Binding Channels

Binding a channel to JMS is similar to binding a reference or service. The main difference is that by default, Topics instead of Queues are used for messaging:

<channel name="TestDurableChannel" requires="f3:durable">
   <binding.jms>
      <destination jndiName="TestDurableChannelTopic"/>
   </binding.jms>
</channel>

Binding a channel is typically done when there is a need to observe events originating from outside the SCA domain or there is a need to send events to an external consumer.

Durable Subscriptions

Durable JMS topic subscriptions can be enabled using the durable intent on a channel:

<channel name="DurableChannel" requires="f3:durable">
   <binding.jms>
      <destination jndiName="DurableChannelTopic"/>
   </binding.jms>
</channel>

Lost Messages

When a channel is bound to a JMS Topic, there is the possibility the events sent to the channel will be dropped and not received by consumers. To understand why this happens it is necessary to describe how consumers are attached to the JMS channel binding. Fabric3 implements a message container that performs a looping blocking receive with a timeout. This is necessary to support transactional dequeue (the receive is performed within a transaction) and also to avoid tying up kernel threads indefinitely. If a timeout occurs, the container will loop and perform another receive. If a message is received, it will be processed and the container will loop and perform a new receive. This creates the possibility of a window where no consumers are connected to the Topic. When this occurs, a JMS provider is free to drop messages. At high message rates, the possibility of dropping messages increases as the message container will frequently be processing messages and not receiving.

To avoid dropped messages, the channel should be configured as durable. This will result in a JMS durable topic subscription being used. However, using durable subscriptions comes at a significant cost both in terms of performance and memory requirements as messages must be held in a topic until they have been delivered to all active subscriptions.