Splunk 有transaction
可以duration
在按 id 分组的日志之间生成的命令:
2020-01-01 12:12 event=START id=1
2020-01-01 12:13 event=STOP id=1
Run Code Online (Sandbox Code Playgroud)
正如它所描述的
如何计算Datadog中事件之间的持续时间?
如果我查询:
select * from pg_stat_activity where application_name ~ 'example-application';
Run Code Online (Sandbox Code Playgroud)
我得到很多行,状态是idle
和查询COMMIT
.它们持久耐用,不会消失.一段时间后,我的应用程序达到hibernate.c3p0.max_size
(池中的最大JDBC连接数)限制并停止使用数据库.
一些应用程序实现细节在其他SO线程中描述: 线程池中的Guice DAO提供程序 - 查询变为"在转换中空闲"
为什么会这样?如何解决这个问题呢?
我用compile 'org.springframework.retry:spring-retry:1.2.2.RELEASE'
了Spring Boot 1.5.9.RELEASE
.
配置为重试我的方法,它运作良好:
@Retryable(value = { IOException.class }, maxAttempts = 5, backoff = @Backoff(delay = 500))
public void someMethod(){...}
Run Code Online (Sandbox Code Playgroud)
重试发生时如何输出某些特定消息?
我有Spring Boot端点,它有枚举作为查询参数:
@GetMapping("/example")
public List<Example> getByEnum(@RequestParam(name = "exampleEnum", required = false) ExampleEnum exampleEnum) {
// code
}
Run Code Online (Sandbox Code Playgroud)
和枚举类:
public enum ExampleEnum {
FIRST,
SECOND,
}
Run Code Online (Sandbox Code Playgroud)
如果我将大写枚举值传递给endpoit,它反序列化很好,但它会抛出小写错误:
java.lang.IllegalArgumentException: No enum constant
Run Code Online (Sandbox Code Playgroud)
如何在Spring Boot Rest端点中反序列化枚举忽略大小写?
我有项目 Guice - Jersey 1.19 项目与依赖项:
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-servlet</artifactId>
<version>${version.jersey}</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>${version.jersey}</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
<version>${version.jersey}</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-core</artifactId>
<version>${version.jersey}</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-json</artifactId>
<version>${version.jersey}</version>
</dependency>
<dependency>
<groupId>com.sun.jersey.contribs</groupId>
<artifactId>jersey-multipart</artifactId>
<version>${version.jersey}</version>
</dependency>
<dependency>
<groupId>com.sun.jersey.contribs</groupId>
<artifactId>jersey-guice</artifactId>
<version>${version.jersey}</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
我已经用 Jersey 版本 2.22.2 替换了它们:
<dependency>
<groupId>com.squarespace.jersey2-guice</groupId>
<artifactId>jersey2-guice</artifactId>
<version>0.10</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>${version.jersey}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-server</artifactId>
<version>${version.jersey}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<version>${version.jersey}</version>
</dependency>
<dependency>
<groupId>com.owlike</groupId>
<artifactId>genson</artifactId>
<version>1.4</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
我有服务("/rest/*").with(GuiceContainer.class, params); 但目前没有 PackagesResourceConfig 和 GuiceContainer。
public class BootstrapServletModule …
Run Code Online (Sandbox Code Playgroud) 我总是在使用 Google 登录时遇到这个问题。我有一个 Android 应用程序,用户连接使用该应用程序向 Google 进行身份验证,然后将 idToken 发送到我的服务器。服务器使用 Google 提供的库 (GoogleIdTokenVerifier) 来验证令牌。
GoogleIdTokenVerifier verifier = new GoogleIdTokenVerifier.Builder(transport, jsonFactory)
.setAudience(audience)
.setIssuer("https://accounts.google.com")
.build();
GoogleIdToken idToken = null;
try {
idToken = verifier.verify(idTokenString);
} catch (Exception e) {
e.printStackTrace();
}
if (idToken != null) {
GoogleIdToken.Payload payload = idToken.getPayload();
String userId = payload.getSubject();
System.out.println("User ID: " + userId);
String email = payload.getEmail();
System.out.println("Emaail:" + email);
return userId;
} else {
System.out.println("Invalid ID token.");
return null;
}
Run Code Online (Sandbox Code Playgroud)
这工作了一段时间,然后突然验证开始总是失败。什么也没有变!有任何想法吗?
我应该在每个方法调用中创建新的 ExecutorService 还是每个类使用一个?就性能而言,哪个是首选?
public class NotificationService {
public void sendNotification(User recipient) {
ExecutorService notificationsPool = Executors.newFixedThreadPool(10);
// code
notificationsPool.shutdown();
}
}
Run Code Online (Sandbox Code Playgroud)
或者
public class NotificationService {
ExecutorService notificationsPool = Executors.newFixedThreadPool(10);
public void sendNotification(User recipient) {
// code
}
}
Run Code Online (Sandbox Code Playgroud) 服务类用@Service又名FooServiceImpl
注释,这使其符合自动装配的条件。为什么在单元测试期间这个类没有被拾取和自动装配?@Component
@Service
public class FooServiceImpl implements FooService {
@Override
public String reverse(String bar) {
return new StringBuilder(bar).reverse().toString();
}
}
@RunWith(SpringRunner.class)
//@SpringBootTest
public class FooServiceTest {
@Autowired
private FooService fooService;
@Test
public void reverseStringShouldReverseAnyString() {
String reverse = fooService.reverse("hello");
assertThat(reverse).isEqualTo("olleh");
}
}
Run Code Online (Sandbox Code Playgroud)
测试未能加载应用程序上下文,
2018-02-08T10:58:42,385 INFO Neither @ContextConfiguration nor @ContextHierarchy found for test class [io.github.thenilesh.service.impl.FooServiceTest], using DelegatingSmartContextLoader
2018-02-08T10:58:42,393 INFO Could not detect default resource locations for test class [io.github.thenilesh.service.impl.FooServiceTest]: no resource found for suffixes {-context.xml}.
2018-02-08T10:58:42,394 INFO …
Run Code Online (Sandbox Code Playgroud) Google 于2018年8月13日将Google Maps JavaScript API V3参考更新为v3.34.目前没有发行说明.我注意到我们的网站缩放和地图类型选择按钮比以前大得多.此外,这种变化似乎影响了许多其他网站.控件是默认值,取自Google API.当我改变版本时,v=3.33
它们变得像以前一样大小.但是,v=3.33
将在几个月内弃用.我应该等待Google修复吗?或者使用v3.34
并制作自定义控件?
我有以下测试:
org.springframework.test.web.client.MockRestServiceServer mockServer
Run Code Online (Sandbox Code Playgroud)
当我使用any(String.class)
或确切的 URL运行时,它们运行良好:
mockServer.expect(requestTo(any(String.class)))
.andExpect(method(HttpMethod.GET))
.andRespond(withSuccess("response", MediaType.APPLICATION_JSON));
Run Code Online (Sandbox Code Playgroud)
或者:
mockServer.expect(requestTo("https://exact-example-url.com/path"))
.andExpect(method(HttpMethod.GET))
.andRespond(withSuccess("response", MediaType.APPLICATION_JSON));
Run Code Online (Sandbox Code Playgroud)
我希望通过字符串模式请求避免检查确切的 URL。我可以在Spring MockRestServiceServer上编写自定义匹配器来处理对同一 URI 的多个请求(自动发现)
有没有其他方法可以mockServer.expect(requestTo(".*example.*"))
通过 String 模式制作?
java ×6
spring-boot ×4
spring ×3
guice ×2
android ×1
concurrency ×1
datadog ×1
enums ×1
google-login ×1
google-maps ×1
hibernate ×1
jersey ×1
jersey-2.0 ×1
junit ×1
logging ×1
mockito ×1
mockserver ×1
monitoring ×1
postgresql ×1
rest ×1
servlets ×1
splunk-query ×1
spring-retry ×1
threadpool ×1
token ×1
unit-testing ×1