Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
bhalchandraswcg
Contributor
0 Kudos

Previous – Point-to-Point Channel | Index | Next – Datatype Channel


This week, we'll study a pattern known as Publish-Subscribe Channel.

When do I use this pattern?


A Publish-Subscribe Channel is used when the sender wants to send messages to multiple receivers. For example, invoice data can be sent to a collection centre and a reporting software. In this blog, I'll reuse the example from Durable Subscriber blog.

Publish-Subscribe Channel in CPI


Integration Flow – Publish Invoices



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.fung‘s blog on the Publish-Subscribe pattern.

The Topic Name will be ‘Invoices’.

This integration flow publishes the invoice data on 'Invoices' topic.

Integration Flow – Collection Center



Collection Center


This integration flow is step 13 from jonathan.fung‘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



Financial Reporting


Similarly, this integration flow is step 13 from jonathan.fung‘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’.

Integration Flows Collection Center and Financial Reporting subscribe to get the messages from Invoices topic.

Output


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


Published Invoices


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


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 Reporting Subscribes


As you can see, a Publish-Subscribe channel ensures that each subscriber gets the message once.

While this pattern allows adding the subscribers on the fly, a new subscriber may not get the messages that are already published, it will only get newly published messages.

EIPinCPI Rating - 10/10


Enterprise Messaging supports publish-subscribe channels out of the box. Therefore, this pattern gets 10/10 EIPinCPI rating.

Conclusion


Publish-Subscribe channel is used when a sender wants to send messages to multiple receivers.

References/Further Readings



Hope this helps,
Bala

Previous – Point-to-Point Channel | Index | Next – Datatype Channel

Labels in this area