On Sat, Jul 02, 2011 at 10:03:18PM +0200, Mario Camou wrote:
>
> The thing at the moment is that the Storage is persistent while the Hash is
> not. My view is that, either both should be persistent, or both
> non-persistent (or use timeouts if I continue with the current
> implementation - which I should be doing anyway). Because of what I said in
> the previous paragraph, I'm more inclined to make everything non-persistent.
>
> Ideas?
Hello Mario,
when your participant receives the workitem, does it know the id of the device
to to which it will send ? Your description implies that yes.
You could place that information in the workitem (and not in an in-memory
hash). When the receiver is handed a reply, you could look at the workitems and
find the one holding the same device id.
Here is a suggestion :
---8<---
class MyParticipant < Ruote::StorageParticipant
def consume(workitem)
msg = Message.new(workitem)
msg.emit()
workitem.fields['device_id'] = msg.device_id
super
# will place the workitem in the storage
end
end
class MyReceiver < Ruote::Receiver
def handle_message(msg)
workitem = @context.engine.storage_participant.find { |wi|
wi.fields['device_id'] == msg.device_id
}
@context.engine.storage_participant.proceed(workitem) if workitem
# reply to the engine, but via the storage participant, so that
# the workitem is removed from the 'list of waiting workitems'
end
end
--->8---
It could be slow when there are lots of workitems in storage participants, but
it's persistent.
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