Monday, August 31, 2015

BPM Suite 12c: Oracle Adaptive Case Management: Monitoring Case Events

Oracle Adaptive Case Management (ACM) is an interesting addition to Oracle BPM Suite which has been introduced in 11.1.1.7. Adaptive Case Management is suitable to model complex work-flows in which there is no set order of activities taking place. This allows more control to the end user on what to do when.

When a case is started, it is a running process in the SOA infrastructure. The main component is Oracle Business Rules which governs (among other things) the availability of activities and when certain process milestones are achieved. The case API allows you to query the case events and milestones (how you can expose the API as a service is described here and here by Roger Goossens).

Sometimes people want to obtain information about cases such as;
  • in how many cases has a certain activity been executed?
  • in which cases has a certain milestone been reached?
Cases can crash, be restarted, migrated, aborted, purged, etc. Sometimes you might not want to depend on the running case being there to provide the information you want. Also using the API every time you want certain information might put a serious strain on your system. Using sensors or BAM might help but they require an investment to implement and are still manual implementations with no guarantee you can obtain information in the future you did not think you would need in the present/past.

Publish Case Events

Luckily Oracle has provided the perfect solution for monitoring case events! You can publish case events to the Event Delivery Network (read here 31.17.2 How to Publish Case Events). This can easily be monitored by for example a BPEL process, which can store the information in a custom table.


You can find the event definition of a case event in the MDS at oramds:/soa/shared/casemgmt/CaseEvent.edl

Publishing case events does not work however when using the (BPM 12.1.3) quickstart installation (with the Derby database). I got the below error:

Caused By: org.apache.derby.client.am.SqlException: 'EDN_INTERNAL_PUBLISH_EVENT' is not recognized as a function or procedure.
    at org.apache.derby.client.am.Statement.completeSqlca(Unknown Source)
    at org.apache.derby.client.net.NetStatementReply.parsePrepareError(Unknown Source)
    at org.apache.derby.client.net.NetStatementReply.parsePRPSQLSTTreply(Unknown Source)
    at org.apache.derby.client.net.NetStatementReply.readPrepare(Unknown Source)
    at org.apache.derby.client.net.StatementReply.readPrepare(Unknown Source)
    at org.apache.derby.client.net.NetStatement.readPrepare_(Unknown Source)
    at org.apache.derby.client.am.Statement.readPrepare(Unknown Source)

The PL/SQL procedure EDN_INTERNAL_PUBLISH_EVENT apparently is used when publishing EDN (Event Delivery Network) events from the Case. Of course the quickstart Derby database doesn't have PL/SQL support.

I quickly (Vagrant/Puppet) created a full blown SOA Suite 12c installation with a serious Oracle database to continue (from the following article by Lucas Jellema using scripts from Edwin Biemond). When enabling debug logging for the Event Delivery Network (see here) I could see the following (this is a sample event).

[SRC_METHOD: fineEventPublished] Received event: Subject: null  Sender: oracle.integration.platform.blocks.event.saq.SAQRemoteBusinessEventConnection   Event:[[
<business-event xmlns:ns="http://xmlns.oracle.com/bpm/case/event" xmlns="http://oracle.com/fabric/businessEvent">
   <name>ns:CaseEvent</name>
   <id>67622616-f339-4478-b033-f773be3eba78</id>
   <tracking>
      <ecid>eac134b8-79de-49bc-9fc7-1b70f9e6ccf8-0003eb63</ecid>
      <conversationId>c9fb038e-7666-47e7-9f70-5e2f19a39d82</conversationId>
   </tracking>
   <content>
      <ce:caseEvent xmlns:ce="http://xmlns.oracle.com/bpm/case/event" eventType="ACTIVITY_EVENT">
   <ce:eventId>e427621f-a35e-4106-ac84-f650d3b92222</ce:eventId>
   <ce:caseId>50ad482f-5024-403e-aea9-3ec56ae623ae</ce:caseId>
   <ce:updatedBy>weblogic</ce:updatedBy>
   <ce:updatedByDisplayName>weblogic</ce:updatedByDisplayName>
   <ce:updatedDate>2015-08-31T11:06:45.811+02:00</ce:updatedDate>
   <ce:activityEvent>
      <ce:activityName>actConfirmUserCreditProcess</ce:activityName>
      <ce:activityType>BPMN</ce:activityType>
      <ce:activityEvent>COMPLETED</ce:activityEvent>
      <ce:startedDate>2015-08-31T11:06:45.316+02:00</ce:startedDate>
      <ce:completedDate>2015-08-31T11:06:45.811+02:00</ce:completedDate>
   </ce:activityEvent>
   <ce:documentEvent>
      <ce:document>
         <ce:documentId>5896af2e-156d-45e9-8329-81010cbe292b</ce:documentId>
      </ce:document>
   </ce:documentEvent>
</ce:caseEvent>
   </content>
</business-event>


Thus the event was published to the EDN... at least I thought it was.

Debugging EDN

In order to retrieve events, I created a small case and logger BPEL process as sample. You can download them here. The logger stores events on the filesystem. You can of course easily expand this to store the information in a database table. The sample logger process also shows how you can Base64 encode the event for the fileadapter.
 
My CaseEventLogger process however did not pickup the EDN events.

Removing EDNDataSource and EDNLocalTxDataSource

I read however (here) that two datasources (EDNDataSource and EDNLocalTxDataSource) needed to be removed for the WLJMS implementation of EDN in 11g to work (default is AQJMS). In 12c the WLJMS implementation is default so I tried removing the datasources and restarted my soa-infra. Next I got the following errors:

Exception in publishing business event[[
java.lang.NullPointerException
    at oracle.bpm.casemgmt.event.CaseEventEDNPublisher.publish(CaseEventEDNPublisher.java:112)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)


This was curious since ACM was not supposed to use the EDN datasources (that I had just removed). Remember the logging I posted before? SAQRemoteBusinessEventConnection was used. Why AQ? (hardcoded in CaseEventEDNPublisher?).

When publishing an event from the Enterprise Manager I see logging like;

[SRC_METHOD: publish] EDN outbound: JMS Config: oracle.soa.management.config.edn.EDNJmsConfig@d6c5dac2 [remote=false, jmsType=WLJMS, durable=true, xa=true, connectionName=eis/wls/EDNxaDurableTopic, topicName=jms/fabric/EDNTopic]

I also see other logging from oracle.integration.platform.blocks.event.jms2.EdnBus12c. This is a class the Case does not seem to use. The Case uses oracle.integration.platform.blocks.event.saq.SAQBusinessEventBus.

Setting the implementation to AQJMS

In order to confirm this finding, I set the EDN implementation to AQJMS (this MBean: oracle.as.soainfra.config:Location=SoaServer1,name=edn,type=EDNConfig,Application=soa-infra) and redeployed my logger process is order to have it use the correct datasource (you can also alter it at runtime from the Enterprise Manager in the Business Event screen).

I still didn't see my event arrive in my logger process. I did see however the EDN activation:

[SRC_METHOD: log] eis/aqjms/EDNxaDurableTopic EdnBus12c Populating ActivationSpec oracle.tip.adapter.jms.inbound.JmsConsumeActivatio
nSpec with properties: {UseNativeRecord=false, DurableSubscriber=CaseEventd_SCA_60016, PayloadType=TextMessage, UseMessageListener=false, MessageSelector=EDN$namespace = 'http://xmlns.oracle.com/bpm/case/event' AND EDN$localName
= 'CaseEvent', endpoint.ActionSpec.className=oracle.tip.adapter.jms.inbound.JmsConsumeActivationSpec, DestinationName=jms/fabric/EDNAQjmsTopic}


Maybe I shouldn't use the new (and very useful!) 12c durable subscriber feature? Lets retry without.

[SRC_METHOD: log] eis/aqjms/EDNxaTopic EdnBus12c Populating ActivationSpec oracle.tip.adapter.jms.inbound.JmsConsumeActivationSpec w
ith properties: {UseNativeRecord=false, PayloadType=TextMessage, UseMessageListener=false, MessageSelector=EDN$namespace = 'http://xmlns.oracle.com/bpm/case/event' AND EDN$localName = 'CaseEvent', endpoint.ActionSpec.className=or
acle.tip.adapter.jms.inbound.JmsConsumeActivationSpec, DestinationName=jms/fabric/EDNAQjmsTopic}


They both use (check the JmsAdapter configuration) jms/fabric/EDNAQjmsTopicXAConnectionFactory. In the soajmsmodule, you can find the topic used: EDN_AQJMS_TOPIC.

But what does the Case do?

When looking at what the class used by the Case for publishing events does, we see something different. The oracle.integration.platform.blocks.event.saq.SAQBusinessEventBus class is used by the oracle.integration.platform.blocks.event.saq.SAQBusinessEventConnection class of which we see logging. The SAQBusinessEventBus class uses the EDN_EVENT_QUEUE (indirectly, via the EDN_INTERNAL_PUBLISH_EVENT procedure, which you could also see in the first error when still using the Derby quickstart database). When looking at the database, my messages also appeared to have ended up there.

Finally

Thus in Adaptive Case Management 12c (I've used 12.1.3.0.2) publishing of case events to the event delivery network does not work yet (and this should not be something which we should fix on our own). In Adaptive Case Management 11g we do not have guaranteed delivery when using the EDN. Thus currently this feature cannot be used yet to for example obtain management information about cases since in 11g it is not guaranteed all case events are delivered and in 12c it does not work.

If it could be used, it would be great to for example store case events in a data-warehouse and allow a management information department to query on the results. It requires minimal effort to implement and has the potential to provide a lot of (business relevant) information.

Resources

EDN Debugging
https://blogs.oracle.com/ateamsoab2b/entry/edn_debugging

SOA 12c – EDN –Using AQ JMS
https://svgonugu.wordpress.com/2014/12/31/soa-12cednusing-aq-based-jms/

BPM Suite 11.1.1.7 with Adaptive Case Management (ACM) User Interface available for download
https://blogs.oracle.com/soacommunity/entry/bpm_suite_11_1_11

How to Publish Case Events
http://docs.oracle.com/cd/E28280_01/doc.1111/e15176/case_mgmt_bpmpd.htm#BPMPD87511


Rapid creation of Virtual Machine(s) for SOA Suite 12.1.3 server run time environment – leveraging Vagrant, Puppet and Biemond
https://technology.amis.nl/2014/07/31/rapid-creation-of-virtual-machines-for-soa-suite-12-1-3-server-run-time-environment-leveraging-vagrant-puppet-and-biemond/


How to Configure JMS-based EDN Implementations
http://docs.oracle.com/cd/E23943_01/dev.1111/e10224/obe_intro.htm#SOASE295

  
Sample case and logger process
https://dl.dropboxusercontent.com/u/6693935/blog/SOAApplication.zip 

1 comment:

  1. Need you help, Facing issues in ACM 12c- BPM 12.2.1.3

    I am facing issues while implementing Case management in BPM 12c (BPM 12.2.1.3).

    Below are the Challenges we are facing

    1) Even after Completing the Task for a case by the user the process state is still “ RUNNING”, is this the default behavior?? How to make this completed

    2) After we create a case and send it to other user for review and second user has closed the task then all the cases has to be closed and needs to be terminated. Can we able achieve this functionality??
    If I try to execute above use case, unable to close the task.

    3) For UI we are following this approach in the current Project.

    For Human tasks, I have created the BPM Case management flow with Human Tasks and has shared with the ADF team, they are generating the form using .task file
    For Case UI I have auto generated the CaseUI and Shared with the team and they are deploying ADF Task form and Case Form as a war.
    When I am testing the Case from SOAP UI, able to see the Case data in BPM workspace , but when we are testing from JET UI, it is unable to render the data in Case but able to see in ADF form in BPM workspace for that particular task.

    Just want to understand , are we missing any link or something

    -Pavan

    ReplyDelete