Skip to Content
Technical Articles
Author's profile photo Bhalchandra Wadekar

EIPinCPI – Durable Subscriber

Previous – Selective Consumer | Index | Next – Idempotent Receiver

This week, we’ll study a pattern known as the Durable Subscriber.

When do I use this pattern?

Durable Subscriber is used when messages have to be consumed even if the subscriber loses connection for a while. For example, an invoice sent from a System A to System B needs to be sent in any case otherwise the finances will not balance in System B.

For the demonstration, I’ll create the invoices using the Content Modifier. These Invoices need to be sent to Collection Center where money will be collected against these invoices. If invoices don’t reach Collection Center, the company won’t be able to collect the money. Same Invoices need to be sent to Financial Reporting system as well. Again, if the Financial Reporting system does not get a copy of the invoice, the reports will be wrong. Both of these systems need to be Durable Subscribers.

Durable Subscriber in CPI

I’ll use Enterprise Messaging of Cloud Platform Integration Suite to demonstrate the Durable Subscriber pattern.

I followed Jonathan‘s blog on the Publish-Subscribe pattern to create the integration flows in this blog.

Integration Flow – Publish Invoices

Publish%20Invoices

Publish Invoices

This simple flow starts immediately using Timer Start Event, sets the Invoice body using a Content Modifier and publishes the Invoice using HTTP Receiver Adapter.

For the configuration of HTTP Receiver Adapter, follow step 10 part 3 in Jonathan‘s blog on the Publish-Subscribe pattern.

The Topic Name will be ‘Invoices’.

Integration Flow – Collection Center

Collection%20Center

Collection Center

This integration flow is step 13 from Jonathan‘s blog on the Publish-Subscribe pattern. The difference is that we are logging the payload instead of sending it to SFTP. Also, the Queue Name will be ‘CollectionCenter’.

Integration Flow – Financial Reporting

Collection%20Center

Financial Reporting

Similarly, this integration flow is step 13 from Jonathan‘s blog on the Publish-Subscribe pattern. The difference is that we are logging the payload instead of sending it to SFTP. Here, the Queue Name will be ‘FinancialReporting’.

Output

To demonstrate the Durable Subscriber pattern, we’ll deploy Publish Invoices integration flow. We can see 1 message in each queue.

Published%20Invoices

Published Invoices

Now, we’ll deploy the Collection Center integration flow. The number of messages in CollectionCenter queue reduces to 0.

Collection%20Center%20Subscribes

Collection Center Subscribes

At this time, the financial reporting system is down. The Enterprise Messaging will keep the message in Financial Reporting queue until the message expires.

Once the financial reporting system comes back up, we can see that it consumes the message.

Financial%20Reporting%20Subscribes

Financial Reporting Subscribes

EIPinCPI Rating – 10/10

Enterprise Messaging supports durable subscribers out of the box. Therefore, this pattern gets 10/10 EIPinCPI rating.

Conclusion

Durable Subscriber is used when the subscriber must get the messages even if it loses connection for a while. In Cloud Platform Integration Suite, we can implement a Durable Subscriber using Enterprise Messaging.

References/Further Readings

Hope this helps,
Bala

Previous – Selective Consumer | Index | Next – Idempotent Receiver

Assigned Tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.