[jboss-user] [jBPM] - Store variables in DB?

nt2005 do-not-reply at jboss.com
Tue Jan 31 13:06:19 EST 2012

nt2005 [https://community.jboss.org/people/nt2005] created the discussion

"Store variables in DB?"

To view the discussion, visit: https://community.jboss.org/message/649727#649727

Hey Guys,

The 'problem' I have is a bit difficultly to describe, but I will give my best:

I use jBPM 5.2 in a Web-Application at an JBoss 6 AS with a PostgreSQL (just for info).

I start a process in an Seam bean like this:

public void startProcess() {
        EntityManagerFactory emf = entityManager.getEntityManagerFactory();
        TransactionManagerService tms = new TransactionManagerService();
        Environment env = KnowledgeBaseFactory.newEnvironment();
        env.set(EnvironmentName.ENTITY_MANAGER_FACTORY, emf);
        env.set(EnvironmentName.TRANSACTION_MANAGER, tms.getTransactionManager());
        Properties properties = new Properties();
        KnowledgeSessionConfiguration config = KnowledgeBaseFactory.newKnowledgeSessionConfiguration(properties);
        // load up the knowledge base
        KnowledgeBase kbase = readKnowledgeBase(processid);
        StatefulKnowledgeSession ksession = JPAKnowledgeService.newStatefulKnowledgeSession(kbase, config, env);
        JPAWorkingMemoryDbLogger logger = new JPAWorkingMemoryDbLogger(ksession);
        ksession.getWorkItemManager().registerWorkItemHandler(LoadDataWorkItem.NAME, new LoadDataWorkItem());
        ksession.getWorkItemManager().registerWorkItemHandler(TextOutputWorkItem.NAME, new TextOutputWorkItem());
        ksession.getWorkItemManager().registerWorkItemHandler(ImageOutputWorkItem.NAME, new ImageOutputWorkItem());
        String id = "blackdata";
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("id", id);
        process = ksession.startProcess("de.toni.new", params);

My jBPM-Process only contains my own WorkItems. The process works great and all.

In my process I have some process variables like:

<property id="image" itemSubjectRef="_imageItem"/>
<property id="text" itemSubjectRef="_textItem"/>

That I read and edit in my WorkItems:

String text = (String) workItem.getParameter("text");
Map<String, Object> results = new HashMap<String, Object>();
results.put("text", text);
manager.completeWorkItem(workItem.getId(), results);

The problem is, that these variables are in the process and not in the database. I thought, the persistence and serializable of all would save these in my db.

So my question to you:
How can I get these variables out of the process in a db?
I hope you understand what I mean, if not, just ask.  :)

Reply to this message by going to Community

Start a new discussion in jBPM at Community

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20120131/a3f3365c/attachment.html 

More information about the jboss-user mailing list