Publish Subscriber design in JBoss ESB with guaranteed delivery

390 views Asked by At

I'm having trouble designing a publish/subscribe service which will run on JBoss ESB. I need to be able to publish a message to a topic, which probably 200 subscribers will be listening to, and they will do something with the message once they get it. I'm writing the publish service and a sample subscriber service to showcase how it might be done.

I need to have guaranteed delivery to these subscribers. If they go offline for a period of time, and messages get published within that time, when they come back online, those messages need to be delivered. So I think that means they need to be durable subscribers (my understanding is the Topic is not durable, but the subscribers are defined as durable).

I have a publish service right now which sticks an ESB message on an ESB Aware Queue, which calls a NotifyTopic, which sticks the message on an ESB-Unaware Topic. I have a Subscriber which has a listener for the ESB-Unaware topic, and this calls a webservice using an httprouter which sends the message off to be processed by my webservice. That all works - except when my webservice is offline (I have to figure out how to handle that scenario, but I'm not even there yet), or if my ESB Subscriber Service is offline (which I test by uninstalling it, sending a few publish messages, and reinstall it - no backlog of messages get sent to my webservice).

I'm pretty sure I'm not building the subscriber correctly. I thought I needed the subscriber to be deployed on the ESB. I'm not sure how it would work otherwise, how it would be deployed on a different server and then still be connected to the ESB (trying to avoid having to mess with mutual ssl, firewalls, ports, etc). I figured having the subscriber installed on the ESB would be the best option. But I don't know how to get it to be durable/have guaranteed delivery.

1

There are 1 answers

2
Beryllium On BEST ANSWER

A quote from Creating Robust JMS Applications

5.2.1 Creating Durable Subscriptions

To make sure that a pub/sub application receives all published messages, use PERSISTENT delivery mode for the publishers. In addition, use durable subscriptions for the subscribers.

The TopicSession.createSubscriber method creates a nondurable subscriber. A nondurable subscriber can receive only messages that are published while it is active.

At the cost of higher overhead, you can use the TopicSession.createDurableSubscriber method to create a durable subscriber. A durable subscription can have only one active subscriber at a time.

[...]

You establish the unique identity of a durable subscriber by setting the following:

  • A client ID for the connection
  • A topic and a subscription name for the subscriber

I have run some tests using JBoss 7

  • I have set a client ID on the connection factory level
  • Using a different subscription name for each of the three subscribers:
topicSession.createDurableSubscriber(topic, subscriptionName);

and the JMS server buffers the messages for each disconnected subscriber properly.