To

Options

The To EIP supports 2 options which are listed below:

Name Description Default Type

uri

Required Sets the uri of the endpoint to send to.

String

pattern

Sets the optional ExchangePattern used to invoke this endpoint

ExchangePattern

Samples

The following example route demonstrates the use of a file consumer endpoint and a JMS producer endpoint.

from("file://local/router/messages/foo")
    .to("jms:queue:foo");

And in XML:

<route>
    <from uri="file://local/router/messages/foo"/>
    <to uri="jms:queue:foo"/>
</route>

to-eip with pattern

Instead of using inOnly and inOut you may want to keep using to where you can specify the exchange pattern as shown:

from("direct:startInOnly")
  .to(ExchangePattern.InOnly, "bean:process");

from("direct:startInOut")
  .to(ExchangePattern.InOut, "bean:process");

And here is how to do it in XML:

<route>
  <from uri="direct:startInOnly"/>
  <inOnly uri="bean:process"/>
</route>

<route>
  <from uri="direct:startInOut"/>
  <inOut uri="bean:process"/>
</route>

And here we use <to> with the pattern attribute to set the exchange pattern:

<route>
  <from uri="direct:startInOnly"/>
  <to pattern="InOnly" uri="bean:process"/>
</route>

<route>
  <from uri="direct:startInOut"/>
  <to pattern="InOut" uri="bean:process"/>
</route>