Talend Connect
Virtual Summit
JOIN US!
And visit the Customer
& Community Lounge.
May 27-28, wherever you are.

incorrect flow happening from tRestRequest

Highlighted
Eight Stars

incorrect flow happening from tRestRequest

I have a webservice which is going to create a user (using POST) and then, send user details back when GET request is used.

Something like this:




When I am disable either one, it gives the correct output. However, when I have both active, both the routes activate.

What am I doing wrong?




As you can see in the screenshot above, d(main order 5) is for "GET" and c(main order 4) is for POST

I did a "GET" request and both the scenarios got triggered, and a "new" user creation was triggered. At same time, the user check was done, but, it was unable to send data back as POST had already executed and sent a response back to the client (user creation success).

What do I need to do here to get it working? Please advise.
Highlighted
Ten Stars

Re: incorrect flow happening from tRestRequest

Can you change the the URI patterns? I have to admit I have never tried having such similar patterns, but I suspect the fact that you are using "/users" and "/users/{id}" is the cause of this. If you change them to "/createuser" and "/getuser/{id}" I suspect this problem will go.
Highlighted
Eight Stars

Re: incorrect flow happening from tRestRequest

rhall_2.0 wrote:
Can you change the the URI patterns? I have to admit I have never tried having such similar patterns, but I suspect the fact that you are using "/users" and "/users/{id}" is the cause of this. If you change them to "/createuser" and "/getuser/{id}" I suspect this problem will go.

Thanks. I tried this too.

But, still, it is not helping me here. I am not sure what is causing it to go crazy. Any way to debug what is going on wrong here?
Highlighted
Ten Stars

Re: incorrect flow happening from tRestRequest

I know what it is. I just had another look at your job/service design. This is caused by the OnComponentOK links. After those, you have DB queries. These are being fired because even though there is no data going to the component before, it is finishing "OK". Therefore the query component is firing. Replace the OnComponentOK links with IF links, using something that will only fire if that route is OK to use.

It is a bit of a pain, but I remember when I worked for Talend the expectation was that services wouldn't use subjobs like this. Using them is not a massive issue, but you have to work around them. 
Highlighted
Eight Stars

Re: incorrect flow happening from tRestRequest

rhall_2.0 wrote:
I know what it is. I just had another look at your job/service design. This is caused by the OnComponentOK links. After those, you have DB queries. These are being fired because even though there is no data going to the component before, it is finishing "OK". Therefore the query component is firing. Replace the OnComponentOK links with IF links, using something that will only fire if that route is OK to use.

It is a bit of a pain, but I remember when I worked for Talend the expectation was that services wouldn't use subjobs like this. Using them is not a massive issue, but you have to work around them. 

I had a hunch that would be a problem (on component OK), but, you confirmed it.

Well, it took me some time to figure out what type of conditions to add, but, that seems to work for now. I have been able to get it working with the same URL:

/users/ (POST) && /users/{id}/ (GET)

Fingers crossed, hopefully this setup workaround may work...

Thanks a bunch for your insights.
Highlighted
Employee

Re: incorrect flow happening from tRestRequest

Yes, /users/ & /users/{id} would never clash, it is a fundamental part of a JAX-RS selection algorithm

2019 GARTNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

An API-First Approach to Modernizing Applications

Learn how to use an API-First Approach to Modernize your Applications

Watch Now

Talend API Designer – Technical Overview

Take a look at this technical overview video of Talend API Designer

Watch Now

Getting Started with APIs

Find out how to get started with APIs

Read