Friday, April 22, 2011

BPMN 2.0 data associations discussion

There's some discussion going on about some of the details in the BPMN 2.0 specification, more specifically the use of the process data input and process data outputs.

One of the issues of using an XSD to check the validity of an XML file (as the BPMN2 specification provides), is that the XSD does not express all the constraints that a process must fulfill to be valid. A lot of constraints are expressed in the narrative sections of the specification. That's why Bruce Silver is working on a profile for BPMN interoperability (BPMN-I) that could be used to check additional constraints, with the goal of achieving true interoperability between different vendors by making a lot of the "hidden" rules explicit.

During that work, Bruce (I hope he doesn't mind me calling him Bruce, maybe I should say Mr. Silver based on my appreciation for the work he has done and is still doing in this area ;)) discovered some discrepancies (or at least some confusing statements) in the specification itself when it comes to the use of process data inputs in relation to data input associations. I'm not going to try and explain the issue in detail, I would like to refer the readers that might be interested in the details to his blog and the followup blog, as it contains all the details, including numerous references to the spec itself and a discussion on the topic. But to make a long story short:

Can a process data input be used as the source of a data input association of task that is contained inside the process?

Since Bruce is asking for input from other interested parties, and jBPM is offering a BPMN 2.0 engine, I thought I'd give it a try. But since I couldn't find a way to put all this information and picture as a reply on his blog itself, I decided to write this blog entry and include my reply here (and to avoid splitting up the discussion I would suggest to add comments related to this topic on his blog as well). And at the same time I can invite other readers to give their 2 cents as well ;) So here it goes:

It seems to me, from reading the specification, that data input and output associations are meant to be "local", by which I mean they are not intended to be referenced from outside the element in which they are defined. On top of that, it also seems to me that they are intended to be "immediate" or "instantaneous" (not sure this is the best term but I couldn't come up with a better one at this point), meaning they are "executed" when they are reached, but they don't exist anymore after that.

Therefore, I would agree with your statement that process data inputs should not be the source of a data input association, as the process data input association only exists when the process is invoked and at that point, that data input association is executed. [I also believe that using a process data input when the process is actually started by a timer start event confusing, as it's unclear where this information would come from, but that's another issue.]

So how would you use your process data inputs in the remainder of your bpmn2 process then? I think the ioSpecification of the process, that contains these process data inputs, should also contain data output associations that map these data inputs to more persistent (as opposed to immediate or instantaneous) item-aware elements like a property or a data object. These can then serve as the source of other data input associations. So you don't directly use a process data input as the source of a data input association of (for example) a task, but you rather first map the process data input to a property using a data output association (as part of the process ioSpecification) and then use this property as the source of the data input association of the same task.

A screenshot of this in a real process is shown below (note that I deliberately chose a slightly different example to avoid using a start timer event in combination with a process data input as this makes it only more confusing):



You don't often come across people with such an in depth knowledge of how ioSpecifications in BPMN2 actually work, so I must admit I enjoyed reading the discussion so far ;)

Wednesday, April 13, 2011

Drools & jBPM Workshops (May 2011) - New York and Washington DC

After JBoss World we have two Drools and jBPM5 workshops in May for New York and Washington. These are free events open to all in the public:

The events will be a mixture of talks with lots of time for questions and discussions.

Speakers:
Mark Proctor - Drools co-creator and Project Lead
Kris Verlaenen - jBPM Project Lead
Edson Tirelli - Drools technical lead.

Event: New York - Registration page and agenda
Date:
Tuesday, May 10, 2011
Time: 8:30am – 5:30pm (breakfast, lunch, afternoon snack provided)
Cost: Free but register as seats are very limited.
Location: Affinia Manhattan Hotel
371 Seventh Avenue,
New York, NY 10001

Event: Washington - Registration page and agenda
Date:
Thursday, May 12, 2011
Time: 8:30am – 4:00pm
Cost: Free but register as seats are very limited.
Location: Renaissance Washington
999 Ninth Street, NW
Washington, DC 2000

Monday, April 4, 2011

JUnit testing your jBPM5 processes

Even though business processes aren't code (we even recommend you to make them as high-level as possible and to avoid adding implementation details), they also have a life cycle like other development artefacts. And since business processes can be updated dynamically, testing them (so that you don't break any use cases when doing a modification) is really important as well.

