I'm using Spring Integration + Spring Cloud Stream to create the following flow:
@Bean
public IntegrationFlow testEventFlow(){
return IntegrationFlows.from(TestEventSink.INPUT)
.transform(Transformers.fromJson(TestEvent.class))
.transform(TestEvent::getSomeId)
.log()
.channel("nullChannel")
.get();
}
Test event class is:
public class TestEvent {
private String someId;
public TestEvent(){}
public TestEvent(String someId){
this.someId = someId;
}
public String getSomeId(){
return someId;
}
public void setSomeId(String someId){
this.someId = someId;
}
}
Problem here is that messages from TestEventSink.INPUT
are coming in snake case:
{ "some_id" : "1234" }
If I annotate Test Event class with @JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class)
it works well, but I can't annotate the class because it's from a third party library.
I tried to set the property spring.jackson.property-naming-strategy=SNAKE_CASE
, but It doesn't worked either.
I also tried:
@Bean
public ObjectMapper objectMapper(){
ObjectMapper mapper = new ObjectMapper();
mapper.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE);
return mapper;
}
But it doesn't worked.
I think that I can use a custom mapper for that transformation, but I'm looking for something that changes the configuration of all Spring Integration JSON transformers at same time.
Thanks in advance!