Four Stars

Reading XML message from Queue

Hi,

 

I am reading XML messages located in a Queue with Talend. Schema of a message might change from another. 

 

Can i know which XML component should use to pick a filed on the incoming XML messages. (Assume there is one field that is common for all schemas)

 

 

 

 

3 REPLIES
Fifteen Stars

Re: Reading XML message from Queue

Use a tExtractXMLField component to pass the whole document through (using the "." XPath) and retrieve the common field. In the next component (maybe a tMap) use the common field to identify the type and pass the whole document to an output that will lead to a part of the job that will process that XML schema.

                                                                         |-------Type2

Message Queue ---> tExtractXMLField---> tMap ----Type1

                                                                        |--------Type3

Rilhia Solutions
Four Stars

Re: Reading XML message from Queue

Hi,

 

Sample XML is: 

<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>

talend.JPG

 

 

 

with this setup tlogrow is not printing anything. It should print the whole xml right?

 

Actually, my workflow is reading messages and i can print it in tJavaflex.

 

Could you please correct me if i am doing anything wrong.

 

Fifteen Stars

Re: Reading XML message from Queue

I'm assuming you are getting the message in the tJavaFlex, correct? Is this returning as an XML or a String? When you run it, is a record being passed to the tExtractXMLField component? You should be able to see by the row count leading to the tExtractXMLField. Could you show your tJavaFlex code? Alternatively, could you connect your tLogRow to your tJavaFlex to see if the XML is printed to the output through the tLogRow?

 

Unfortunately it is a bit tricky to work out what might be going wrong here as you appear to be doing a lot in Java ....which isn't necessarily bad, although you should probably think about making use of the included components to retrieve messages from message queues if you can.

 

The tExractXMLField component looks OK, but I can't see if you have ticked the Get Node box. You need that to return an XML document. Also, do you have Ignore Namespaces ticked (in the Advanced Settings of the tExtractXMLField component)? That is always useful to switch on when testing to save XPath issues....although your Xpaths are not complicated.

Rilhia Solutions