|
|
Reading EMS message as TextMessage instead of String
hi,
i am new to springs so might be a basic query.
In our application we are reading the incoming EMS message as a string.
These are the configuration settings done:
lt;bean id=quot;instrumentListenerquot; class=quot;org..jms.listener.adapter.Me ssageListenerAdapterquot;gt; lt;property name=quot;delegatequot;gt; lt;ref bean=quot;instrumentMdpquot; /gt; lt;/propertygt; lt;property name=quot;defaultListenerMethodquot;gt; lt;valuegt;processInstrumentlt;/valuegt; lt;/propertygt; lt;/beangt;
Now i want to read the incoming message as a TextMessage so that i can read the header properties of the incoming message which i cannot read when the message comes as string.
I tried changing the properties like:
lt;bean id=quot;instrumentListenerquot; class=quot;org..jms.listener.adapter.Me ssageListenerAdapterquot;gt; lt;property name=quot;delegatequot;gt; lt;ref bean=quot;instrumentMdpquot; /gt; lt;/propertygt; lt;property name=quot;defaultListenerMethodquot;gt; lt;valuegt;processInstrumentlt;/valuegt; lt;/propertygt;
lt;property name=quot;messageConverterquot;gt; lt;valuegt;nulllt;/valuegt; lt;/propertygt; lt;/beangt;
It does not work and gives a runtime error saying:
Cannot resolve reference to bean 'instrumentListener' while setting bean property 'messageListener'; nested exception is org..beans.factory.BeanCreationExce ption: Error creating bean with name 'instrumentListener' defined in class path resource [Instrument-Response.xml]: Initialization of bean failed; nested exception is org..beans.TypeMismatchException: Failed to convert property value of type [java.lang.String] to required type [org..jms.support.converter.MessageC onverter] for property 'messageConverter'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [java.lang.String] to required type [org..jms.support.converter.MessageC onverter] for property 'messageConverter': no matching editors or conversion strategy found.
Can somebody please provide inputs for the same.
Have you tried passing in a reference to a message converter (e.g. SimpleMessageConverter) rather than null to the MessageListenerAdapter bean??
You also need to ensure that a method has been defined in your MDP that takes a TextMessage as as parameter.... |
|