WSO2 EI Reliable Messaging Part 2

Jenananthan
3 min readFeb 8, 2019

--

In the previous post we discussed about an integration scenario and its implementation approach. Now it is time to discuss about the implementation using ESB and Broker profile of EI. This post will discuss about Inbound adapter implementation and complete source code is available in this git repository

Implementation of Inbound Adapter

Inbound Adapter covers the implementation of consuming message from source system’s queue and to publish in to a topic. From this topic outbound adapters will consume the messages.

  • Create JMS inbound endpoint to consume the messages from queue

Since guaranteed delivery must be achieved, if there is an issue while delivering the message,then message should be preserved somewhere and redelivered to the target. For this purpose, need to enable the local jms transaction and should rollback the transaction in any case of failure.

To enable the transaction in inbound endpoint set below parameter to true

Now need to change the acknowledgement type to CLIENT_ACKNOWLEDGE in inbound , which will help to roll back the transaction in any case of failure by setting the property SET_ROLLBACK_ONLY in mediation

  • Create entry sequence to publish the consumed messages to the topic

This sequence is attached to above inbound endpoint. Messages picked from the inbound endpoint will be mediated to this sequence. From here message can be published to topic as shown in below config.

When calling any external endpoint(in our case jms),we must use the call mediator with blocking option true to rollback the transaction in any case of error. if blocking is set to false, ESB will acknowledge the broker before response received or endpoint related error occurs and broker will remove the message based on the acknowledgement received.

  • Create error sequence to rollback the transaction

This error sequence is attached to all the sequences and inbound endpoint. if there is any error in any sequences , message will be dispatched to attached error sequence where error handling will be done.

In the current Inbound Adapter implementation if connection is lost with broker while publishing a message, then that transaction should be roll-backed. When there is a connection issue and error will be thrown and mediation flow will be dispatched to error sequences attached to it. Therefore setting the SET_ROLLBACK_ONLY in error sequence will roll back the transaction.

Outbound Implementation details are discussed in following post

Remark : If rollback is implemented correctly, then in case of failure Message broker will send the failed message to Dead Letter Channel after certain retries. After fixing the problem message can be restore to the queue from Dead Letter Channel manually for mediation.

References

[1] http://lalajisureshika.blogspot.com/2013/06/how-to-block-sending-message-to.html

[2]https://docs.wso2.com/display/EI630/Working+with+Transactions#WorkingwithTransactions-JMSconsumertransactions

--

--