Results 1 to 8 of 8

Thread: spring-integration-activiti

  1. #1
    Join Date
    Feb 2009
    Location
    London
    Posts
    128

    Default spring-integration-activiti

    Hi,

    Is this project in progress or on hold for decision making? I can see a bit of code on this for adaptor and gateways.

    I think this is nice way to achieve Process Manager pattern from EAI patterns.

    Please let me know any update on this or I will doing some implementation of my own for this pattern.

    For my task, I will need a steps of requests/responses being sent/received from different applications sequentially/parallelly but all steps do not need to execute if first few fails!

    I think spring-integration-activiti, quite fit into my req.

    Thanks

  2. #2
    Join Date
    Feb 2006
    Location
    Los Angeles, CA
    Posts
    79

    Default

    Hi,

    The Spring Integration Activiti code in the sandbox should be a fit for your requirements. NB: it requires a version greater than 5.0 of Activiti (I think 5.1 just came out and that should be compatible). Additionally, the namespace doesn't work at the moment , though the objects do. If you clone the sandbox project and look at the src/test/* folders, you'll see examples of the different pieces in play. The gateway is the most powerful piece: you run a BPMN process, enter a state that in turn delegates to Spring Integration through the gateway. Spring Integration is then free to do whatever processing it like (perhaps send an XMPP message to your boss asking for approval on an audit flow? ...anything...). The gateway expets a response message on the reply channel. The reply message has to have an execution ID header (see the example) and ten the BPMN wait state continues execution. From Activiti's POV, the wait state is a regular wait-state. When execution enters the wait-state and sends a Message into SPring Integration, it stops execution and the flow stops until a reply message 'signals' the wait-state. The reply-message can arrive 10 seconds later, or 10 years later.

    Additionally, there is an outbound adapter that implements the processManager pattern of a trigger message. A message is used to 'trigger' the execution of a new business process instance.

    I suspect this will be wrapped up and polished in time for the next release of Spring Integration itself, and I will work to restore the namespace soon. Either way, any feedback would be very appreciated.
    Josh Long
    Spring Developer Advocate
    SpringSource, a division of VMware

    http://blog.SpringSource.org
    http://www.joshlong.com

  3. #3
    Join Date
    Feb 2009
    Location
    London
    Posts
    128

    Default

    Hi Josh,

    Thanks for quick and very detailed response. I will start playing with it today and see If all looks good.

    Though, I will have to go through the code and Activiti but here are few quick thoughts that flashed my mind:
    1) My flow is JMS based flow( event-driven adaptor) and then the message will come to some in-between processors doing there bit and then I want to hand-over to Process-Manager which will do/handle request/response( comes to defined queues ) from different systems.

    As soon as I receive a message from the target system , then I will have to send a message to other system depending on some conditions( I guess outbound adaptor will be better here ) , which will be achieved by Activity and SI.

    2) I want to make sure that thread of execute during the whole execution in my bus is not stuck waiting for response from target system. So that the system is still taking other new messages that come at source( begining of the JMS flow ). I hope if I use gateway would not block! . Will test and verify.


    I will come back with any feedback and start using the sandbox Activiti module.

    Thanks

  4. #4
    Join Date
    Feb 2009
    Location
    London
    Posts
    128

    Default

    quick comments:
    1) got the sandbox and started playing.
    2) few compilation errors around -- this.messagingTemplate.setTransactionManager(this. platformTransactionManager); as there is no setTransactionManager method on MessagingTemplate.
    3) activiti 5.0 and 5.1 does seem to have no Execution execution = (RuntimeService)(processService.findExecutionById( executionId);-- method

    I will keep posted on how i go on and let you know.

  5. #5
    Join Date
    Feb 2009
    Location
    London
    Posts
    128

    Default

    Hi Josh,

    Made a bit of progress to get this going and the code is complaint to 5.1. Started testing but not much luck for sometime now. Though , outbound adaptor seems to be working ok.

    If we look at the config below and code, the test fails as serviceTask needs to have a class attribute, which shoould refer to fully clasified name( link-- http://www.activiti.org/userguide/in...avaServiceTask ).

    I tried option like expression/delegateExpression but taht did not make sense. So, I am kind of stuck that how gateway is going to get invoked.

    Any idea, will be of great help.


    Error message:
    HTML Code:
    EVERE: Error while closing command context
    org.activiti.engine.ActivitiException: One of the attributes 'class', 'delegateExpression', 'type', 'operation', or 'expression' is mandatory on serviceTask. | processes/si_gateway_example.bpmn20.xml | line 16 | column 10
    HTML Code:
    <!-- <!-- Activiti sends a message 'to' (inbound) Spring Integration 'from' Activiti -->
    	<activiti:inbound-gateway
    			process-engine="processEngine"
    			request-channel="request"
    			async="true"
    			reply-channel="response"
    			forward-process-variables-as-message-headers="true"
    			update-process-variables-from-reply-message-headers="true"
    			id="gateway"
    	/>	/>
    And BPM config below:
    HTML Code:
    	<process id="sigatewayProcess">
    
    		<startEvent id="theStart"/>
    		<sequenceFlow id="flow1" sourceRef="theStart" targetRef="sigw"/>
    		<serviceTask id="sigw" name="Spring Integration Gateway" activiti:class="${gateway}" />

  6. #6
    Join Date
    Feb 2009
    Location
    London
    Posts
    128

    Default

    Hi Josh,

    I got this working with new expression and kind of working partialy now. But i think wait state does now work still.

    Few questions--
    • When does public void execute(ActivityExecution execution) in AsyncActivityBehaviorMessagingGateway gets called. I thought BPMN should have called but I do not see this being called.

    • When reply message is being sent to reply channel , there is no Execution instance attached to the processEngine. I would have imagined there should have been one. In fact, I tried to log all the insatnces for that process but there was none. Please see the code for list in handleMessage method of ReplyMessageHandler.

    • I am attaching the modified compiled code. Please have a quick look if you like. And, let me know whats going wrong. Activiti version being used is 5.1

    rename the attachment from .zip to .rar if the extraction does not work.

    Please pour in some comments.
    Attached Files Attached Files

  7. #7
    Join Date
    Feb 2009
    Location
    London
    Posts
    128

    Default

    Update--

    Josh,
    The processEngine's instance is finished as soon as its created. Look at the code below and isEnded returns true

    Looks like i am running out of time and any input to proceed will be great. Otherwise, I seem to be heading towards not so good solution that we will think of implementing process manager, may routing slip which essential does not give the actual pattern.

    Code:
    @Test
    	public void testGateway() throws Throwable {
    		processEngine.getRepositoryService().createDeployment().addClasspathResource("processes/si_gateway_example.bpmn20.xml").deploy();
    		Map<String, Object> vars = new HashMap<String, Object>();
    		vars.put("customerId", 232);
    		ProcessInstance processIntance = processEngine.getRuntimeService().startProcessInstanceByKey("sigatewayProcess", vars);
    		logger.info("Process instance id is " + processIntance.getId());
    		logger.info("Process Business id is " +  processIntance.getBusinessKey());
    		logger.info("Process Business Def id is " +  processIntance.getProcessDefinitionId());
    		logger.info("Process ended " +  processIntance.isEnded());

  8. #8
    Join Date
    Feb 2009
    Location
    London
    Posts
    128

    Default

    The statement below is not actually calling the Spring endPoint
    BPMN

    Code:
    <serviceTask id="sigw" name="Spring Integration Gateway" activiti:expression="#{gateway}"/>
    Code:
    <!-- Activiti sends a message 'to' (inbound) Spring Integration 'from' Activiti -->
       <activiti:inbound-gateway
             process-engine="processEngine"
             request-channel="request"
             async="true"
             reply-channel="response"
             forward-process-variables-as-message-headers="true"
             update-process-variables-from-reply-message-headers="true"
             id="gateway"
       />
    And, as per comment above "Activiti sends a message 'to' (inbound) Spring Integration 'from' Activiti "- there is no way to send message from Activiti to channel as of now. I tried overriding ActivityBehavior to send the message on channel but I guess the channel inject does not work in BPMN configs. So, Unfortunately i am stuck

    Josh, any comment would be very useful.

    Thanks

    Is their any other way that you know to invoke the gateway using some other expressions or class? So, its back to square one. The instance was closing becausing I was just sending the request on channel directly.
    Last edited by rock_star; Jan 10th, 2011 at 12:58 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •