View Full Version : Send XML format message
kurimus
05-05-2008, 10:15 AM
Hello all,
I'm pretty new (15mins) with Spring.NET so please excuse me if this is not right place to post my question. However, i am using NMS with our ActiveMQ server and i am having problems to send xml message into queue. Sending simple "string" works fine...
"Cannot convert object [System.Xml.XmlDocument] to NMS message"
any suggestions, or am i totally lost?
Mark Pollack
05-05-2008, 03:19 PM
Hi,
The default converter that is used in NmsTemplate, SimpleMessageConverter, knows how to convert from the following .NET types to NMS Message types (and in the other direction)
string -> ITextMessage
IDictionary -> IMapMessage
byte array -> IBytesMessage
ISerializable -> IBytesMessageYou can simply convert your XML payload to a string via the standard XML API and then it will be sent via a TextMessage. You can provide your own IMessageConverter implementation and register it with NmsTemplate, so that it can handle that deal with XML object directly instead of having to perform the extra API manipulation. You can differentiate the fact that the payload contains XML, as compared to a normal string, by setting a NMS property value. Since this is a common case, I've added a JIRA (http://jira.springframework.org/browse/SPRNET-936) issue to add this to the SimpleMessageConverter.
Cheers,
Mark
kurimus
05-05-2008, 04:05 PM
Hi,
The default converter that is used in NmsTemplate, SimpleMessageConverter, knows how to convert from the following .NET types to NMS Message types (and in the other direction)
string -> ITextMessage
IDictionary -> IMapMessage
byte array -> IBytesMessage
ISerializable -> IBytesMessageYou can simply convert your XML payload to a string via the standard XML API and then it will be sent via a TextMessage. You can provide your own IMessageConverter implementation and register it with NmsTemplate, so that it can handle that deal with XML object directly instead of having to perform the extra API manipulation. You can differentiate the fact that the payload contains XML, as compared to a normal string, by setting a NMS property value. Since this is a common case, I've added a JIRA (http://jira.springframework.org/browse/SPRNET-936) issue to add this to the SimpleMessageConverter.
Cheers,
Mark
Mark, thank's for your your quick reply.
I've tried conversion to string method and everything
seems to be fine now.
Erno
vBulletin® v3.7.3, Copyright ©2000-2008, Jelsoft Enterprises Ltd.