Details
-
New Feature
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.0-incubating
-
None
Description
ODE Business Process Data capture through Event Listeners: Proposal
(Plaintext of the Proposal)
It is necessary to get Business process data through events to track what's going on with the process using the data flow. It's also useful for Business Activity Monitoring (BAM) solution to get 'What's happening right now?' type of data.
Currently ode fires events and can be captured through Event Listener mechanism. But to get the data, we have to use pmapi (through web services).
So, the proposal is to get the data, in Event listeners with out using the web services. How to consume the events is up to the Event Handlers.
For that, we have to add a BpelEventContext in BpelEvent object, which will carry the event context to the Event Listeners. The BpelEventContext interface carries two public methods.
1.public String[] getVariableNames();
2.public String getVariableData(String varName);
The getVariableNames() returns all variable names available in that event context as an array of String. It will return null, if no variable is available.
The getVariableData(varName) returns the variable data, for the given variable name, if exists and initialized, as a String representation of DOM Node. Otherwise it will be null.
The BpelEventContext implementation BpelEventContextImpl implements these methods. It takes OScope object, scopeInstanceId and BpelRuntimeContext as constructor parameters. Using these values, it's easy to return the variable names and its data.
In BpelEvent a public property is needed to carry the BpelEventContext. For that purpose add the following in the BpelEvent.java
public transient BpelEventContext eventContext;
To populate the context, in ACTIVITY.java, where the ScopeEvent got populated, add the following method.
/**
- Populate BpelEventContext, to be used by Registered Event Listeners
- @param event ScopeEvent
*/
protected void fillEventContext(ScopeEvent event)
{
BpelEventContext eventContext = new BpelEventContextImpl(
_scopeFrame.oscope, _scopeFrame.scopeInstanceId,
getBpelRuntimeContext());
event.eventContext = eventContext;
}
And in protected void sendEvent(ScopeEvent event), call this method to populate the BpelEventContext.
How to consume event data?
Here is a code snippet to consume the event data.
public void onEvent(BpelEvent event)
{
if(event instanceof ActivityExecStartEvent)
{
try
{
String[] __names = ((ActivityEvent)event).eventContext.getVariableNames();
if(__names != null)
{
System.out.println(">>>>>>> Variable Data...");
for(int i = 0; i < __names.length; i++)
{
String varName = __names[i];
System.out.println(">>>>>>> For Variable ..." + varName);
String data = ((ActivityEvent)event).eventContext. getVariableData(
varName);
if(data != null)
else
{ System.out.println(".....DATA Not Available......"); } }
System.out.println(">>>>>>> Variable Data ENDS...");
}
}
catch(Exception e)
}
}