cWireTap
Routes messages to a separate endpoint while forwarded to the ultimate
destination.
cWireTap wiretaps messages to a
user defined URI while they are sent to their original endpoint. It
also allows you to populate a new message to this wiretap URI
concurrently.
cWireTap Standard properties
These properties are used to configure cWireTap running in the Standard Job framework.
The Standard
cWireTap component belongs to the Routing family.
Basic settings
URI |
The endpoint URI to send the wire tapped message. |
Populate new exchange |
Select this check box to populate a new message to the wiretap URI. |
Populate Type |
This option appears when the Populate new |
Expression: Using expression
Language: Select the language of the expression you
Expression TXT: Enter the expression to set the |
|
Processor: Using processor gives you full power to specify how the exchange is populated as you can set properties, headers and so on to the message with a piece of Java code in the Code field. |
|
Copy the original message |
Select this check box to create a copy of the original exchange, which The exchange |
Usage
Usage rule |
cWireTap can be a middle |
Limitation |
n/a |
Scenario: Wiretapping a message in a Route
This scenario applies only to a Talend solution with ESB.
In this scenario, a cWireTap component is used to route a
message to a separate endpoint while it is routed to the ultimate destination.
Dropping and linking the components
-
From the Palette, expand the Connectivity folder, and drop a cFile and two cMessagingEndpoint components onto the design
workspace. -
Expand the Routing folder, and drop a
cWireTap component onto the design
workspace. -
Expand the Core folder, and drop a
cJavaDSLProcessor components onto the
design workspace. -
Expand the Custom folder, and drop and
two cProcessor components onto the design
workspace. -
Right-click the cFile component, select
Row > Route from the contextual menu and click the cWireTap component. - Repeat this operation to connect the components as shown above.
- Label the components to better identify their functionality.
Configuring the components
-
Double-click the cFile component labeled
Source to display its Basic
settings view in the Component tab. -
In the Path field, browse to or enter the
input file path. In this use case, there is a Hello.txt
file in the specified file path, which contains the content Hello
World!. Leave the other parameters as they are. -
Double-click the cWireTap
component to display its Basic settings
view in the Component tab. -
Enter
"direct:a"
in the URI field to route the wiretapped message to this endpoint.Select the Populate new exchange check box, select Processor as the populate type, and then enter the following code in the Code box to display the file name of the wiretapped message and its content on the console:123456System.out.println("Message wiretapped: "+exchange.getIn().getHeader("CamelFileName"));System.out.println("Message content: "+exchange.getIn().getBody(String.class)+""); -
Double-click the cJavaDSLProcessor component to display its Basic settings view in the Component tab.
-
In the Code field, enter the Java code
.to("direct:b")
to define the URI of the endpoint to route
the original message to. -
Double-click the cMessagingEndpoint component labeled Endpoint_a to display its Basic
settings view in the Component
tab. Enter"direct:a"
in the URI field to retrieve the message routed to this
endpoint.Repeat this operation to set the endpoint URI for Endpoint_b. -
Double-click the cProcessor component labeled Monitor_a to display its Basic settings view in the Component tab. Enter the following code in the Code box to display the file name of the message routed to Endpoint_a.
12System.out.println("Message on endpoint a: "+exchange.getIn().getHeader("CamelFileName"));
Then, configure the other cProcessor component in the same way to display the file name of the message routed to Endpoint_b.
- Press Ctrl+S to save your Route.
Viewing code and executing the Route
-
Click the Code tab at the
bottom of the design workspace to have a look at the generated code.In this partially shown code, any messagefrom
the endpointSource
will be wiretapped by.wireTap
and routed to
"direct:a"
. The fine name and content of each
wiretapped message will be displayed on the console. The original message will
be routed.to
an endpoint identified by the URI
"direct:b"
, which is defined incJavaDSLProcessor_1
. -
Click the Run view to display it and click the Run button to launch the execution of your Route.
You can also press F6 to execute it.RESULT: The source message is wiretapped and routed to endpoint a as well as being routed to endpoint b.