...
Request only is when the caller sends a message but do not expect any reply. This is also sometimes known as fire and forget or event message.
The Request Reply is then when the caller sends a message and then waits for a reply. This is like the Http protocol that we use every day when we surf the web.
We send a request to fetch a web page and wait until the reply message comes with the web content.
In Camel a message is labeled with a Message Exchange Pattern that labels whether its a request only or request reply message. Camel uses the JBI term for this an uses InOnly
for the request only, and InOut
for the request reply.
For both the request only and the request reply the routing in Camel can happen all message exchange they can be executed either:
- synchronous
- asynchronous
Synchronous Request Reply
A sync synchronous exchange is defined as the caller thread and the remaining routing and processing of the message is happening in the same thread and as sync the caller waits until this thread has done its work before the invocation can return to the caller and continue its worksends a message and waits until its complete before continuing. This is illustrated in the diagram below:
...
On the other hand the asynchronous version is where the caller thread initiates the request and leave the further processing of the message sends a message to an Endpoint and then returns immediately back to the caller. The message however is processed in another thread, the asynchronous thread, and then immediately returns to the caller. Then the caller can continue doing other work and at the same time the asynchronous thread is processing the message. If we are using [Request Reply then at a later point in time the original caller can get hold of the response from the asynchronous thread. If we are using request only then there are no response but the caller can still get a kind of response as it can get information whether the asynchronous thread is done or failed due to an exception. This is illustrated in the diagram below:
...