Publish Subscribe Channel

Camel supports the Publish Subscribe Channel from the EIP patterns.

How can the sender broadcast an event to all interested receivers?

image

Send the event on a Publish-Subscribe Channel, which delivers a copy of a particular event to each receiver.

The Publish-Subscribe Channel is supported in Camel by messaging based Components, such as:

  • AMQP for working with AMQP Queues

  • ActiveMQ, or JMS for working with JMS Queues

  • SEDA for internal Camel seda queue based messaging

  • Spring RabbitMQ for working with AMQP Queues (RabbitMQ)

There are also messaging based in the cloud from cloud providers such as Amazon, Google and Azure.

See also the related Point to Point Channel EIP

Example

The following example demonstrates publish sbuscriber messaging using the JMS component with JMS topics:

from("direct:start")
    .to("jms:topic:cheese");

from("jms:topic:cheese")
    .to("bean:foo");

from("jms:topic:cheese")
    .to("bean:bar");

And in XML:

<routes>
    <route>
        <from uri="direct:start"/>
        <to uri="jms:queue:foo"/>
    </route>
    <route>
        <from uri="jms:queue:foo"/>
        <to uri="bean:foo"/>
    </route>
</routes>