How to handle exceptions when executing TIBCO BusinessEvents catalog function Event.routeTo() in Cache and In-Memory only mode?

How to handle exceptions when executing TIBCO BusinessEvents catalog function Event.routeTo() in Cache and In-Memory only mode?

book

Article ID: KB0076106

calendar_today

Updated On:

Products Versions
TIBCO BusinessEvents Enterprise Edition 5.x

Description

The catalog function Event.routeTo() sends a simple event to a destination with custom destination properties. In success scenario , after sending it returns the same value as the input argument Event.

In failure scenario, the behavior is different between Cache and In-Memory only mode.

In-Memory Mode:
This function will return null if there was an error.

Cache Mode:
In case of any error while sending , This function will still return an Event argument
for example :
++
be.gen.Events.TestEve@id=27855
++
and hence it's not possible to catch any route event exceptions in cache only mode.

Cause:
In Cache only mode, all the send/route event activities will happen at the end of RTC (PostRTC).
The PostRTC thread tries to send/route the Events that are created during its RTC phase and any exceptions are captured in the the postRTC only.
 

Issue/Introduction

Behavior of BusinessEvents catalog function Event.routeTo() in Cache and In-Memory only mode and how to handle exceptions.

Environment

BusinessEvents 5.x All Supported Operating system

Resolution

How to handle exceptions with Event.routeTo() in Cache only mode?

Option 1:
To handle the exceptions, one can create a transaction error handler callback rule function that helps identify which post RTC transactions failed or which events were not sent out during the post RTC phase.

Option 2:
Without waiting for POST-RTC phase completion, One can send JMS messages immediately in the RTC itself using Event.Ext.*Immediate catalog function.
This function Event.Ext.*Immediate will send/route message right away in the same RTC and not in PostRTC.

For example :
Event.Ext.routeToImmediate()

This will immediately sends/routs the SimpleEvent evt to the configured default channel and destination for this SimpleEvent and in case of any errors during the routing process, one can handle the exceptions using try-catch block.

sample code :

try {
String evn=      Event.Ext.routeToImmediate(deleteEvent, "/Channels/triggercha/deletdest", "");
System.debugOut("########Routed Event using routeToImmediate ############ "+evn );

}
catch (Exception ex)
{
System.debugOut( "####### Exception happened while routing event " + ex@stackTrace);
}