Accessing event payload in TIBCO BusinessEvents rule body and external Java function.

Accessing event payload in TIBCO BusinessEvents rule body and external Java function.

book

Article ID: KB0091021

calendar_today

Updated On:

Products Versions
TIBCO BusinessEvents Enterprise Edition -
Not Applicable -

Description

Resolution:
Description:
===========
Accessing event payload in TIBCO BusinessEvents rule body and external Java function   .

Environment:
===========
All Operating Systems
TIBCO BusinessEvents 4.x,5.x


Resolution:
===========
The attached example (FraudDetectionTestPayload) is to test event payload in rule functions and passing the payload as a string in an external Java function. The custom jar file attached is TestPayload.jar , TIBCO BusinessEvents (BE) project is FraudDetection . Refer to the section entitled "Working with External Library and Custom Function Paths" in the TIBCO BusinessEvents developers guide on guidelines to create an external library with custom functions .

Steps to Reproduce :

1). Add the custom jar file in the customs jar tab in build path .

2). Since the attached project is created in TIBCO BusinessEvents 5.0.1, use TIBCO BusinessEvents 5.x studio or studio-tools to create the ear file for simplicity.

3). Send an event to TestPayload jms destination with any XML string in the event payload .
        
Example XML String :
    &ltnote> &ltto&gtTo</to> &ltfrom&gtArjun</from> &ltheading&gtReminder</heading> &ltbody&gtDon't forget me this weekend!</body></note>

4). It will return from the custom function with "Watch My test" prepended as well as appended . The custom Java function takes the event payload string as input and prepends as well as appends "Watch My test" to it before returning it to the rule   .

In CreateAccount.rule  note the following lines of code and the notes beside the lines.

String xmlPayload = request@payload;  // Access payload from event
System.debugOut("#### Start to execute custom function " + xmlPayload);
String output = test.testPayload(xmlPayload); // This is where the call to external java function occurs
System.debugOut("#### After execution of custom function " + output);

Issue/Introduction

Accessing event payload in TIBCO BusinessEvents rule body and external Java function.

Attachments

Accessing event payload in TIBCO BusinessEvents rule body and external Java function. get_app
Accessing event payload in TIBCO BusinessEvents rule body and external Java function. get_app