## Return Address

Camel supports the
http://www.enterpriseintegrationpatterns.com/ReturnAddress.html[Return
Address] from the link:enterprise-integration-patterns.html[EIP
patterns] by using the `JMSReplyTo` header.

image:http://www.enterpriseintegrationpatterns.com/img/ReturnAddressSolution.gif[image]

For example when using link:jms.html[JMS] with InOut the component will
by default return to the address given in `JMSReplyTo`.

*Requestor Code*

[source,java]
-------------------------------------------------------------------------------
getMockEndpoint("mock:bar").expectedBodiesReceived("Bye World");
template.sendBodyAndHeader("direct:start", "World", "JMSReplyTo", "queue:bar");
-------------------------------------------------------------------------------

*Route Using the link:fluent-builders.html[Fluent Builders]*

[source,java]
----------------------------------------------------------------------
from("direct:start").to("activemq:queue:foo?preserveMessageQos=true");
from("activemq:queue:foo").transform(body().prepend("Bye "));
from("activemq:queue:bar?disableReplyTo=true").to("mock:bar");
----------------------------------------------------------------------

*Route Using the link:spring-xml-extensions.html[Spring XML Extensions]*

[source,java]
--------------------------------------------------------
<route>
  <from uri="direct:start"/>
  <to uri="activemq:queue:foo?preserveMessageQos=true"/>
</route>

<route>
  <from uri="activemq:queue:foo"/>
  <transform>
      <simple>Bye ${in.body}</simple>
  </transform>
</route>

<route>
  <from uri="activemq:queue:bar?disableReplyTo=true"/>
  <to uri="mock:bar"/>
</route>
--------------------------------------------------------

For a complete example of this pattern, see this
http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsInOnlyWithReplyToAsHeaderTest.java?view=markup[junit
test case]

[[ReturnAddress-UsingThisPattern]]

### Using This Pattern

If you would like to use this EIP Pattern then please read the
link:getting-started.html[Getting Started], you may also find the
link:architecture.html[Architecture] useful particularly the description
of link:endpoint.html[Endpoint] and link:uris.html[URIs]. Then you could
try out some of the link:examples.html[Examples] first before trying
this pattern out.
