org.springframework.integration.message.MessagingException: expected a 'org.springframework.integration.message.Message', but received 'class org.springframework.batch.integration.chunk.ChunkRequest'

Spring JIRA | Dave Syer | 8 years ago
  1. 0

    JmsGateway is able to send messages to the channel without losing header information because inherited SimpleMessagingGateway.sendAndReceive sniffs payload to be Message without passing it to MessageCreator but reply message is always passed to MessageMapper which strips headers and passes only payload back to JmsGateway. This leads to exception. org.springframework.integration.message.MessagingException: expected a 'org.springframework.integration.message.Message', but received 'class foo.bar.Payload'' at org.springframework.integration.adapter.jms.HeaderMappingMessageConverter.toMessage(HeaderMappingMessageConverter.java:64) at org.springframework.jms.listener.adapter.MessageListenerAdapter.buildMessage(MessageListenerAdapter.java:517) at org.springframework.jms.listener.adapter.MessageListenerAdapter.handleResult(MessageListenerAdapter.java:493) at org.springframework.jms.listener.adapter.MessageListenerAdapter.onMessage(MessageListenerAdapter.java:360) Quick fix would be to use 'sendAndReceiveMessage 'as MessageListenerAdapter method. I think more appropriate way would be to remove whole sniffing capability along with MessagingGateway.sendAndReceiveMessage because it would focus MessagingGateway as per it's javadoc. I checked the remaining dependencies and it seems that only remoting (INT-240) really uses this method. GatewayProxyFactoryBean seems to have support for it but I guess that just because there's such a method. If awareness "of channels or even messages" is required (RMI, JMS, HttpInvoker, etc) the MessageEndpoint derivations might be more appropriate. At least to me MessageChannelTemplate seems to fit better for the purpose than MessagingGateway.

    Spring JIRA | 8 years ago | Tuomas Kiviaho
    org.springframework.integration.message.MessagingException: expected a 'org.springframework.integration.message.Message', but received 'class foo.bar.Payload''
  2. Speed up your debug routine!

    Automated exception search integrated into your IDE

  3. 0

    JmsGateway is able to send messages to the channel without losing header information because inherited SimpleMessagingGateway.sendAndReceive sniffs payload to be Message without passing it to MessageCreator but reply message is always passed to MessageMapper which strips headers and passes only payload back to JmsGateway. This leads to exception. org.springframework.integration.message.MessagingException: expected a 'org.springframework.integration.message.Message', but received 'class foo.bar.Payload'' at org.springframework.integration.adapter.jms.HeaderMappingMessageConverter.toMessage(HeaderMappingMessageConverter.java:64) at org.springframework.jms.listener.adapter.MessageListenerAdapter.buildMessage(MessageListenerAdapter.java:517) at org.springframework.jms.listener.adapter.MessageListenerAdapter.handleResult(MessageListenerAdapter.java:493) at org.springframework.jms.listener.adapter.MessageListenerAdapter.onMessage(MessageListenerAdapter.java:360) Quick fix would be to use 'sendAndReceiveMessage 'as MessageListenerAdapter method. I think more appropriate way would be to remove whole sniffing capability along with MessagingGateway.sendAndReceiveMessage because it would focus MessagingGateway as per it's javadoc. I checked the remaining dependencies and it seems that only remoting (INT-240) really uses this method. GatewayProxyFactoryBean seems to have support for it but I guess that just because there's such a method. If awareness "of channels or even messages" is required (RMI, JMS, HttpInvoker, etc) the MessageEndpoint derivations might be more appropriate. At least to me MessageChannelTemplate seems to fit better for the purpose than MessagingGateway.

    Spring JIRA | 8 years ago | Tuomas Kiviaho
    org.springframework.integration.message.MessagingException: expected a 'org.springframework.integration.message.Message', but received 'class foo.bar.Payload''

    Root Cause Analysis

    1. org.springframework.integration.message.MessagingException

      expected a 'org.springframework.integration.message.Message', but received 'class org.springframework.batch.integration.chunk.ChunkRequest'

      at org.springframework.integration.adapter.jms.HeaderMappingMessageConverter.toMessage()
    2. org.springframework.integration
      HeaderMappingMessageConverter.toMessage
      1. org.springframework.integration.adapter.jms.HeaderMappingMessageConverter.toMessage(HeaderMappingMessageConverter.java:62)
      2. org.springframework.integration.adapter.jms.HeaderMappingMessageConverter.toMessage(HeaderMappingMessageConverter.java:66)
      2 frames