Hi John,

Thanks for your reply.

Solution no 2 worked for me

but there was a catch : recycled object error

I was saving the object_id of the process handle and using in cancel

but sometimes I get Recycled Object error.

could you tell me some other workaround for it.

Thanks,
Rashi

On Thu, Jul 26, 2012 at 4:29 PM, John Mettraux <[email protected]> wrote:

>
> On Thu, Jul 26, 2012 at 04:05:27PM +0530, Rashi Gupta wrote:
> >
> > I am using Ruote 2.2.0
> >
> > class ParticipantTest
> >   include Ruote::LocalParticipant
> >
> >   def initialize (options)
> >     @options = options
> >   end
> >
> >   def consume (workitem)
> >
> >     # some long running process
> >
> >     @handle = long_running_process(r)
> >
> >     reply_to_engine(workitem)
> >   end
> >
> >   def cancel(fei, flavour)
> >
> >     # cancel long running process using @handle ???
> >   end
> > end
>
> Hello Rashi,
>
> I'd say you have to flip the issue. Since you seem to be in control of
> "long_running_process"...
>
> ---8<---
> #
> # Hypothetical API for Rashi's "long running processes"
> #
> module LongProcessRunner
>   def self.run(id, process_name)
>     #  ...
>   end
>   def self.cancel(id)
>     # ...
>   end
> end
>
> class ParticipantTest
>   include Ruote::LocalParticipant
>
>   def initialize (options)
>
>     @options = options
>   end
>
>   def consume (workitem)
>     LongProcessRunner.run(
>       workitem.fei.to_storage_id,
>       workitem.fields['long_process_name'])
>     reply_to_engine(workitem)
>   end
>
>   def cancel(fei, flavour)
>     LongProcessRunner.cancel(fei.to_strorage_id)
>   end
> end
> --->8---
>
> Here, you force the id on the LongProcessRunner and you thus use the
> workitem's fei (FlowExpressionId, the unique identifier for the workitem)
> as
> the id for the long running process.
>
> If you cannot do that, then use some database model:
>
> ---8<---
> class ParticipantTest
>   include Ruote::LocalParticipant
>
>   def initialize (options)
>
>     @options = options
>   end
>
>   def consume (workitem)
>
>     handle = long_running_process(r)
>     ProcessHandle.create(workitem.fei, handle)
>
>     reply_to_engine(workitem)
>   end
>
>   def cancel(fei, flavour)
>
>     handle = ProcessHandle.find(fei)
>
>     cancel_long_running_process(handle)
>   end
> end
> --->8---
>
> If none of those options are possible for you, please tell me and I'll show
> you a third technique.
>
>
> I hope it will help. 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 "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

Reply via email to