PollEnrich Options - 6.3

Talend ESB Mediation Developer Guide

EnrichVersion
6.3
EnrichProdName
Talend Data Fabric
Talend Data Services Platform
Talend ESB
Talend MDM Platform
Talend Open Studio for ESB
Talend Real-Time Big Data Platform
task
Design and Development
EnrichPlatform
Talend ESB

Name

Default Value

Description

uri 

The endpoint uri for the external service to enrich from. You must use either uri or ref.

ref 

Refers to the endpoint for the external service to enrich from. You must use either uri or ref.

strategyRef 

Refers to an AggregationStrategy to be used to merge the reply from the external service, into a single outgoing message. By default Camel will use the reply from the external service as outgoing message. From Camel 2.12 onwards you can also use a POJO as the AggregationStrategy, see the Aggregate page for more details.

strategyMethodName 

Camel 2.12: This option can be used to explicit declare the method name to use, when using POJOs as the AggregationStrategy. See the Aggregate page for more details.

strategyMethodAllowNullfalse

Camel 2.12: If this option is false then the aggregate method is not used if there was no data to enrich. If this option is true then null values is used as the oldExchange (when no data to enrich), when using POJOs as the AggregationStrategy. See the Aggregate page for more details.

timeout-1

Timeout in millis when polling from the external service. See below for important details about the timeout.

Warning

By default Camel will use the receive. Which may block until there is a message available. It is therefore recommended to always provide a timeout value, to make this clear that we may wait for a message, until the timeout is hit.

If there is no data then the newExchange in the aggregation strategy is null.

You can pass in a timeout value that determines which method to use:

  • if timeout is -1 or other negative number then receive is selected (Important: the receive method may block if there is no message)

  • if timeout is 0 then receiveNoWait is selected

  • otherwise receive(timeout) is selected

The timeout values is in millis.

Warning

pollEnrich does not access any data from the current Exchange which means when polling it cannot use any of the existing headers you may have set on the Exchange. For example you cannot set a filename in the Exchange.FILE_NAME header and use pollEnrich to consume only that file. For that you must set the filename in the endpoint URI.

In this example we enrich the message by loading the content from the file named inbox/data.txt.

from("direct:start")
   .pollEnrich("file:inbox?fileName=data.txt")
   .to("direct:result");

And in XML DSL you do:

<route>
   <from uri="direct:start"/>
   <pollEnrich uri="file:inbox?fileName=data.txt"/>
   <to uri="direct:result"/>
</route>

If there is no file then the message is empty. We can use a timeout to either wait (potentially forever) until a file exists, or use a timeout to wait a certain period. For example to wait up to 5 seconds you can do:

<route>
   <from uri="direct:start"/>
   <pollEnrich uri="file:inbox?fileName=data.txt" timeout="5000"/>
   <to uri="direct:result"/>
</route>