X

The Integration blog covers the latest in product updates, best practices, customer stories, and more.

Integration Patterns - Publish/Subscribe (Part1)

Daniel Martins Teixeira
Tech Solution Engineer

Broadcasting, Publish/Subscribe, Distributed Messaging, One-to-many, these are just some of the names referring to the same integration pattern, which is one of the most powerful available for connecting multiple systems.

In a nutshell, this pattern is about:

  • Source System publishes a message
  • Target Systems subscribe to receiving that message

This enables the propagation of that message into all the target systems that subscribe to it, as illustrated in the below picture.

Related image

https://docs.oracle.com/cd/E19509-01/820-5892/ref_jms/index.html

 

This pattern is not new, in fact, it’s been around for decades. It powered distributed systems with its inherent loose coupling and independence.  Publishers and subscribers are loosely coupled which allows for the systems to run independently of each other. In the traditional client-server architecture, a client cannot send a message to a server that is offline. In the Pub/Sub model, message delivered is not conditioned by the server availability.

Topics VS Queues

The difference between a Topic and a Queue is that all subscribers to a Topic receive the same message when the message is published and only one subscriber to a Queue receives a message when the message is sent. This pattern is about Topics.

The Hard way

From a vendor neutral point of view, if an Organization needs a messaging infrastructure, it will typically need to setup hardware, install the OS and the messaging software, take care of configurations, creating and managing user, groups, roles, queues and topics…and this is only for the Development environment. Then we have Test and Production, which may require an HA cluster…you can see the direction this is going, it adds complexity.

The Easy way

Fortunately, OIC abstracts that complexity from the user. It’s Oracle managed, the Topics are created and managed by Oracle. From an integration developer point of view – the only requirement is to make use of the “ICS Messaging Service Adapter” – as we will explain in a bit.

This brings the benefits of messaging to those that did not require the full extent of capabilities that a messaging infrastructure provides and were typically put away due to its complexity.

Use Cases

 There are plenty of uses cases that would benefit from this solution pattern:

  • User changes address data in the HCM application
  • New contact/account created in the Sales or Marketing applications
  • ERP Purchase Orders need to be shared downstream

Oracle’s OIC Adapters support many of the SaaS Business Events. How to enable that has been described in another blog entry:  https://blogs.oracle.com/imc/subscribe-to-business-events-in- fusion-based-saas-applications-from-oracle-integration-cloud-oic-part-2     

 

Implement in 4 Steps

For this use case, we will just use a REST request as the Publisher.

 

1. Create a REST trigger

Go to Connections and create a new one. Select the REST Adapter.

https://cdn.app.compendium.com/uploads/user/e7c690e8-6ff9-102a-ac6d-e4aebca50425/d2ad7c45-a081-491e-bc77-30ed620416a6/File/699a41f8413eebaedf43d5d38094d301/699a41f8413eebaedf43d5d38094d301.png

Provide a Name and a Description. The role should be Trigger. Press Create.

https://cdn.app.compendium.com/uploads/user/e7c690e8-6ff9-102a-ac6d-e4aebca50425/d2ad7c45-a081-491e-bc77-30ed620416a6/File/2170261f65e948cc937d053fbe9edf67/2170261f65e948cc937d053fbe9edf67.png

Then you can save and close.

 

2. Create an Integration.

We will select the Type Publish To OIC, which provides the required structure.

https://cdn.app.compendium.com/uploads/user/e7c690e8-6ff9-102a-ac6d-e4aebca50425/d2ad7c45-a081-491e-bc77-30ed620416a6/File/123417ed03c3b9df5c88d06bee28b3fc/123417ed03c3b9df5c88d06bee28b3fc.png

Provide a name a description and optionally associate this integration with a package.

https://cdn.app.compendium.com/uploads/user/e7c690e8-6ff9-102a-ac6d-e4aebca50425/d2ad7c45-a081-491e-bc77-30ed620416a6/File/4e8d646b32d2c1c3b42d12134f74df49/4e8d646b32d2c1c3b42d12134f74df49.png

Now we can drag the connection we created before, from the pallet on the right side, into the Trigger area on the canvas (left side)

