August 17, 2023

cExchangePattern – Docs for ESB 5.x

cExchangePattern

cexchangepattern_icon32.png

cExchangePattern properties

Component Family

Processor

Function

cExchangePattern can be configured
to indicate the message exchange mode.

Purpose

cExchangePattern allows you to set
the message exchange mode.

Basic settings

Exchange Patterns

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

Usage

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

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 Processor folder of the Palette, drag and drop a cCXF, 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 cCXF to cExchangePattern using a Row > Route
    connection.

  3. Link cExchangePattern to cProcessor using a Row > Route
    connection.

Configuring the components

  1. Double-click cCXF 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. In the Dataformat list, select PAYLOAD.

  6. Double-click cExchangePattern to open its
    Basic settings view in the Component tab.

    use_case_cexchangepattern_3.png
  7. In the Exchange Patterns list, select
    InOut to enable the request/reply
    message exchange mode.

  8. Double-click cProcessor to open its
    Basic settings view in the Component tab.

    use_case_cexchangepattern_4.png
  9. 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.

  10. 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 cCXF, 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