본문 바로가기
IBM - old/IBM BPM

[BPM]Long running service design in IBM Business Process Manager

by freeman98 2017. 1. 31.

https://www.ibm.com/developerworks/community/blogs/aimsupport/entry/long_running_service_design_in_ibm_business_process_manager?lang=en


Long running service design in IBM Business Process Manager

ZeHuaYANG | | Visits (4392)

imageimage

 

If you want to integrate an externally long running service in an IBM Business Process Manager process application, the best practice is to use asynchronous calls.

The reason for this practice is that long running synchronous call from IBM Business Process Manager to the outside service can lead to many potential problems. IBM Business Process Manager will keep a thread alive for the synchronize calls during the execution. It will hold many resources, such as table lock in the BPMDB, java heap. It can block the other threads from accessing the resource and it will not serve the other requests.

As a consequence, you end up seeing hung threads in the server logs. In extreme situation, it will exhaust the server resource.


The following screen shot illustrates an example, which is explained below:
 

image


 

 

 

In the previous screenshot, the process application has a timer for step 3 and this timer connects to one autoRetrieveTask. The autoRetrieveTask calls an Integration Service, which will call a third party service to get the task data. This call can take 30 minutes to return.

When the application is running, you can see the following messages in the server logs:

[14-11-25 12:50:05:027 CST] 00000099 ThreadMonitor W   WSVR0605W: Thread “WorkManager.bpm-em-workmanager : 1”(00000119)has been active for 610972 milliseconds and may be hung.  There is/are 6 thread(s) in total in the server that may be hung.
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.read(SocketInputStream.java:140)
    at java.net.SocketInputStream.read(SocketInputStream.java:101)

        ....


Before the autoRetrieveTask finished, if you call the following REST API to check process instance details, it will also be blocked:

GET /rest/bpm/wle/v1/process/{instanceId}[?parts={string}]

The following hung message can be seen in the server logs:

[14-11-25 12:59:05:034 CST] 00000099 ThreadMonitor W   WSVR0605W: Thread “WebContainer : 11”(00001838)has been active for 642212 milliseconds and may be hung.  There is/are 7 thread(s) in total in the server that may be hung.
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.read(SocketInputStream.java:140)
    at com.ibm.db2.jcc.t4.z.b(z.java:199)
    at com.ibm.db2.jcc.t4.z.c(z.java:259)
    at com.ibm.db2.jcc.t4.z.c(z.java:372)
    at com.ibm.db2.jcc.t4.z.v(z.java:1147)
    at com.ibm.db2.jcc.t4.db.c(db.java:30)
    at com.ibm.db2.jcc.t4.r.a(r.java:32)
    at com.ibm.db2.jcc.t4.j.Zb(j.java:263)
    at com.ibm.db2.jcc.am.ym.X(ym.java:3687)
    at com.ibm.db2.jcc.t4.d.f(d.java:1893)
    at com.ibm.db2.jcc.am.jc.a(jc.java:203)
    at com.ibm.db2.jcc.t4.d.a(d.java:109)
    at com.ibm.db2.jcc.am.ym.c(ym.java:382)
    at com.ibm.db2.jcc.am.ym.next(ym.java:309)
    at com.ibm.ws.rsadapter.jdbc.WSJdbcResultSet.next(WSJdbcResultSet.java:3108)
    at com.lombardisoftware.bpd.runtime.engine.util.LockBPDInstanceCommand$2.extractData(LockBPDInstanceCommand.java:94)
    at org.springframework.jdbc.core.JdbcTemplate$1.doInPreparedStatement(JdbcTemplate.java:653)
    at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:591)
    at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:641)
    at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:670)
    at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:678)

        ...

From the previous stack, you can see the operation is pending in the database. You can use DB2 tools like db2pd or the database snapshot to find out the lock status in the database. You will find that the long running service holds the lock on the process instance, while the query operation also attempts to get the lock. However, it can only wait for the lock to be released.

So, the best solution is to change the autoRetrieveTaskService to asynchronous calls.  Refer to the following articles on how to implement asynchronous calls in IBM Business Process Manager:

Integrating IBM Business Process Manager Standard with synchronous and asynchronous applications using IBM Integration Bus V9
http://www.ibm.com/developerworks/websphere/library/techarticles/1307_howes/1307_howes.html

IBM Business Process Manager V8.0 Performance Tuning and Best Practices
http://www.redbooks.ibm.com/abstracts/redp4935.htm

 

time-running-out image (modified) credit: (cc) Some rights reserved by Recon Cycles



Tags:  bpm service process_application


댓글