Reputation: 337
I have a JMS listener which is receiving ByteMessage from another application. The current application is working with Spring JMS. I am trying to introduce spring integration here. So I added the following sample code to listen for the message.
@Configuration
public class JmsConfiguration {
@Bean
public IntegrationFlow integrationFlow(ConnectionFactory connectionFactory) {
return IntegrationFlows
.from(Jms.messageDrivenChannelAdapter(connectionFactory)
.destination("fooQueue"))
.transform("hello "::concat)
.get();
}
Then I am getting the class cast exception as below:
java.lang.ClassCastException: [B cannot be cast to java.lang.String
I am getting a ByteMessage and I am not finding a good example on how the ByteMessage with Byte array payload can be extracted. I am new to the spring integration world.
Upvotes: 0
Views: 749
Reputation: 174574
Add .transform(Transformers.objectToString())
before your .transform()
. BytesMessage
will result in a message with a byte[]
payload so you need to convert it to a String
before trying to concatenate it.
Upvotes: 1