| [[message-eip]] |
| = Message |
| |
| Camel supports the |
| http://www.enterpriseintegrationpatterns.com/Message.html[Message] from |
| the xref:enterprise-integration-patterns.adoc[EIP patterns] using the |
| http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/Message.html[Message] |
| interface. |
| |
| image::eip/MessageSolution.gif[image] |
| |
| To support various message xref:exchange-pattern.adoc[exchange patterns] |
| like one way xref:event-message.adoc[Event Message] and |
| xref:request-reply.adoc[Request Reply] messages Camel uses an |
| xref:exchange.adoc[Exchange] interface which has a *pattern* property |
| which can be set to *InOnly* for an xref:event-message.adoc[Event |
| Message] which has a single inbound Message, or *InOut* for a |
| xref:request-reply.adoc[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 using a `ProducerTemplate` |
| |
| [source,java] |
| ---- |
| //InOnly |
| getContext().createProducerTemplate().sendBody("direct:startInOnly", "Hello World"); |
| |
| //InOut |
| Object result = getContext().createProducerTemplate().requestBody("direct:startInOut", "Hello World"); |
| ---- |
| |
| And an example with routes: |
| |
| [source,java] |
| ---- |
| from("direct:startInOnly") |
| .inOnly("bean:process"); |
| |
| from("direct:startInOut") |
| .inOut("bean:process"); |
| ---- |
| |
| See xref:to-eip.adoc[to-eip with pattern] |