When unit testing your process, you test whether the process behaves as expected in specific use cases, for example test the output based on the existing input. To simplify unit testing, jBPM5 includes a helper class that you can use to greatly simplify your junit testing, by offering:
  • helper methods to create a new knowledge base and session for a given (set of) process(es)
    • you can select whether you want to use persistence or not
  • assert statements to check
    • the state of a process instance (active, completed, aborted)
    • which node instances are currently active
    • which nodes have been triggered (to check the path that has been followed)
    • get the value of variables
    • etc.
For example, conside the following hello world process containing a start event, a script task and an end event. The following junit test will create a new session, start the process and then verify whether the process instance completed successfully and whether these three nodes have been executed.


public class MyProcessTest extends JbpmJUnitTestCase {

public void testProcess() {
// create your session and load the given process(es)
StatefulKnowledgeSession ksession = createKnowledgeSession("sample.bpmn");
// start the process
ProcessInstance processInstance = ksession.startProcess("com.sample.bpmn.hello");
// check whether the process instance has completed successfully
assertProcessInstanceCompleted(processInstance.getId(), ksession);
// check whether the given nodes were executed during the process execution
assertNodeTriggered(processInstance.getId(), "StartProcess", "Hello", "EndProcess");
}
}

Testing processes that don't interact with the environment like this one are really easy to test but in general aren't that realistic ;) Real-life business processes typically include wait states, invocation of external services, etc. One of the advantages of our domain-specific process approach however is that you can easily specify different implementation of the node depending on the context. This means that, when you are unit testing your business process, you can register test handlers that can be used to verify whether specific services are requested correctly, and provide test responses for those services. For example, imagine you have an email node or a human task as part of your process. When unit testing, you don't want to send out an actual email but rather test whether the email that is requested contains the correct information (for example the right to email, a personalized body, etc.).

The following example describes how a process that sends out an email could be tested. This test case in particular will test whether an exception is raised when the email could not be sent (which is simulated by notifying the engine that the sending the email could not be completed). The test case uses a test handler that simply registers when an email was requested (and allows you to test the data related to the email like from, to, etc.). Once the engine has been notified the email could not be sent (using abortWorkItem(..)), the unit test verifies that the process handles this case successfully by logging this and generating an error, which aborts the process instance in this case.


public void testProcess2() {
// create your session and load the given process(es)
StatefulKnowledgeSession ksession = createKnowledgeSession("sample2.bpmn");
// register a test handler for "Email"
TestWorkItemHandler testHandler = new TestWorkItemHandler();
ksession.getWorkItemManager().registerWorkItemHandler("Email", testHandler);
// start the process
ProcessInstance processInstance = ksession.startProcess("com.sample.bpmn.hello2");
assertProcessInstanceActive(processInstance.getId(), ksession);
assertNodeTriggered(processInstance.getId(), "StartProcess", "Email");
// check whether the email has been requested
WorkItem workItem = testHandler.getWorkItem();
assertNotNull(workItem);
assertEquals("Email", workItem.getName());
assertEquals("me@mail.com", workItem.getParameter("From"));
assertEquals("you@mail.com", workItem.getParameter("To"));
// notify the engine the email has been sent
ksession.getWorkItemManager().abortWorkItem(workItem.getId());
assertProcessInstanceAborted(processInstance.getId(), ksession);
assertNodeTriggered(processInstance.getId(), "Gateway", "Failed", "Error");
}

You can configure whether you want to execute the junit tests using persistence or not (by default using an in-memory H2 database which is started by the junit test itself and by using a history log), simply by passing a boolean whether you want to use persistence or not when calling the super constructor.

We will extend the set of out-of-the-box assert statements over time, but if you do need additional assertions for your use cases, you can already extend the set yourself by looking at the implemention of the existing ones and simply tweaking where necessary. And let us know if you create some reusable ones, we'll add them to the code base!

If you combine these test features with the advanced debugging capabilities, (as for example shown in this screencast) you can use this to walk through the process one step at a time and figure out what's happening internally. We're working on extending this even further to support full simulation and testing capabilities. This would allow you easily define and run various test scenarios, replay an execution log, etc. The foundation is already there (like a simulation clock and the definition of execution paths), but we're still working on the user interface that would make this useable by not just developers but also business users.

Saturday, April 2, 2011

jBPM at JUDCon and JBoss World in Boston in May

The first week of May is going to be busy this year!


First, there is 2 days of JUDCon, May 2 - 3. JUDCon is an event by developers, for developers. I attended JUDCon Berlin last year and it is a great place for developers to learn the details of different technologies and meet the core developers and other community developers out there. Presentations will include a range of deep technical dives into JBoss Community projects and related technical topics of developer interest. And the hack fests allow you to do some real coding as well.

