Hi, I'm using tMomInput to read from a IBM MQ. I can read messages, but only once. If I enter a message id, is that the new "starting point" to read messages, or will it only read "that message". If it's the later, how to i do the first thing. Also, when reading the message, i'm expecting a standard MQ message including some header fields and an xml file. However, I get one field to work with ("message") how do I parse out the header? Thanks in advance.
I'm trying this in TOS 3.2. the tMomInput in this version has an option to keep listening to messages with a wait in between each check! also you can specify the number of messages to read before aborting. in other version, I believe we use to achieve the same using one of the looping components like the tInfiniteLoop or tLoop. You can connect these components to the tMomInput and then connect the tMomInput with onComponentError to a tSleep to put a wait between each try to listen to a message. also you can parse the message content coming out of this component with the tExtractXMLField under processing/Fields. please let us know if these suggestions work for you.
To parse the message; if this one is an xml content, you have to use the tExtractXMLField to parse the XML struct and retrieve information from the message. As you see in the following screenshot; I'm parsing the message regarding a specific XMLPathNode and XMLPathRequest to fill the expected metadata. Then by the way this metadata could be modify, transform and load as well in your target of your choice (databases, files or another message to another MOM server). Best regards;
Regarding WebSphere MQ To my understanding the "Message ID" that you provide the component is a stopping point (According to the documentation of the MQQueue class). The nature of a queue is that you have a stack of items. All preceding items have to be removed before any subsequent items can be removed. This should give a little insight into why the "Message ID" parameter does what it does. Also, in a queue when items are read they are removed or "popped" off of the queue, so yes, they can only be read once by the first client that access the message. In some instances you are allowed to peek at the next value in the queue, so that you can read it without removing it, but it is not currently available in Talend (if it is an option in Websphere). Another option is to use a topic, with this you can have more than one subscriber, so that the message can be read multipule times by having several subscribers. If you know that the functionality for Peek exists in Websphere or that Topics would be a functionality you want, please submit a feature request to the bug tracker. This could be important functionality, that others will be looking for.
Thanks everyone. I think we'll have to either switch to a Topic or put in an archiving mechanism to enable reprocessing. However, regarding the "header" issue. It's stemming from an error i'm getting when I try to use tExtractXMLField component. For every message I get the following error: Error on line 1 of document : Content is not allowed in prolog. Nested exception: Content is not allowed in prolog. When I look at the logged row, the message has a bunch of weird characters before the XML starts. I'm assuming this is the "header" and it needs to be parsed so that I can send just the XML part to the tExtractXMLField component. Does that sound right? Attached is a screenshot of the log.
you didn't attach the screenshot! but i would suggest to try to parse out the header from the xml body using basic string manipulation functions in java. do this using a tmap component, or any other component, before the tExtractXMLField.
I was able to use string manipulation to get the information I needed. However, i believe there is room for building another component which will get the header information as there may be useful information in there.