Thursday, December 3, 2009

WebSphere Process Server - skipping steps in the process

A customer of mine has decided to build an application that can monitor his processes, instead of the regular WPS supplied tool.
His main concern was skipping steps. Turns out that when a process has executed a specific activity, and this activity is in a special position (like user task) - an outside application can cause a skip in the process.
I have developed a short demo for this, and I'm enclosing the main method here. Just make sure to disable the process security before running it - or you'll get a non authorized exception...

// Connect to the server
Properties props = new Properties();
props.put(Context.PROVIDER_URL, "iiop://localhost:2811");
javax.naming.InitialContext ctx = new javax.naming.InitialContext(props);

// Lookup the BusinessFlowManager. If you get casting exception - read the InfoCenter - you need to add some JARs to your code - it's WPS/ProcessChoreographer/client/bpe137650.jar
Object lookupResult = ctx.lookup("com/ibm/bpe/api/BusinessFlowManagerHome");

BusinessFlowManagerHome processHome = (BusinessFlowManagerHome) PortableRemoteObject
.narrow(lookupResult, BusinessFlowManagerHome.class);

BusinessFlowManager bfm = processHome.create();

// Replace with any process id
ProcessInstanceData pid = bfm.getProcessInstance("_PI:90030124.f71386d4.dbed54f5.5d84025c");

// Replace with any activity name
ActivityInstanceData aid = bfm.getActivityInstance(pid.getID(),"Wait");

// Skip to the specific activity
bfm.skipAndJump(aid.getID(), "TargetActivity");

No comments:

Post a Comment