There are a handful of jBPM-related presentations, and many many more. Check out the agenda and register today!



Immediate after JUDCon and on the same venue, there is JBoss World and Red Hat Summit, May 3 - 6, where there will be numerous presentations on a lot of different topics, (j)BPM being one of them. We'll be touching on a wide area of from the core engine itself to event-driven BPM and decision management. Details in the agenda, and don't forget to register!

Friday, March 18, 2011

JBoss Asylum on jBPM5

I recently did an interview for JBoss Asylum. They bring us regular updates on what's new at JBoss by doing podcasts and inviting guests to talk about special topics.

With the release of jBPM 5.0, now was my time to get attacked by Max Rydahl Andersen, Emmanual Bernard and Michael Neale ;)

This episode had some bad luck with respect to the audio recording and took a while to get edited down to listenable quality. The news are therefore a bit out of date but the interview with Kris Verlaenen about jBPM 5 is all filled with great and interesting content.

The interview part has good audio and you can skip to the 22m33s mark to hear about jBPM 5.

We are again sorry that Emmanuel Bernard messed up the recording, but we will back soon with a new interviewee and with better sound ;)

If you got comments/feedback send it via mail or on twitter.


Get the episode from here

Thursday, March 17, 2011

Red Hat & Accenture: BRMS & BPMS Event (London, March 29th)

Business Rules and Business Process Management the Open Source Way


Join Red Hat and Accenture on Tuesday 29th March at Accenture Old Bailey to understand how Business Rules Management Systems (BRMS) and Business Process Management Systems (BPMS) can help businesses leverage technology more effectively and increase productivity. See how Enterprise Open Source is leading the way with powerful capabilities and industry-leading innovation.

There will be 2.5 hours of technical talks, starting at 9am. Full timings and agenda here.

Talks (from core developers, there are other talks too):

Introduction to Rule Based Systems (Mark Proctor)
Introduces Drools and explains what a rule based system is and how it works. We will also cover event processing on a rule based system.

Why BPMN2 Matters (Kris Verlaenen)
jBPM5 has just been released as premier Open Source BPMN2 implementation. Come and hear how this changes your whole legacy approach to BPM.

Using Guvnor for Enterprise Systems (Geoffrey de Smet)
Guvnor provides a web interface to your knowlege systems, such as rules and bpm. This talk provides a gentle introduction into Guvnor and how to use it.

Decision Tables in Depth (Michael Anstis)
Decision Tables is now a major focus for us, we want to show you why we'll have the slicket decision table environment out there.

Register here !

Tuesday, March 8, 2011

jBPM5 lightweight? Running on Android!

I recently bought myself a new Android phone, and as a developer, that obviously means I have to try and write my own application for it ! :)

And since we always claim jBPM is such a lightweight engine that you can embed it practically anywhere, I decided to give that a try: run the jBPM5 engine on Android. Some people might be thinking, why would I want to do that? Well, my primary goal was just as a proof of concept. But maybe, if we extend that proof of concept a little more and add more Android tasks, end users without any real development experience might be able to use it do model simple Android applications as well, who knows!

So after downloading the Eclipse tooling and following a hello world example, I decided to create a simple process that first asks the user for some keyword and then uses this keyword to search the jBPM community forum for entries containing that keyword (I know, not rocket science, you don't really need a workflow engine for that but it's just a demo example).


After adding the jBPM5 jars to the classpath, I updated my application to start this process when the application is started. I also created two domain-specific services for Android, one for requesting some input from the user (where I then bind this result to a process variable) and one for showing a web page (which shows a URL, which I created based on the input of the user).

And it worked almost[*] out of the box! So this is what it looks like (on the emulator, but it runs nicely on my phone as well). First you start the jBPM application ...



The first node in the process will ask you for a keyword you want to search for ...


And the last node will show the results of the query on the jBPM community forum in a browser ...


I'm pretty sure there are a lot of developers out there that try to play with new technologies like this, so if you're interested in playing with this and maybe extending this a little, let me know. Imagine we add a few more default services for showing an image, getting some file, getting GPS location, etc. Would be pretty cool if you could create more advanced applications like that.

I've uploaded the source code and the jbpm-android.apk so you can give it a try yourself !

[*] A small modification is needed in org.drools.util.CompositeClassLoader. Apparently, the Android JVM doesn't allow null as the parent classloader so I changed that to super(CompositeClassLoader.class.getClassLoader()) in the constructor, and that works fine.