Hi Axyd,
I wrote a variation on your idea :
This variation uses a map user -> workitem, of course this is flawed,
since there could be multiple instances of this process each sending
an email to the same user...
The next variation assumes your mail service tracks a string
containing the identifier of the workitem/expression and it uses that
info when the answer comes back to retrieve the workitem and let the
engine resume :
Best regards,
--
John Mettraux - http://jmettraux.wordpress.com
Hi Axyd,
sorry, it's my fault. Your participant shouldn't reply to the engine
(I didn't think about that and was using BlockParticipant (Block as in
Ruby block of code, not blocking/stopping), which implicitely replies
to the engine. So you got it right by not using BlockParticipant and
not replying to the engine. Well done !
Calling reply lets the process continue, it's important not to reply
since you're waiting for answer from the real participant.
About the "not releasing" : the consume method should immediately exit
when it's done sending. The thread will be released as soon as the
consume method exits :
Once the participant has "consumed" the workitem, the engine is
supposed to sit and wait. Maybe what you experience as "doesn't
release its thread" is simply "the engine doesn't move until the reply
comes" which is the intended behaviour.
> The code for Sample (if you will be interested) is here:
> async_participant.rb http://docs.google.com/Doc?docid=dgpvsb45_10fm69kxhg&hl=en
> definitions.rb http://docs.google.com/Doc?docid=dgpvsb45_9ct4sdjgx&hl=en
> question.rb http://docs.google.com/Doc?docid=dgpvsb45_11dpxg5vd4&hl=en
> answer.rb http://docs.google.com/Doc?docid=dgpvsb45_12g7b2cvcj&hl=en
>
> First runs 'question.rb', prints the question on console and then
> exits.
> Then runs 'answer.rb', restores Engine from disk, and waits for user
> input on the console, then passes it to Engine.
>
> Should i call 'reply' twice (on send and on receive)? Or there is
> another way to release Thread? Or it's ok with it?
You should call once and only once (at receive time).
Your code looks good, I hope you're having fun implementing all of this.
Hi Axyd, thanks for the suggestion, I will write something about that,
you are right.
Hi Axyd, hi all,
I've started a piece of documentation at :
http://openwferu.rubyforge.org/part.html
feel free to comment / critique it here. The part on remote
participants / listeners is still a TODO.
Thanks again,