AnsweredAssumed Answered

Activiti Workflow and Project Architecture

Question asked by fritz128 on Sep 6, 2013
Latest reply on Mar 10, 2014 by frederikheremans1
I start to integrate Activiti in my application, and I faced architecture problems.

My bussiness logic looks like:

  //this handler proceed ALL logic, and call needed activiti to do the final actions
  public void handle(org.eclipse.jetty.websocket.api.Session clientSession) {
    //I. Create and Save to database
    Session session = openHibernateSession();
    MyObject obj = new MyObject();
    session.save(obj);
    ….

    //II. Notify client
    clientSession.getRemote().sendString(Utils.objectToJson(obj));

    //III. Start activiti
    runtimeService.signalEventReceived("signal", executionId);   //only proceed some minor logic, like saving history!!!
  }


Problem:
I use WebSockets in my application, so I can't serialize clientSession and pass it to activiti's tasks. As a result, I can't proceed II-section of code (Notify Client) in activiti scope. As a result, I can't proceed in activiti scope all logic that  goes before II-section of code.
As I understand, the problem is that Activiti should wrap the  whole application logic, and provide more flexibility and clearance to my workflow!

What  I want:
Something like next architecture:


  //this handler only start the needed activity, and nothing else
  public void handle(org.eclipse.jetty.websocket.api.Session clientSession) {
     //I. Kick needed Activiti
     runtimeService.signalEventReceived("signal", executionId);   //proceeed ALL logic like I, II & III-code sections in example above
  }


Bad way to solve the problem:
I can't pass websocket session to the activiti's tasks, but I can ask it from task (for example save all sessions in static collection).

Disadvantage:
If I move Activiti to the separate machine, I can't pull static session list!

Question:
What is the right architecture for this case?

Outcomes