One Star

Problem using tMomInput to process XML

I'm attempting to create a job like this: tMomInput => tMap => tLogRow that pulls an XML message out of an ActiveMQ JMS message and am having an issue where I get no data coming out in the tLogRow. I've verified that the tMomInput is receiving the message as a TextMessage from MQ. For the Schema settings for the tMomInput I selected 'Repository' and then pointed to a generic schema that I set up based on a simple xml document like this:
<?xml version="1.0" encoding="UTF-8" ?>
<product xmlns="" xmlns:xsi="" xsi:schemaLocation=" product.xsd">
<description>Happy Fun Ball</description>
The Generic Schema has entries for id, description, and cost which I assume is correct. In the tMap I've mapped across the data from the tMomInput (id, description, cost) over to the tLogRow. Then when I run the job I get this:
Connecting to URL: tcp://
Consuming queue: blah.blah
We will consume messages while they continue to be delivered
id: |description: |cost:
As you can see the data for the attributes is not pulled from the XML file and displayed. I've verified that the messages are being queued and de-queued in MQ and the job is displaying the messages onscreen going between the components. My guess is that there's something wrong with the definition of the generic schema but am not sure since I'm new to the tool.
One Star

Re: Problem using tMomInput to process XML

One more thing to note is that when I created this job - that when I switch from Built-in to Repository on the schema on the tMomInput that it creates two errors in the java class that gets built. The java code is there to set the 'from' and the 'message' attribute on the row1Struct class even though this class has the id, description, and cost attributes on it.
while ((message_tMomInput_1 = consumer_tMomInput_1.receive()) != null) {
javax.jms.TextMessage txtMsg_tMomInput_1 = (javax.jms.TextMessage) message_tMomInput_1;
String msg_tMomInput_1 = txtMsg_tMomInput_1.getText();
row1.from = "CHOO.CHOO"; //error here
row1.message = msg_tMomInput_1; //error here
When I created another job and used "Built-in" instead of "Repository" then the above code is right - the row1Struct class has the two attributes specified above. So it looks like possibly the ActiveMQ tMomInput code generation has issues? Or is it related to the Generic Schema I selected. Hope the more information sheds some light.
One Star

Re: Problem using tMomInput to process XML

I dont have an ActiveMQ here to test this out with, but I believe that you need to leave the from and message in the tMomInput schema, just try mapping those two fields to a tLogRow and see if you get data. The message should be the full xml message (the payload). If you do get the xml in the message field, you will then use a tXMLParseField component to parse that xml into the fields that you were expecting. You will need to specify a loop xpath and which fields you want. (e.g. loop on /product fields ./id ./description ./cost)

Let us know how that works and we'll go from there.


One Star

Re: Problem using tMomInput to process XML

Replying on this old thread because I faced the same issue, came here looking for a solution but didn't find it. Eventually, we managed to sort out the flow. If the input to your tMap is as expected, this is probably occurring due to an incorrect XPath in your tMap. 
Have a look at the following in your configurations:-
a. The built-in schema for a tMOMInput is set to two values: 'from' and 'message', both of type String. Since the message type is defined as a string, the payload is converted from an XML document to a String and the tags are probable escaped too. Hence, XPath can no longer be applied on it in your tMap component. Make sure your 'message' is set to document type
b. Make sure that there are no default namespaces configured in the input XML schema, and if they are, adhere to it in your request payload.
Here's the flow we used:-
tMOMInput (Payload from ActiveMQ) >> tXMLMap >> tLogRow
tMOMInput: Use the default schema which contains from as a string and message as a document. Pass these on to the tXMLMap action.
tXMLMap: Create a XML schema for the payload being sent by ActiveMQ and configure that to the 'message' part of the input. Ignore the 'from' value. 
In the output of your tXMLMap, set the output as a document and configure an output schema corresponding to the output payload. Set the loop elements for both input and output (root if no repeating groups, or the repeating group tag if present). Map the input and output tags. The output should now be an XML document containing the required payload and can be seen in the tLogRow component
P.S: This should work on tMAP too. I've used tXMLMap because I needed an XML output. Just Map the input XML fields to output values/variables that you need instead of output tags.