The dwp-springboot-starter-correlationid assigns a unique Correlation ID to every transaction across multiple
services. The ID is passed between services in the request header, and set
in MDC within the service. In addition, it provides a
configured RestTemplate with x-correlation-id set in request header.
mvn clean verify install
<dependence>
<groupId>uk.gov.dwp.health</groupId>
<artifactId>springboot-starter-correlationId</artifactId>
<version>${dwp.correlation.id.version}</version>
</dependence>By default, the correlation ID is turned on. To disable it, set the following configuration
in the application.yml
uk:
gov:
dwp:
health:
feature:
correlation:
enabled: falsecustom RestTemplate with CorrelationID tracer enabled. Use following configuration to replace standard RestTemplate.
uk:
gov:
dwp:
health:
correlation:
rest:
enabled: true The starter provide a default RestTemplate with correlation ID capability. The RestTemplate came with a default HttpResponseError handler, however developer can override the default HttpResponseHandler to handle more complex response. This can be achieved by;
@Configuration
public class HttpClientConfig {
@Bean
public ResponseErrorHandler responseErrorHandler() {
return new ResponseErrorHandler() {
@Override
public boolean hasError(ClientHttpResponse response) throws IOException {
//... test response and return as appropriate
return false;
}
@Override
public void handleError(ClientHttpResponse response) throws IOException {
//... handle error as appropriate
}
};
}
}<dependency>
<groupId>uk.gov.dwp.logging</groupId>
<artifactId>encoded-logger-output</artifactId>
<version>${dwp.encoded.logger.version}</version>
</dependency>