https://cdn.app.compendium.com/uploads/user/e7c690e8-6ff9-102a-ac6d-e4aebca50425/d2ad7c45-a081-491e-bc77-30ed620416a6/File/64f65b4470ad3813ec4c44279495b5e3/64f65b4470ad3813ec4c44279495b5e3.png

The REST wizard pops up. We can add a name and a description.

The endpoint URI is /message – that’s the only parameter we need. We want to send a message; therefore the action is POST.

Select the Checkbox for “Configure a request payload for this request”. Leave everything else as default.

https://cdn.app.compendium.com/uploads/user/e7c690e8-6ff9-102a-ac6d-e4aebca50425/d2ad7c45-a081-491e-bc77-30ed620416a6/File/5d738d479016e98a4e205a36dfc0355d/5d738d479016e98a4e205a36dfc0355d.png

 

https://cdn.app.compendium.com/uploads/user/e7c690e8-6ff9-102a-ac6d-e4aebca50425/d2ad7c45-a081-491e-bc77-30ed620416a6/File/ddb9f54f5000e529f6fc58928ba56a2a/ddb9f54f5000e529f6fc58928ba56a2a.png

The payload format we want is JSON and we can insert inline a sample – as seen in the picture.

https://cdn.app.compendium.com/uploads/user/e7c690e8-6ff9-102a-ac6d-e4aebca50425/d2ad7c45-a081-491e-bc77-30ed620416a6/File/34db6d835a6803f73f242b9e38d05212/34db6d835a6803f73f242b9e38d05212.png

That’s all for the REST adapter configuration!

https://cdn.app.compendium.com/uploads/user/e7c690e8-6ff9-102a-ac6d-e4aebca50425/d2ad7c45-a081-491e-bc77-30ed620416a6/File/69db4960828d3855bb2be1e50d8b02f5/69db4960828d3855bb2be1e50d8b02f5.png

You should also add a tracking identifier. The only available is the message element.

https://cdn.app.compendium.com/uploads/user/e7c690e8-6ff9-102a-ac6d-e4aebca50425/d2ad7c45-a081-491e-bc77-30ed620416a6/File/3a01c2ad2c587dc22f79f5a139823f45/3a01c2ad2c587dc22f79f5a139823f45.png

 

3. Activate the Integration.

We are now ready to activate the Integration. You can choose to enable tracing and payload for debugging. (Your activation window might look a bit different, as this has the API Platform CS integrated for API publishing)

 

https://cdn.app.compendium.com/uploads/user/e7c690e8-6ff9-102a-ac6d-e4aebca50425/d2ad7c45-a081-491e-bc77-30ed620416a6/File/6eb7510ffd6adc6a4082d7435bc81d7f/6eb7510ffd6adc6a4082d7435bc81d7f.png

 

4. Test the Integration.

After activation, you see a green banner on top of your screen with the endpoint metadata. Here you can find the endpoint URL to test the REST trigger we just created.

Using Postman (or any other equivalent product) we can send a REST request containing the message we wish to broadcast.

https://cdn.app.compendium.com/uploads/user/e7c690e8-6ff9-102a-ac6d-e4aebca50425/d2ad7c45-a081-491e-bc77-30ed620416a6/File/b1aa25c658204621591c61b3728b331b/b1aa25c658204621591c61b3728b331b.png

 

And when we check the Tracking Instances under Monitoring…voilà, we see the instance of the Integration we just created.

https://cdn.app.compendium.com/uploads/user/e7c690e8-6ff9-102a-ac6d-e4aebca50425/d2ad7c45-a081-491e-bc77-30ed620416a6/File/2dc6e8cf3d0b988f118408974d6254c5/2dc6e8cf3d0b988f118408974d6254c5.png

And here we have the confirmation that the payload was sent to the Topic!

https://cdn.app.compendium.com/uploads/user/e7c690e8-6ff9-102a-ac6d-e4aebca50425/d2ad7c45-a081-491e-bc77-30ed620416a6/File/7e2bd44b2f425127bd066d100a51b07f/7e2bd44b2f425127bd066d100a51b07f.png

 

In Part 2 of this blog series we will cover the Subscribers!

 

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.