WSO2 EI Reliable Messaging Part 3

Jenananthan
3 min readFeb 8, 2019

--

In part 2 we implemented the inbound adapter which can consume messages from source queue and publish to a topic. Outbound adapters will subscribe to this topic and consume the messages published and send to relevant target systems. In this post we will implement one outbound adapter which post the messages to rest API of the target system. Complete source code of inbound adapter and both outbound adapters available in this git repository

Implementation of Outbound Adapter

  • Create JMS inbound endpoint to consume the messages from topic

Similar to Inbound adapter , need to enable jms transaction to rollback in case of failures by setting following parameters.

When a message is published to a topic it will be broadcast to all the subscribers of the topic. If a subscriber is not available at that time then that particular message will be lost for the unavailable subscriber. To provide the guaranteed delivery, even when subscriber not available message should be persisted and redelivered to the subscriber when it becomes available.

For that need to do a durable subscription from client side to broker. In our case from Inbound endpoint. Set SubscriptionDurable to true and give unique values(There can be multiple subscribers to topic) for DurableSubscriberClientID and DurableSubscriber name to make a durable subscription

  • Create entry sequence and attach to inbound endpoint

Messages received from the topic will be mediated to the sequence attached to inbound endpoint. In our scenario, need to make a rest API call with the message received from topic. API call should be made with call mediator blocking true option to rollback the transaction. If there are any endpoint related failures , error will be dispatched to error sequence and from there roll back property will set to true. In some occasions We may need to roll back the transaction based on the response received from API. e.g if status code is not in range of 200–299. By checking the response HTTP code we can decide whether to roll back or not. In our sample scenario transaction will be roll-backed if API code is not in range of 200–299.

  • Attach the error sequence for error handling

As already discussed in part 2 , error sequence is used to handle errors and rollback the transaction.

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 Topic from Dead Letter Channel manually for mediation.

References

[1]https://docs.wso2.com/display/EI640/Creating+Durable+Topic+Subscriptions

--

--