On Thu, Apr 04, 2013 at 08:51:55AM -0700, Adrien Kohlbecker wrote: > > We are still slowly migrating our receipt processing to ruote and we hit > the following roadblock : > > We have a master process, launched by an API call from the user > Right after that call, the user uploads one or more pictures > asynchronously. Each picture is processed independently. > After each picture is processed, the master process should resume > > I was looking at the way you implemented AlertParticipant in ruote-amqp but > I don't think it works for our use case : > > - The pictures could finish uploading in two month, if the user closes our > app and does not reopen it right away, or in the worst case never, if the > user never reopens the app, so we can't have each AlertParticipant polling > a queue until uploaded > > - If the user is on a fast connection, the upload could finish before our > backend has had time to launch the master process, so we need a way to > cache the notifications until they are ready to be processed. > > The issue here is that the subprocess is not launched by ruote so there is > no workitem to store and receive once the upload is done (especially since > the reply could happen before any workitem exists) > > How would you go about implementing something like that ?
Hello Adrien, how do you correlate the pictures and the main process? I guess there is some kind of shared identifier. You could start the process after the picture upload. Ok, it doesn't work if you want the user to deal with the process while the pictures load... Back to the equivalent of an AlertParticipant. How about placing a timeout attribute on it? http://ruote.rubyforge.org/common_attributes.html#timeout This could help solve the "it took 2 months" issue. That doesn't solve the "it's already here" one. What about having a participant that looks like: ``` class ImageGrabber < Ruote::Participant def on_workitem # somehow a blocking call... # returns as soon as the pictures are done uploading # returns immediately if the pictures are already uploaded # workitem.fields['images'] = ImageUploadService.fetch_uris(case_id) reply end # probably called on_timeout # def on_cancel # kills the pending .fetch_uris if present # ImageUploadService.stop_fetching_uris(case_id) end protected # use the ruote wfid as correlation id # def case_id workitem.wfid end end ``` ? The pictures are uploaded somewhere in some service. Let's communicate with that service. You could also bypass the "let's wait for the pictures to upload" participant and consider that the pictures are there (unless you do OCR, the pictures are probably not worth much for the application). You could complain later on, when you notice that the pictures are not here yet. I guess the trick is not to wait for some notifications about the images, but to poll for them. Could that participant be summarized as "wait until the pictures are uploaded"? <parentheses> Ruote is not meant to build wizards, you'd better gather all the info for the launch step and then launch. The same can be said for any "human" step, Trying to piggyback a ruote process with a web wizard is hard. Having a dedicated screen (set of screens) for a ruote "human" step is better. ``` sequence do fill_in_form_details end ``` is better than ``` sequence do fill_in_form_name fill_in_form_address fill_in_form_whatever # ... end ``` Of course, that second flow makes sense if the human participant is different at each step... </parentheses> Ah, a warning, do not put the pictures themselves in the workitem or in queue messages, place the URIs or whatever id of the picture. Sorry, it may already be obvious to you. I hope that this confusing mix will help anyway, best regards, -- John Mettraux - http://lambda.io/jmettraux -- -- 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 --- You received this message because you are subscribed to the Google Groups "ruote" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
