• Index
  •  » Talend Open Studio for Data Integration » Usage, Operation
  •  » [resolved] How to use tXMLMap or DB component to catch up a lookup failure

#1 2011-11-24 19:07:13

sberyozkin
Talend team
Registered: 2011-02-17
Posts: 50

[resolved] How to use tXMLMap or DB component to catch up a lookup failure

I'm creating a tRESTRequest-based job for looking up customer records in a db.
Job consists of 4 components:
tRESTRequest provides a lookup variable to tXMLMap (example, 'id' of type Integer), tXMLMap delegates to a DB component to do a lookup which usually returns 2 fields, ex, 'id' and 'name' and then tXMLMap uses the returned fields to create an xml payload which is fed into tRESTResponse.

See the attached images please.
For example,

GET http://localhost:8088/customer/1

will return

<customer><name>Fred</name></customer>.

However, if no a given customer exists, I'm getting

<customer><name/></customer>

I'd like to configure tXMLMap somehow to react to the fact that no a customer with id like '6' exists and return some different xml response.
Can I handle it somehow in tXMLMap alone or should I use the DB components triggers somehow ?

thanks, Sergey


Uploaded Images

Last edited by sberyozkin (2011-11-29 13:47:48)

Offline

#2 2011-11-25 20:54:52

walkerca
Member
Company: Bekwam, Inc.
Registered: 2011-01-12
Posts: 253
Website

Re: [resolved] How to use tXMLMap or DB component to catch up a lookup failure

Prior to the tXMLMap, you can use a tMap and tFilterRow to establish a reject output.  Left outer join the lookup to the DB customers, passing along the db's id which will be null if the lookup fails.  tFilterRow records with a db id.  The filter connection goes on to tXMLMap while the reject connection goes to a second tXMLMap which produces XML specific to the reject handling.

The reject handling could be a separate XML document.  Or, you can use 2 tAdvancedFileOutputXMLs in append mode instead of the tXMLMap.  See the section "Multiple Loops" in the blog post http://bekwam.blogspot.com/2011/09/xml- … urces.html for how to do thi.


Visit bekwam.blogspot.com for Talend topics and tutorials.  Twitter @bekwaminc for updates.

Offline

#3 2011-11-28 12:14:58

pcoffre
Talend Team
Registered: 2009-03-26
Posts: 526
Website

Re: [resolved] How to use tXMLMap or DB component to catch up a lookup failure

Hi Carl,

Nice blog post, thanks!

Best,
Pcoffre.


Follow Talend on Twitter, Linkedin, Facebook and the forum.
Download and try Talend solutions

Offline

#4 2011-11-29 14:02:39

sberyozkin
Talend team
Registered: 2011-02-17
Posts: 50

Re: [resolved] How to use tXMLMap or DB component to catch up a lookup failure

Sorry for a delay, I did not get a notification the response was available.
Can you clarify please how to use tFilterRow ? I've uploaded two more images, tFilterRow1.png and tFilterRow2.png.

tFilterRow1.png shows a tFilterRow being inserted between tRESTRequest and tXMLMap, with Customers (DB) acting as a lookup. Note that 'id' which is coming from tRESTRequest is never null or empty, so the tFilterRow/Reject is never activated, if no record exist I simply get an empty customer XML back,

tFilterRow2.png shows a tFilterRow being inserted between Customers and tXMLMap, in the actual job it has a 'NAME NotEqualTo ""' rule (CUSTOMERS return ID & NAME).
When I have an existing record being retrieved, tFilterRow directs it to the main output which is fine, and if I request a customer with a non-existent id, the job hangs and the tFilterRow rejects output is not activated.

Sorry if I'm missing something

Offline

#5 2011-11-29 17:38:05

walkerca
Member
Company: Bekwam, Inc.
Registered: 2011-01-12
Posts: 253
Website

Re: [resolved] How to use tXMLMap or DB component to catch up a lookup failure

I haven't used tRESTRequest and tRESTResponse, but here's a screenshot of a job that filters after a left outer join in the tMap.


Uploaded Images


Visit bekwam.blogspot.com for Talend topics and tutorials.  Twitter @bekwaminc for updates.

Offline

#6 2011-12-07 13:59:57

sberyozkin
Talend team
Registered: 2011-02-17
Posts: 50

Re: [resolved] How to use tXMLMap or DB component to catch up a lookup failure

Thanks a mill, adding an extra tMAP made it work, see the attached image.


Uploaded Images

Offline

  • Index
  •  » Talend Open Studio for Data Integration » Usage, Operation
  •  » [resolved] How to use tXMLMap or DB component to catch up a lookup failure

Board footer

Powered by FluxBB