cIdempotentConsumer
Identifies messages that have already been sent to the receiver and eliminates
them. Messages are still sent by the sender but are ignored by the receiver at the
delivery stage.
cIdempotentConsumer deduplicates
messages and thereby prevents the receiving message endpoint from
receiving duplicate messages.
cIdempotentConsumer Standard properties
These properties are used to configure cIdempotentConsumer running in the Standard Job framework.
The Standard
cIdempotentConsumer component belongs to the Routing family.
Basic settings
Repository Type |
Message identifiers need to be stored in a repository. For new
Memory: messages identifiers are Warning:
The in-memory storage mode can easily run out of
File: messages identifiers are |
File store |
Specify the path and name of the file storing messages |
Cache Size |
Type in the size of the cache, namely the number of message |
Use language |
Select this check box if you want to specify the language used in For more information about how to use the languages to create an expression, see |
Predicate |
Type in the expression to use to specify the identifier of the |
Add Namespaces |
This option appears when XPath is Select this check box to add namespaces for the Xpath expression. |
Eager |
Select this check box to detect duplicate messages even when By default, this check box is selected. |
SkipDuplicate |
Select this check box to drop duplicates; clear it to ignore By default, this check box is selected. |
Usage
Usage rule |
cIdempotentConsumer is used as a |
Connections |
idemp: The idemp link retrieves messages deduplicated by the cIdempotentConsumer component. |
 |
Route: As an optional link, the Route link retrieves all messages from the message sender. |
Limitation |
 n/a |
Deduplicating messages while routing them
This scenario applies only to Talend Open Studio for ESB, Talend Data Services Platform and Talend Data Fabric.
In this scenario, duplicated messages are filtered and only the unique one is routed to the
destination.
Three XML files that have the same content, as shown below, are used in this use
case.
1 2 3 4 5 6 7 |
<people> <person id="8"> <firstName>Ellen</firstName> <lastName>Ripley</lastName> <city>Washington</city> </person> </people> |
Dropping and linking the components
This use case requires one cFile component, one
cIdempotentComsumer component, and two
cProcessor components.
-
From the Palette, expand the Connectivity folder, select the cFile component, and drop it onto the design workspace as
the message source component. -
Expand the Routing folder, select the
cIdempotentComsumer component and drop
it onto the design workspace as the message deduplicator. -
Expand the Custom folder, drop two cProcessor components onto the design workspace, one as the
consumer for deduplicated messages and another for all messages. -
Right-click the cFile component, select
Row > Route from the contextual menu and click the cIdempotentComsumer component. -
Right-click the cIdempotentComsumer
component, select Row > idemp from the contextual menu and click the
cProcessor component on the top. -
Connect the cIdempotentComsumer component
to the other cProcessor component using a
Row > Route connection. This optional connection will retrieve all
the messages coming from the source. - Label the components to better identify their roles in the Route.
Configuring the components and connections
-
Double-click the cFile component, which
is labelled Source, to display its
Basic settings view in the Component tab. -
In the Path field, specify the file path to the message source.
From the Encoding list, select the encoding type of your source files, and leave all the other parameters as they are.
-
Double-click the cIdempotentComsumer
component, which is labelled Deduplicator, to display its Basic
settings view in the Component tab. -
From the Repository Type list, select between Memory and File to specify where the message identifiers will be stored before the deduplication process. For this scenario, select File.
In the File store field, specify the location of the file storing message identifiers.In the Expression field, enter an expression to filter the messages. In this scenario, enter the following expression to filter the messages according to the person node of the XML files:
xpath("/people/person")
, and leave all the other parameters as they are. Alternatively, you can select the Use language check box, select XPath from the Language list, and enter"/people/person"
in the Predicate field. -
Double-click the cProcessor component
labelled Unique to display its Basic settings view in the Component tab. -
In the Code area, customize the code to
display the file name of the message that passes the deduplication:12System.out.println("Message consumed on Unique: "+exchange.getIn().getHeader("CamelFileName")); -
Repeat these steps to configure the other cProcessor component, which is labelled All, to display the file names of all the
messages coming from the source:12System.out.println("Message consumed on All: "+exchange.getIn().getHeader("CamelFileName")); - 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 view the generated code.In this partially shown piece of code, messagesfrom
theSource
are filtered according to the expression
xpath("/people/person")
and deduplicated by
cIdempotentConsumer_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: When several files have the same content, only the first one is
routed to the receiving endpoint.