On Thu, Apr 23, 2009 at 12:28 AM, krish <[email protected]> wrote: > > However, one or more of my tasks would be interacting with 3rd party > software via web service calls, and ofcourse, it is asynchronous. So, > what I need to be able to achieve is this - > > Until I get a response from the 3rd party app(s), I don't want to move > forward with the workflow. It should basically be in a "paused" state > (perhaps, I could pause the engine, but what after that?) and should > resume when it receives a response (HTTP POST, for instance) from the > 3rd party app. Does the workflow engine support this?
Hi Krish, thanks for your interest. I think I have to finish the documentation at http://openwferu.rubyforge.org/part.html so that it covers the answer to your question. So in your scenario, you call a webservice and then, later, this webservice posts its result back to your application (sounds like a "webhook"). I assume your web service is something over HTTP and not necessarily SOAPesque (http://openwferu.rubyforge.org/participants.html#SoapParticipant). I wrote something that might interest you about (this http://jmettraux.wordpress.com/2008/05/27/restful-bpm/), but it's maybe better to have a fresh look at the issue. Ruote-rest and ruote-web2 have a "workitems" resource. A 'client' can pick a workitem (GET /workitems/x/y) and later issue it back to the engine by putting back its updated representation (PUT /workitems/x/y) with a 'proceed' flag set to true (else it simply saves the new payload of the workitem, but the flow doesn't resume). It's nice but you want to "trigger" the webservice, you don't want it to poll the engine/application for work. Your webservice participant could look like : ---8<--- class WebserviceParticipant def initialize (target_uri, callback_uri) @target_uri = target_uri end def consume (workitem) representation = to_representation(workitem, @callback_uri) http_post(@target_uri, representation) end end --->8--- This hypothetical implementation assumes the 'endpoint' is known when the application starts (target_uri), the callback_uri is the URI of the controller that follows. When the participant receives a workitem from the engine, it will turn the workitem into some representation understood by the target (JSON, XML, CSV, whatever) and post it. The representation should include the workitem identification data (at least workflow_instance_id and expression_id). A suggestion : the representation should include as well the callback_uri (makes it more loose, and the target may thus deal with multiple work sources/engines). Note that the participant does not reply to the engine, letting the segment of process instance wait. The listener takes the shape of a Rails controller : ---8<--- class CallbackController < ApplicationController def update workitem = rebuild_workitem(params) RuotePlugin.ruote_engine.reply(workitem) end end --->8--- It assumes the workitem representation comes back via a PUT (real or faked). It rebuilds the workitem out of the parameters (mostly the representation found in the body of the PUT/POST) then replies to the engine with it. The call to reply may potentialy fail (maybe the process instance or segment got cancelled), so watch out for that. This conversation with Axyd might interest you : http://groups.google.com/group/openwferu-users/browse_frm/thread/28a6938a6ba09c2d/c0468a68f7e79235 (in one of the gists there is a technique that, for "workitem rebuilding" asks the engine for the workitem and then fills it with the new info). This is one way of doing it. I hope this helps. In summary, no need to pause the engine, it's always between "apply" and "reply" calls, it's always waiting in some way. Best regards, -- John Mettraux - http://jmettraux.wordpress.com --~--~---------~--~----~------------~-------~--~----~ you received this message because you are subscribed to the "ruote users" group. to post : send email to [email protected] to unsubscribe : send email to [email protected] more options : http://groups.google.com/group/openwferu-users?hl=en -~----------~----~----~----~------~----~------~--~---
