XML & Web services: Publishing contents of an XML document to a topic in JMS
- Posted by: Arpan Joshi
- Posted on: October 06 2005 14:13 EDT
I am trying to develop a JMS based messaging system using pub-sub model.
Before my publisher publishes messages it has to parse an XML configuration file which will be as follows:
Values for all of these elements are required and based on the value of topic element I want to select the topic to publish this message to. In this case the value of topic element in the configuration file is timecard so my topic for this message has to be timecard. Now, the elements till the body elements are all part of my header and I don't want to send the header as part of my message. Once the header information(all header elements are present) is verified (if not I want to throw an exception),
I want to send the CDATA(if not empty) which is the message body as part of my JMS message.
Please help me in solving this problem. I am ok in validating the XML file before send it as a message but verifying the header information and choosing the topic on the basis of the topic element is what I need help with.
Hope this is clear enough.
- Publishing contents of an XML document to a topic in JMS by James Strachan on October 08 2005 02:42 EDT
- Publishing contents of an XML document to a topic in JMS by srinivasa rallabandi on October 10 2005 12:02 EDT
I'm not sure I follow what your question actually is :)
You can certainly send whatever the XML is you want as a JMS TextMessage without any issue. Then use any logic you like to generate a topic String by combining fields together (with "." as a separator) - then just send the message.
String topicExpression = ...
Destination destination = session.createTopic(topicExpression);
Once you got the XML as a text message, you need to parse it to find the destination and send a message to it.
Alternatively if it is a JMS message you received, you can find the reply to destination and reply back.