On Wed, Jan 26, 2011 at 04:37:27AM -0800, Mario Camou wrote:
>
> OK, so I create my own Receiver (perhaps inheriting from 
> RuoteAMQP::Receiver) and in there I can do whatever I want. As far as 
> "correlation" is concerned, what I need to do is, find out the FEI to which 
> to send the incoming data, get the workitem associated with that FEI, and 
> plug in the data from the message.
> 
> Outbound messages get handled by my own Participant which needs to 
> coordinate with the Receiver, perhaps storing the data needed for 
> correlation somewhere where the Receiver can find it (perhaps a global Hash 
> table, a database, or in the quantum state of the Universe) and associate it 
> with the FEI. Correct?

Hello Mario,

yes. If you follow my suggestion, you'll notice that passing the fei avoids the 
need to map to a custom correlation id, the fei being the correlation id.

> Also, is there a way of searching through all the stored workitems, to do 
> the correlation? So, suppose the message comes with certain fields (for 
> example, "source_token" and "message_type") that need to match data inside 
> of the workitem (for example, fields called "expected_token" and 
> "expected_message_type"). In that case I could either store the 
> "expected_token" and "expected_message_type" someplace and associated with 
> the FEI, so the Receiver can get at them, or have the Receiver search the 
> stored workitems to find the FEI. What would be the preferred way of doing 
> this?

Re-working my previous sample :

---8<---
class MarioReceiver

  def handle(msg)

    correlation_id = extract_correlation_id(msg)

    expressions = @engine.processes.collect { |process_status|
      process_status.expressions.select { |expression|
        expression.class == Ruote::Exp::ParticipantExpression
      }
    }.flatten

    expression = expressions.find { |exp|
      exp.h.applied_workitem['fields']['correlation_id'] == correlation_id
    }

    raise "not found" unless expression

    workitem = Ruote::Workitem.new(expression.h.applied_workitem)

    reply_to_engine(workitem)
  end
end
--->8---

Something like that.

The problem : it goes through all the process instances... The fei as 
correlation id method is so much "direct"...

Now I could show you examples of how to store your correlation_id <-> fei 
mapping, but oh well...

"expected_token" could easily contain the fei, and "expected_message_type"... 
does it matter ? The receiver should just discard irrelevant messages before 
even thinking about correlation.


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

Reply via email to