Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Integration serializes MessageHeader Object

i have some services, one implemented with Grails 2.4.2 (Spring 4.0.5) some implemented as Spring Web (Spring 4.0.5) and one implemented with Spring Boot 1.2.1 (Spring 4.1.4).

The services communicate over RabbitMQ with spring-integration.

Communication between Grails and the Spring Web services is fine, but it's not possible to communicate with the Spring Boot service. Because Spring Boot uses a newer Spring version and the serial version of the MessageHeader class has changed.

What can i do to avoid this problem?

Here the exception:

Caused by: org.springframework.messaging.MessagingException: Failure occured in AMQP listener while attempting to convert and dispatch Message.; nested exception is org.springframework.amqp.support.converter.MessageConversionException: failed to convert serialized
 Message content
        at org.springframework.integration.amqp.channel.AbstractSubscribableAmqpChannel$DispatchingMessageListener.onMessage(AbstractSubscribableAmqpChannel.java:201) ~[spring-integration-amqp-4.0.2.RELEASE.jar:na]
        at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:693) ~[spring-rabbit-1.3.4.RELEASE.jar:na]
        ... 10 common frames omitted
Caused by: org.springframework.amqp.support.converter.MessageConversionException: failed to convert serialized Message content
        at org.springframework.amqp.support.converter.SimpleMessageConverter.fromMessage(SimpleMessageConverter.java:112) ~[spring-amqp-1.3.4.RELEASE.jar:na]
        at org.springframework.integration.amqp.channel.AbstractSubscribableAmqpChannel$DispatchingMessageListener.onMessage(AbstractSubscribableAmqpChannel.java:176) ~[spring-integration-amqp-4.0.2.RELEASE.jar:na]
        ... 11 common frames omitted
Caused by: java.lang.IllegalArgumentException: Could not deserialize object
        at org.springframework.amqp.utils.SerializationUtils.deserialize(SerializationUtils.java:79) ~[spring-amqp-1.3.4.RELEASE.jar:na]
        at org.springframework.amqp.support.converter.SimpleMessageConverter.fromMessage(SimpleMessageConverter.java:107) ~[spring-amqp-1.3.4.RELEASE.jar:na]
        ... 12 common frames omitted
Caused by: java.io.InvalidClassException: org.springframework.messaging.MessageHeaders; local class incompatible: stream classdesc serialVersionUID = -4615750558355702881, local class serialVersionUID = 7035068984263400920
        at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:617) ~[na:1.7.0_51]
        at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1622) ~[na:1.7.0_51]
        at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1517) ~[na:1.7.0_51]
        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1771) ~[na:1.7.0_51]
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1350) ~[na:1.7.0_51]
>       at org.springframework.amqp.utils.SerializationUtils.deserialize(SerializationUtils.java:76) ~[spring-amqp-1.3.4.RELEASE.jar:na]
like image 789
Cyphercrack Avatar asked Sep 23 '26 17:09

Cyphercrack


1 Answers

Don't serialize the entire Message<?>; use the AMQP adapters' ability to map Message headers to amqp headers and vice-versa.

I am not sure how that works on the grails side but you'd need to do the mapping over there too.

like image 80
Gary Russell Avatar answered Sep 26 '26 19:09

Gary Russell



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!