3

I'm using Spring Integration with AMQP-backed messages and I'd prefer to use JSON instead of the default Java serialization for messages. This preference is due in part to serialization exceptions encountered when using Kotlin objects.

While researching the issue, I came across this post:

Spring integration - AMQP backed message channels and message conversion

So it seems the ability to use JSON serialization with AMQP-backed messages has only recently been supported. Moreover, I believe Spring Cloud Stream project provides support for this approach out-of-the-box but I haven't been able to figure out how to achieve something similar with SI.

I came across a post that provides a means to do this channel-by-channel but it seems tedious to configure it this way for each channel when I really just want to use it across the board.

Community
  • 1
  • 1
roborative
  • 164
  • 1
  • 11

1 Answers1

1

Is there something preventing you from upgrading to 4.3?

<int-amqp:channel id="withEP" 
    extract-payload="true" message-converter="jackson" />

There's currently no way to globally set options for all channels of a particular type.

Gary Russell
  • 166,535
  • 14
  • 146
  • 179
  • I'm currently using 4.3.1 so that's not a problem. However, I'm using the DSL approach for configuration and it's not apparent to me how to set the extract payload property. – roborative Aug 26 '16 at 18:42
  • The DSL usually lags a little behind the main framework - that should change in 5.0 when we merge the DSL into the main project. In the meantime, I opened [an issue for the DSL](https://github.com/spring-projects/spring-integration-java-dsl/issues/107). – Gary Russell Aug 26 '16 at 18:45
  • Thanks, Gary. In the interim, would it be possible to do something like this? `@Bean public IntegrationFlow transformFlow() { return IntegrationFlows.from("input") .transform(Transformers.toJson()) .get(); }` That is, could I use a transformer to get around the serialization issues? – roborative Aug 26 '16 at 18:53
  • Yes, that should solve it for now, or you could subclass the channel spec and add the same code as is in [my PR to add extractPayload](https://github.com/spring-projects/spring-integration-java-dsl/pull/108). – Gary Russell Aug 26 '16 at 19:57