Nivi,

In order to figure out what the JMS Message type is, the best way is
probably to create your own ConsumerMarshaler.  To your JMS SU
project, add a class that extends DefaultConsumerMarshaler and
overrides the populateMessage method that is throwing the exception.
Afterwards, configure the Marshaler you created on your JMS consumer
endpoint.

Something like:
protected void populateMessage(Message message, NormalizedMessage
normalizedMessage) throws Exception {
  if (message instanceof TextMessage) {
    super.populateMessage(message, normalizedMessage);
  } else {
    System.out.println("Found a " + message.getClass());
  }
}

Once you know what the second type is, you can start improving the
else block to correctly handle the payload.  E.g. if it a
BytesMessages as is sometimes sent from a legacy platform, you can use
getBytes() to figure out the payload and convert that into an XML
document.


Regards,

Gert Vanthienen
------------------------
Open Source SOA: http://fusesource.com
Blog: http://gertvanthienen.blogspot.com/



2009/2/26 Nivetha Shri <[email protected]>:
> Hi Gert
> I browsed through JMX but was not able to find out the problem.
> It just has the message that I send, nothing else is there.
>
> It has all the simpletypes set to java.lang.String.
>
> It would be really helpful if you can help me out on this regards
>
> Thanks and Regards
> Nivi
>
>
> On Tue, Feb 24, 2009 at 7:30 PM, Gert Vanthienen
> <[email protected]>wrote:
>
>> Nivi,
>>
>> Could you try browsing the queue through JMX?  The error message 'JMS
>> Message is not a TextMessage' is fairly precise about what's going on, so
>> perhaps there's a leftover message from another application or some other
>> JMS message you aren't expecting?
>>
>> Regards,
>>
>> Gert
>>
>>
>> Nivetha Shri wrote:
>>
>>> Hi Gert
>>>
>>> Thanks for your response. Am sending a jms TextMessage only. Have
>>> given the code snippet that i use to send message. Let me know if
>>> there are any concerns in this.
>>>
>>> Destination destination = session.createTopic("myTopic.input");
>>> TextMessage inputMessage = session.createTextMessage();
>>>
>>> inputMessage.setText("<?xml version='1.0'
>>>
>>> encoding='UTF-8'?><device-request><device-type>D1</device-type><Param>myParam</Param></device-request>);
>>>
>>> MessageProducer producer = session.createProducer(destination);
>>> producer.send(inputMessage);
>>>
>>> Thanks and Regards
>>> Nivi
>>>
>>> On 2/23/09, Gert Vanthienen <[email protected]> wrote:
>>>
>>>
>>>> Nivi,
>>>>
>>>> It looks like the JMS Message that is on the queue is not a
>>>> TextMessage, but some other JMS Message type (e.g. a ByteMessage or
>>>> and ObjectMessage).  How did you send the message to the queue?
>>>>
>>>> There are two ways to get this solved: either change the sending
>>>> application to send a TextMessage or create your own ConsumerMarshaler
>>>> implementation (just inherit from DefaultConsumerMarshaler) to convert
>>>> the other JMS Message type into a Source for sending it though the
>>>> NMR.
>>>>
>>>> Regards,
>>>>
>>>> Gert Vanthienen
>>>> ------------------------
>>>> Open Source SOA: http://fusesource.com
>>>> Blog: http://gertvanthienen.blogspot.com/
>>>>
>>>>
>>>>
>>>> 2009/2/20 Nivetha Shri <[email protected]>:
>>>>
>>>>
>>>>> Hi All
>>>>>
>>>>> Am getting the following exception when i send an xml message to a
>>>>> output
>>>>> queue using apache camel and servicemix.
>>>>>
>>>>> My xml is a valid one
>>>>>
>>>>> Here is the stack trace:
>>>>>
>>>>> WARN  - DefaultMessageListenerContainer - Execution of JMS message
>>>>> listener
>>>>> failed
>>>>> javax.jms.JMSException: Error sending JBI exchange
>>>>>      at
>>>>>
>>>>> org.apache.servicemix.jms.endpoints.AbstractConsumerEndpoint.onMessage(AbstractConsumerEndpoint.java:569)
>>>>>      at
>>>>>
>>>>> org.apache.servicemix.jms.endpoints.JmsConsumerEndpoint$1.onMessage(JmsConsumerEndpoint.java:446)
>>>>>      at
>>>>>
>>>>> org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:506)
>>>>>      at
>>>>>
>>>>> org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:463)
>>>>>      at
>>>>>
>>>>> org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:435)
>>>>>      at
>>>>>
>>>>> org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:322)
>>>>>      at
>>>>>
>>>>> org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:260)
>>>>>      at
>>>>>
>>>>> org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:944)
>>>>>      at
>>>>>
>>>>> org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:868)
>>>>>      at java.lang.Thread.run(Thread.java:595)
>>>>> Caused by: java.lang.UnsupportedOperationException: JMS message is not a
>>>>> TextMessage
>>>>>      at
>>>>>
>>>>> org.apache.servicemix.jms.endpoints.DefaultConsumerMarshaler.populateMessage(DefaultConsumerMarshaler.java:104)
>>>>>      at
>>>>>
>>>>> org.apache.servicemix.jms.endpoints.DefaultConsumerMarshaler.createExchange(DefaultConsumerMarshaler.java:72)
>>>>>      at
>>>>>
>>>>> org.apache.servicemix.jms.endpoints.AbstractConsumerEndpoint.onMessage(AbstractConsumerEndpoint.java:536)
>>>>>      ... 9 more
>>>>> WARN  - JbiBinding                     - Unable to convert message body
>>>>> of
>>>>> type class [Ljava.lang.String; into an XML Source
>>>>>
>>>>>
>>>>> Any insight on this will be very helpful
>>>>>
>>>>>
>>>>> RegardsNivi
>>>>>
>>>>>
>>>>>
>>>>
>>>
>>>
>>
>>
>

Reply via email to