On Mon, Feb 24, 2014 at 8:37 AM, Ken Giusti <kgiu...@redhat.com> wrote:

> +1 this question - I've never quite understood Messenger's current
> behavior w.r.t. setting the source and target to the same value.
>

I don't think there is a good reason, I think it's just an accident of
history.


>
> As far as interpreting the behavior of a subscription, and the interaction
> with the API, I would think the most 'natural' approach would be:
>
> sub = M.subscribe("amqp://~0.0.0.0/name") would imply:
>
> > > "I am a service called 'name'
> > > and I wish to begin receiving messages"
>
> and
>
> sub = M.subscribe("amqp://0.0.0.0/name") would imply:
>
> > > "I wish to receive messages
> > > from a node called 'name'".
>
> As the ~ causes Messenger to open a TCP listener on the address, and the
> absence of ~ causes Messenger to initiate a connection attempt to the
> address.
>
> In the two cases, I agree with Ted's point that only the Target or Source
> should be set.  My opinion: set them based on the subscription's mode:
> Target should be set in the case of ~, Source in the case of !~.
>
> Thoughts?
>

When a ~ is used messenger is not the one establishing the link, the remote
peer establishes the link so it's the remote peer that is going to end up
supplying the source and target. Currently messenger just copies whatever
the remote peer supplies and proceeds to pass through any and all incoming
messages.

As for the original question, in the general case we need to think about
local terminus/remote terminus rather than source/target as messenger has
similar behaviour for outgoing links as well as incoming links. This is
even true for ~ URLs since you can send messages to them and they will get
held in the messenger's message store until someone connects and grabs them.

Given that in many respects messenger will behave like an embedded broker
rather than just a simple client, it would in some sense be consistent for
messenger to set the local terminus to the name of the messenger unless
otherwise overridden. This is consistent with what a broker would do, e.g.
when a broker sends messages from a queue, the local terminus is the name
of the queue, when a broker receives messages into a queue, the local
terminus is still the name of the queue.

Regardless of the default though, I think we probably need a mechanism for
explicitly controlling both ends, e.g. something like
M.subscribe("source->target") for when you want a non default target.

--Rafael

Reply via email to