How to start multiple workflow instances with different input data

52 views
Skip to first unread message

deepak...@gmail.com

unread,
Dec 2, 2013, 8:31:52 PM12/2/13
to sarasvati...@googlegroups.com
Hi,

I have a web service deployed on tomcat. Each web service request needs to execute a new instance of a given workflow with different input data received as part of the POST request. In a tomcat node I could have 1000s of such concurrent requests. 

* What's the recommended way to allow such concurrent workflow instances? I noticed a comment indicating engine is not thread safe, so do I create new engine instance for each such request?
* What's the right way to pass the input parameters data to the workflow nodes? Environment variables or any other way?
* Also are there any bench-marking numbers for Saraswati? If I need to execute 1000s of workflow instances in a node, what's the impact on cpu, memory etc? 

Pls let me know if you would like me to provide more data here.

Thanks,
Deepak

deepak...@gmail.com

unread,
Dec 3, 2013, 9:03:19 PM12/3/13
to sarasvati...@googlegroups.com, deepak...@gmail.com
I am trying following example workflow in multiple threads - 5-50 threads. Each with new engine instance.
http://sarasvati.googlecode.com/svn-history/r1268/java/trunk/sarasvati-example/src/main/process-definition/example1.wf.xml


Also able to pass MapEnv while starting process, which is available in nodeToken.getFullEnv while processing tasks. Could you validate - is this the right way way to achieve what I was looking for in the initial post.


    int id = <thread number>;

MemEngine engine = new MemEngine();

...

       Graph example1Graph = engine.getRepository().getLatestGraph("example1");

       MapEnv me = new MapEnv();

       me.setAttribute("id", id);

       GraphProcess example1Process = engine.startProcess( example1Graph, me);


Now in b/w I observed following exception while trying workflow instances in multiple threads - so even with different engine instances does Saraswati has any issues with multiple threads?


Exception in thread "Thread-0" java.lang.NullPointerException

   at java.util.LinkedList$ListItr.next(LinkedList.java:891)

   at com.googlecode.sarasvati.impl.AbstractGraph.getInputArcs(AbstractGraph.java:83)

   at com.googlecode.sarasvati.join.LabelJoinStrategy.getJoiningArcs(LabelJoinStrategy.java:39)

   at com.googlecode.sarasvati.join.AndJoinStrategy.performJoin(AndJoinStrategy.java:88)

   at com.googlecode.sarasvati.join.AndJoinStrategy.performJoin(AndJoinStrategy.java:82)

   at com.googlecode.sarasvati.impl.BaseEngine.retryIncompleteArcToken(BaseEngine.java:293)

   at com.googlecode.sarasvati.impl.BaseEngine.executeArc(BaseEngine.java:278)

   at com.googlecode.sarasvati.impl.BaseEngine.executeQueuedArcTokens(BaseEngine.java:591)

   at com.googlecode.sarasvati.impl.BaseEngine.startProcess(BaseEngine.java:217)

   at com.googlecode.sarasvati.impl.BaseEngine.startProcess(BaseEngine.java:187)

Paul Lorenz

unread,
Jan 27, 2014, 3:23:03 PM1/27/14
to sarasvati...@googlegroups.com, deepak...@gmail.com
At my old job we used the hibernate backed version with lots of threads. However, some quirk of the loading process ensure that we didn't see the bug you are seeing. The AbstractGroup#initialize method should be changed to something like the code below. Unfortunately I no longer have time to maintain Sarasvati. Looking for a new maintainer, if you know anyone who is interested in helping out :)   private void initialize ()
  {
    Map<Node, List<Arc>> inputMap  = new HashMap<Node, List<Arc>>();
    Map<Node, List<Arc>> outputMap = new HashMap<Node, List<Arc>>();

    for ( Arc arc : getArcs() )
    {
      Node node = arc.getStartNode();
      List<Arc> list = outputMap.get( node );

      if ( list == null )
      {
        list = new LinkedList<Arc>();
        outputMap.put( node, list );
      }

      list.add( arc );

      node = arc.getEndNode();
      list = inputMap.get( node );

      if ( list == null )
      {
        list = new LinkedList<Arc>();
        inputMap.put( node, list );
      }

      list.add( arc );
    } this.inputMap = inputMap; this.outputMap = outputMap;
  }


--
You received this message because you are subscribed to the Google Groups "sarasvati-wf-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sarasvati-wf-us...@googlegroups.com.
To post to this group, send email to sarasvati...@googlegroups.com.
Visit this group at http://groups.google.com/group/sarasvati-wf-users.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages