I'm currently working with some business process creation using BPMN with Activiti. For one step in that business process I need to query a database and use that result in subsequent steps. So I'm looking for possible workarounds to integrate SQL operation capabilities to Activiti. So can anyone please suggest me whether is there any way to embed sql query capabilities for the activiti? Any suggestion for external database interaction for BPMN process using Activiti Engine is highly appreciated.
If such solution does not exists, any help on how to implement such feature for activiti also helpful
You can Setup a Java Service Task as instructed here and implement your custom logic that may or may not include interraction with an external DataBase. Just remember to save the output of your service task to your process variables (execution) in case you need it for further processing (review for example, ...)
Here is a sample BPMN Service task:
<serviceTask id="javaService" name="My Java Service Task" activiti:class="org.activiti.MyJavaDelegate" />
And here is a sample implementation for it :
public class ToUppercase implements JavaDelegate { public void execute(DelegateExecution execution) throws Exception { String var = (String) execution.getVariable("input"); var = var.toUpperCase(); execution.setVariable("input", var); } }
Do not forget to manage your DB connection pools, ... etc so that you do not any unnecessary problems in production
EDIT :
I couldn't detect any thing from that blog post your referenced in your comment that may not function correctly in activiti community edition, just remember to make all your custom classes and dependencies available on your classpath.
Note : The post from the blog post is talking about the embedded activiti engine in alfresco (in that case it was Enterprise Edition), but yet again, it should work fine even with the community edition of activiti!