Point-to-Point Channel
In this pattern, a Point-to-Point Channel ensures that only one receiver will be consuming any specific message generated by a Sender. If a channel has multiple receivers connected to it, then only one of them can successfully consume a specific message.
However, if there happen to be multiple receivers that try to consume an individual message, then the channel will ensure that only one of them will be successful. With this level of guarantee, none of the receivers have to coordinate their actions with each other.
The channel can still have multiple receivers to consume multiple messages concurrently, while the channel enforces the rule that only a single receiver consumes any one message.
Â
Point-to-Point using XML DSL:
Demonstration of point-to-point message with JMS components.
<routes>
<route>
<from uri="direct:begin"/>
<to uri="jms:queue:hello"/>
</route>
<route>
<from uri="jms:queue:hello"/>
<to uri="bean:hello"/>
</route>
</routes>
Â
Components that Support Point-to-Point Channel
The following Apache Camel components support the point-to-point channel pattern:
JMS
ActiveMQ
SEDA
JPA
XMPP
JMS Point-to-Point
In JMS, a point-to-point channel is represented by a queue. For example, you can specify the endpoint URI for a JMS queue called Foo.Bar
as follows:
jms:queue:Foo.Bar
NOTE: The qualifier of the queue, is optional because the JMS component creates a queue endpoint by default.
SEDA
This is the Apache Camel Staged Event-Driven Architecture (SEDA) component, and it is implemented using a blocking queue. We will use the SEDA component when you want to create a lightweight point-to-point channel that is internal to the Apache Camel application. For example, you can specify an endpoint URI for a SEDA queue called mySedaQueue
as follows:
seda:mySedaQueue
ActiveMQ
In ActiveMQ, a point-to-point channel is represented by a queue. For example, you can specify the endpoint URI for an ActiveMQ queue called Foo.Bar
as follows: