Skip to main content

Development

Talend ESB – tRestRequest and tRestResponse

Korean Mature Woman And Caucasian Young Woman Lead Meeting Of Multiracial Work Colleagues Discussing Ideas And Business Together Sitting At Table In Modern Creative Office Interior High Angle View Daytime

This article covers the configuration of tRestRequest, tRestResponse and How can we create the HTTP listeners using postman.

Create a job in the Talend tool (it can be Talend ESB or Talend Data fabric). Once you have created a job, place tRestRequest, tjavaRow component, and tRestResponse in the designer.

Capture1

Talend Designer –  job created and component placed.

Once you have placed all the components, you can configure the tRestRequest component as mentioned below. For this configuration, you must provide the endpoint URL and Mapping. This URL must match the Postman URL that we need to create it.

Picture2

Talend tRestRequest settings

Capture3

HTTP listener (name and place are query parameters)L

Picture4

HTTP listener (body)

 

As mentioned above postman collection we need to provide the URL(eg: http://localhost:8088/api). Once postman setup done, we need to add the schema. for that just click the output flow(here, details) add the schema as mentioned below. In Schema tab we have to give comment as query for query parameters.

Picture5

Schema – by clicking the 3 dot in Output flow

HTTP Method is mentioned a POST here so we can give HTTP Verb as POST. After configuring the tRestRequest,nn here it is just printing the message. System.out.println(“”) -> Syntax for printing any messages.

Picture6

Configuring tJavaRow

Then, tRestResponse has to be configured by providing the datatype of the message or payload that we are going to get from the tJavaRow Component. So here it is: string. After a Successful run, it will show 200 OK responses in Postman.

Picture7

Configuring tRestResponse

Clicking the run tab starts the job. Parallelly, we must run the HTTP listener from Postman by clicking the send button.

Picture8

Started the job. Now the provided endpoint is started running.

After successful run job is ending with 200 ok status.

Picture9

HTTP listener Response as details received and status as 200Ok

Picture10

The message or payload from listener is displayed here.

How to call more than one API endpoint using rest components

Picture11

It is like creating one API listener. The tRestRequest configuration is given below. There are 2 Output flows mentioned in the REST API Mapping. Here, the URI Pattern must be declared. Those are “/details” and “/projects.” While creating the endpoint, we have to use the whole URL, like “http://localhost:8088/api/details” and “http://localhost:8088/api/projects.” These two are POST methods.

Picture12

Picture13

http://localhost:8088/api/details?name=abc&place=xyz

  • http://localhost:8088/api – is a common API endpoint for both listeners.
  • /details – is URI pattern
  • ?name=abc&place=xyz – is Query params

So this is how we need to create the API endpoint in Postman.

The next part is Java components. I have used those components just for printing the body using print statements. (System.out.println(input_row.body);).

Below “if condition” is used to trigger the respective endpoint flow.

Picture14

Extracting the URI global variable from the tRestRequest pattern and equating it with the specific endpoint name. Based on the URI pattern, the job flow will trigger. Then, a response is sent to the listener via tRestRequest.
This is about creating listener for two endpoint.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Sneha Annadurai

Sneha Annadurai is an associate technical consultant at Perficient. She has experience in Talend ETL Tools such as ESB, Data Mapper, and DI.

More from this Author

Follow Us
TwitterLinkedinFacebookYoutubeInstagram