blob: c75a2bb5aa1d7c73ab5d824d31cac2f83a36edf9 [file] [log] [blame]
[[Message-Message]]
Message
^^^^^^^
Camel supports the
http://www.enterpriseintegrationpatterns.com/Message.html[Message] from
the link:enterprise-integration-patterns.html[EIP patterns] using the
http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/Message.html[Message]
interface.
image:http://www.enterpriseintegrationpatterns.com/img/MessageSolution.gif[image]
To support various message link:exchange-pattern.html[exchange patterns]
like one way link:event-message.html[Event Message] and
link:request-reply.html[Request Reply] messages Camel uses an
link:exchange.html[Exchange] interface which has a *pattern* property
which can be set to *InOnly* for an link:event-message.html[Event
Message] which has a single inbound Message, or *InOut* for a
link:request-reply.html[Request Reply] where there is an inbound and
outbound message.
Here is a basic example of sending a Message to a route in *InOnly* and
*InOut* modes
*Requestor Code*
[source,java]
---------------------------------------------------------------------------------------------------------------
//InOnly
getContext().createProducerTemplate().sendBody("direct:startInOnly", "Hello World");
//InOut
String result = (String) getContext().createProducerTemplate().requestBody("direct:startInOut", "Hello World");
---------------------------------------------------------------------------------------------------------------
*Route Using the link:fluent-builders.html[Fluent Builders]*
[source,java]
--------------------------------------------------
from("direct:startInOnly").inOnly("bean:process");
from("direct:startInOut").inOut("bean:process");
--------------------------------------------------
*Route Using the link:spring-xml-extensions.html[Spring XML Extensions]*
[source,java]
----------------------------------
<route>
<from uri="direct:startInOnly"/>
<inOnly uri="bean:process"/>
</route>
<route>
<from uri="direct:startInOut"/>
<inOut uri="bean:process"/>
</route>
----------------------------------
[[Message-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.