best grammar app

Adapter - BPM Basics

Submitted by Abhishek on Tue, 2012-05-01 11:26
sxc.hu

Business Processes in BPM world often need a way to do some operations – internally or externally. For example, finding out the next set of performers from a routing table or sending a message to a third party trading system. “Adapters” is a term used commonly for such artifacts which allow you to execute custom code. Products like Savvion Business Manager, Bonitasoft, JBPM all have adapters. Terminology might be different – in general any machine specific task can be called an adapter.

 

How does an adapter work

An adapter works by providing an input and output interface. In terms of basic java an adapter which concats your firstname and lastname could look something like the code below

 

class MyNameAdapter{

private String firstName;

private String lastName;

private String fullName;

 

public void setFirstName(String firstName){

this.firstName=firstName;

}

 

public void setLastName(String lastName){

this.lastName=lastName;

}

 

public void concatNames(){

    this.fullName=this.firstName+” “+this.lastName;

}

 

public String getFullName(){

return this.fullName;

}

}

 

The execution of an adapter happens in three steps

  1. All the Setters are called on the adapter. This sets the value of various fields (in our example, the firstName and lastName). This way the calling logic is able to set data on the adapter

  2. The Worker method is called. Worker method can take care of your business logic. In our example this is the contactNames method which does the actual concatenation of firstName and lastName and then sets the field fullName

  3. The Getters are called. This way calling logic gets the output from the adapter

 

 

Things you can do with an adapter

There are a number of things you can do with an adapter. Here are some examples listed

  • Do some complex calculations and set the value to a particular dataslot. For example if you have logic which calculates the insurance premium based on user age, salary, number of family members and so on

  • Find out the routing logic. For example you could have an adapter just after the start step which determines the downstream performers (like Trade Support Group, Customer Support Group) based on an Account Number specified in the first step

  • Send and receive messages. You can use the adapter to send and receive synchronous and asynchronous messages like JMS, MQ etc. You can parse the message and update the data values. Some mature products like Savvion and Bonitasoft have built in adapters for popular message based integrations

  • Update information. You can use an adapter to update information in some tables within your database or outside. Projects that do not use product provided reporting use adapters to update their reporting/ETL (Extract Transform Load) databases.

  • Do Cleanups. Sometimes adapters are used in case of exceptional conditions to do data cleanup and take care of compensation logic.

 

Things to watch out for

If you are using adapters in your project, there are certain things you should watch out for. For Example, managing exceptions. You are writing code which could throw exceptions. Depending on the BPM Product you are using, you could have different behaviors. For example product like Savvion will suspend the workstep if the adapter throws an exception (that too after retrying it for 3 times). The catch here is that how do you want your process to behave in case of an exception. If you handle the exception gracefully inside your adapter code, your process moves on – for it the adapter did complete correctly. You should either throw exceptions out in case you want process to suspend, or have some kind of data field which you can use as a latch to retry the adapter.

 

Another thing to watch for is where the adapter is executing. Depending on your product your adapter could execute inline with your process or be connected via a JMS Queue logic. Depending on where the adapter is executing, you would need to determine settings like CLASSPATH, Environment Variables etc.

 

Your system type also plays a role. Your process is executing within a development, testing or production system would determine where your adapter connects and transmits information. One way I do this is to have an environment variable which defines if its a DEV, UAT or PROD system. Then have code in your adapter which locates necessary dev.conf, uat.conf or prod.conf file which has further settings like database name or queue destination.

 

Data types is another aspect. Determine how data types are translating between your process an adapters. Sometimes a toString could be called on your data before it gets passed to the adapter making it difficult for you to do type checks and calculations. Same applies in case data is being sent back.

 

Hope this is helpful. Questions are welcome.

 

Also check out these helpful articles


Abhishek Mishra
Good experience in working with BPM technologies like Savvion, JBPM. Founder and Chief Editor of BPMGeek.com. Founder of Savvion Business Manager Mobility Framework Savmobify| View my BPMGeek Profile
|
best grammar app

About BPMGeek

BPMGeek is an initiative to collaborate and communicate with the growing Business process management community out there. The goal is to help developers connect with experts, ask questions, post their learning and get understanding of BPM Concepts. Often tool specific knowledge of niche areas end up developers perplexed and confused - especially when there are very less number of resources available. We will be coming up several several new features. Have a look at our Roadmap here

BPMGeek is an independent entity not associated with any Product. All BPM product professionals are invited to contribute. The Logos and Names used across the site belong to their respective owners. The viewpoints mentioned by Individual contributors are their own. BPMgeek cannot be held liable for any issues arising out of it.


BPMgeek is promoting the Nounshoun English Grammar App - developed by Constellation Software.