Using Transformers.toJson() my json date looks like this:
"createdDate":{"year":2017,"month":"OCTOBER","monthValue":10,"dayOfMonth":25,"hour":7,"minute":57,"second":36,"nano":972000000,"dayOfWeek":"WEDNESDAY","dayOfYear":298,"chronology":{"calendarType":"iso8601","id":"ISO"}}
Here is the outbound ampq configuration:
@Bean
public IntegrationFlow outboundCdrRabbitFlowDefinition() {
return IntegrationFlows.from(CHANNEL_NAME)
.transform(Transformers.toJson())
.handle(Amqp.outboundAdapter(new RabbitTemplate(cachingConnectionFactory))
.routingKey("routing-key"))
.get();
}
The consumer of the rabbit queue expects the format "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
Is there any way i can override the default ObjectMapper used by spring integration?
For example i have the this configuration in my web api config that extends WebMvcConfigurerAdapter:
@Bean
public ObjectMapper objectMapper() {
ObjectMapper mapper = new ObjectMapper();
mapper.setTimeZone(UTC_TIME_ZONE);
mapper.setDateFormat(ISO_8601_DATE_FORMAT);
mapper.registerModule(new Jdk8Module());
mapper.registerModule(new JavaTimeModule());
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
return mapper;
}
@Bean
public MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter() {
MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter = new MappingJackson2HttpMessageConverter();
mappingJackson2HttpMessageConverter.setObjectMapper(objectMapper());
return mappingJackson2HttpMessageConverter;
}
@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
converters.add(mappingJackson2HttpMessageConverter());
super.configureMessageConverters(converters);
}
Is there some way to reuse the objectMapper bean in Spring Integration so the mapping configuration is the same across all my outbound endpoints, web api http or integration ampq?