Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

To identify the xsd of xml message which is received from MQ

Tags:

ibm-mq

In IBM MQ, I have a requirement where I can get many types of xml from the queue. The xml messages will be conformed to already specified xsd (there are say, 5 xsd - which means I can get 5 different xml). When I get the message from queue, I would like to know the type of xml (if its xsd1 or xsd2 or so on)

The reason why I would want to know is, I am using a JaxB interface with SAX implementation, for which I need to give the java object corresponding to the xml as parameter. So I have to know which xsd the input and is and assign the parameter correspondingly.

The options I have is to set a property in the header to the message, but the party who is dropping the message into MQ is not ready.

What other options do I have? Can I get the file name (of xml) from the mq and find the xsd based on the name of the file? Or do I have to do I sax parsing and identify the root tag and derive the xsd type? Any other better option anybody has in mind?

like image 755
Subashree Venkatraman Avatar asked Mar 17 '15 16:03

Subashree Venkatraman


People also ask

How do I check my messages on IBM MQ?

In the Content view, right-click Q1, then click Browse Messages. The Message browser opens to show the list of the messages that are currently on Q1. Double-click the last message to open its properties dialog.

How do I receive messages from MQ?

On the MQ Connection tab, set the Connection property to Local queue manager, and then the Destination queue manager property to TASK2_QUEUE_MANAGER . On the Input Message Parsing tab, set the Message domain property to BLOB. On the Advanced tab: Set the Copy message property to Copy Entire Message.

What is the message format type in IBM MQ?

The format of the payload is decided by the application, not MQ. You can send messages in whatever format you want. As mentioned in the developersWorks article, MQ has some predefined formats such MQFMT_STRING which means the format of the payload is text. This format is typically used for XML, text message body.

What is MQ message ID?

This is a byte string that is used to distinguish one message from another. Generally, no two messages should have the same message identifier, although this is not disallowed by the queue manager.


1 Answers

Think of MQ like the Post Office. When you get a letter, the post office doesn't mess with anything on the inside (the payload) and if it changes the outside, it only changes routing information. If you want to sort incoming mail to different recipients, whoever is sending it has to put the data against which the sort criteria operate on the outside of the envelope. If that doesn't work, you must open the envelope and look for the recipient name, department, or whatever on the papers inside.

Your MQ message is that envelope. The sort criteria can be different queue names, a property of the message, a property of the message header, or something in the payload. But unless the sender explicitly sets the destination queue name based on the selection criteria, or sets the message or header property, your only option is to inspect the payload and figure it out.

If you have to inspect the payload, this is a perfect scenario for IBM Integration Broker. But you can also write an application to perform this function. Very often this is performed by a Dispatch app which gets the message, figures out where it goes, then puts it onto another queue and COMMITs the GET and PUT operations. But if the dispatch app must parse the XML to determine the correct queue, the message has to be parsed twice - once by the dispatcher, once by the receiving app.

like image 120
T.Rob Avatar answered Jan 03 '23 15:01

T.Rob