How to create a Route using a data service - 6.2

Talend Real-time Big Data Platform Studio User Guide

English (United States)
Talend Real-Time Big Data Platform
Talend Studio
Data Quality and Preparation
Design and Development

This section provides a scenario to illustrate how to create a Route using the data service we created in the previous section.

Discovering the scenario

In this scenario, we will define a Route using the Web service we just created, send a request to this Web service and retrieve the response from the Web service for a further use.

Starting the Apache ActiveMQ server

To send data to request the Web service, we use Apache ActiveMQ as the message broker. We need to launch the ActiveMQ server before executing the Route. For more information about installing and launching ActiveMQ server, see the Talend Installation Guide and the Apache Web site

Creating the Route

To create the Route, we need a cJMSConnectionFactory component to specify the connection factory for message handling, two cJMS components, one to read a JMS message from one queue and send the request to the Web service and the other to retrieve the response from the Web service and save it in another queue, and a cCXF component to connect to the Web service.

To create the Route, proceed as follows:

  1. On the Repository tree view, right-click the Route node and from the contextual menu, select Create Route.

  2. In the pop-up wizard, enter the information corresponding to the fields you need to complete. In this scenario, enter airportRoute in the Name field and click Finish. The Route is opened in the design workspace.

Dropping and linking the components
  1. From the Palette, drop a cMQConnectionFactory, a cCXF, a cProcessor, and two cJMS components on to the design workspace.

  2. Label the components for better identification of their roles and link them using the Row>Route connection as shown below.

Configuring the components
  1. Double-click the cMQConnectionFactory component to display its Basic settings view in the Component tab.

  2. From the MQ Server list, select ActiveMQ.

    In the Broker URI field, type in the URI of the local ActiveMQ server, "tcp://localhost:61616" in this use case.

  3. Double-click the cJMS component labeled Input to display its Basic settings view.

  4. From the Type list, select queue to send the messages to a JMS queue.

    In the Destination field, type in a name for the JMS queue, "IN" in this use case.

    Double-click the [...] button next to ConnectionFactory. Select the JMS connection factory that you have just configured in the dialog box and click OK. You can also enter the name of the cMQConnectionFactory component directly in the field.

  5. Repeat this operation to configure the cJMS component labeled Output with the same ConnectionFactory and name the destination JMS queue OUT.

  6. Double-click the cCXF component to display its Basic settings view.

  7. In the Address field, type in the service endpoint URL of the Web service that we have created, http://localhost:8200/airport.service in this example.

    From the Type list, select wsdlURL.

    In the WSDL File field, type in the path to the WSDL file, http://localhost:8200/airport.service?wsdl in this example.

    From the Dataformat list, select PAYLOAD.

  8. Double-click the cProcessor component to display its Basic settings view.

  9. In the Code area, customize the code as shown below to display the message body on the Run console.

    System.out.println("The output message is: "+

Executing the Route
  1. Click the Run view to display it and click the Run button to launch the execution of the Route. You can also press F6 to execute it.

    RESULT: The Route is successfully started.

  2. Switch to the ActiveMQ Web console. The incoming queue is already created.

  3. Enter the message body as shown below in the incoming queue and send the message.

  4. In the Route designer, we can see that the message payload is sent to the Web service. The Web service get called and the response is sent to another queue, OUT as we have configured.