August 15, 2023

cExchangePattern – Docs for ESB 6.x

cExchangePattern

Sets the message exchange mode in a Route.

cExchangePattern Standard properties

These properties are used to configure cExchangePattern running in the Standard Job framework.

The Standard
cExchangePattern component belongs to the Core family.

Basic settings

Exchange Patterns

Select the message exchange mode from InOnly or InOptionalOut, InOut, OutIn,
OutOptionalIn, RobustInOnly, RobustOutOnly.

Usage

Usage rule

As a middle component in a Route, cExchangePattern allows you to set the message
exchange mode.

Limitation

 

Scenario: Enabling the InOut exchange pattern to get replies

This scenario applies only to a Talend solution with ESB.

In this scenario, a cExchangePattern component is
used to enable the request/reply exchange pattern in the Route, so that the client can
get a reply from the server.

use_case_cexchangepattern_1.png

To send requests to the server side, a soapUI is needed and its configuration will be
briefed in the following contents.

To build the Route, do the following.

Dropping and linking the components

  1. From the Palette, drag and
    drop a cSOAP, a cExchangePattern and a cProcessor onto the workspace, and label them WebService_producer, Set_exchange_mode and Build_reply_message respectively to better identify their
    roles in the Route.
  2. Link cSOAP to cExchangePattern using a Row > Route
    connection.
  3. Link cExchangePattern to cProcessor using a Row > Route
    connection.

Configuring the components

  1. Double-click cSOAP to open
    its Basic settings view in the Component tab.

    use_case_cexchangepattern_2.png

  2. In the Address field, leave
    the default setting unchanged.
  3. In the Type list, select
    wsdlURL.
  4. In the WSDL File field,
    enter the URL of the wsdl file. You can also click the three-dot button to
    browse for it.
  5. Click […] next to Service
    Configuration
    to open the service configuration wizard. The
    WSDL field has been filled in with the selected WSDL
    file. Click refresh_button.png to show the available port in the Port
    Name
    box. Select the airportSoap port and click
    Finish to close the wizard. The Service
    Name
    and Port Name fields in the
    Basic settings view are filled in
    automatically.

    use_case_ccxf17.png

  6. In the Dataformat list,
    select PAYLOAD.
  7. Double-click cExchangePattern to open its Basic
    settings
    view in the Component tab.

    use_case_cexchangepattern_3.png

  8. In the Exchange Patterns
    list, select InOut to enable the
    request/reply message exchange mode.
  9. Double-click cProcessor to
    open its Basic settings view in the
    Component tab.

    use_case_cexchangepattern_4.png

  10. In the Code box, enter the
    code below.

    As shown above, a string is built here and is used as a reply
    message of the route. It is in line with the message definition of the above
    wsdl file.
  11. Press Ctrl+S to save your
    Route.

Viewing code and executing the Route

  1. Click the Code tab at the bottom of the
    design workspace to check the generated code.

    use_case_cexchangepattern_5.png

    As shown above, the route has its message exchange pattern set as
    InOut using the method
    .setExchangePattern(org.apache.camel.ExchangePattern.InOut).
    In the meantime, a string is created using StringBuilder sb = new
    StringBuilder()
    at cProcessor_1 and is used as the
    reply message via the method exchange.getOut().setBody(
    sb.toString())
    .
  2. Press F6 to execute the Route.

    The server Route gets started.

Creating and sending a request to the server Route and getting a reply

  1. In the soapUI, create a Test project and edit a request, as illustrated
    below:

    use_case_cexchangepattern_7.png

    Note that the wsdl file must be same as that configured for
    cSOAP, so that the request can be in line
    with the definition of the web service.
  2. Send the request to the server Route and you can get the reply, as
    illustrated below:

    use_case_cexchangepattern_8.png


Document get from Talend https://help.talend.com
Thank you for watching.
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x