You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by SlomanShield <sl...@gmail.com> on 2018/09/19 02:43:15 UTC

Guarantee delivery response message to origin producer

So i am reading and one thing I am trying to look for is. If i have a
multiple producers and multiple consumers. When the producer sends a message
with a correlation ID and the consumer receives the message and responds
back with the same correlation ID will the broker return the message back to
the producer that originated the message? 

I read up on correlation ID and I still can't seem to figure out if it is
possible or not. Another way i thought about it is if each producer creates
a unique correlation ID per message something like
sha512(hostname+ip+timeInNano+salt) then if the reply is with that
correlation ID it can only belong to 1 producer. 

Am i thinking about this right? 

Because the other method would be a counter on all the producer which means
the correlation IDs would overlap. 

Any insight would be much appreciated, thanks :)



--
Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-Dev-f2368404.html

Re: Guarantee delivery response message to origin producer

Posted by "michael.andre.pearce" <mi...@me.com.INVALID>.
I will repeat what Justin has asked, Please use the user list, stop using the dev list.
What is set is upto you in client code. I think Justins been clear on this. With this you need to code and manage this in your intermediate process B. 


Sent from my Samsung Galaxy smartphone.
-------- Original message --------From: SlomanShield <sl...@gmail.com> Date: 20/09/2018  04:10  (GMT+00:00) To: dev@activemq.apache.org Subject: Re: Guarantee delivery response message to origin producer 
Thanks! Now for a extra layer 

What if we have 3 clients 

A B and C

A has a temp queue, B now has a temp queue. 

A message is sent from A to B like you said but instead B takes the message
and forwards it to C.

B puts in the correlation ID from A and sets the  replyto its own temp
queue, does this override the replyto queue from A? Or is there some sort of
stack information within the message structure where the last destination
gets removed once the message is sent back as a reply kind of like a LIFO
type of thing. 



--
Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-Dev-f2368404.html

Re: Guarantee delivery response message to origin producer

Posted by SlomanShield <sl...@gmail.com>.
Thanks! Now for a extra layer 

What if we have 3 clients 

A B and C

A has a temp queue, B now has a temp queue. 

A message is sent from A to B like you said but instead B takes the message
and forwards it to C.

B puts in the correlation ID from A and sets the  replyto its own temp
queue, does this override the replyto queue from A? Or is there some sort of
stack information within the message structure where the last destination
gets removed once the message is sent back as a reply kind of like a LIFO
type of thing. 



--
Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-Dev-f2368404.html

Re: Guarantee delivery response message to origin producer

Posted by artnaseef <ar...@amlinv.com>.
Typically, the best way to accomplish request/reply is to use a temporary
queue.  Like this:

- JMS client A creates a temporary queue
- JMS client A produces message to request queue
  - On that message, the temporary queue is set as the JMSReplyTo using
javax.jms.Message.setJMSReplyTo()
- JMS client B consumes the request from the request queue
- JMS client B then produces a message to the temporary queue using
MessageProducer(requestMessage.getReplyTo(), replyMessage)

There are variations.  The good thing about temporary queues is that they
are automatically deleted by the broker when the client disconnects, so
there will never be idle messages sitting around.  If you need those
messages to remain until consumed, then switching to a permanent queue
that's dedicated to the client usually does the trick.

Hope this helps.

BTW, correlation ID can be used together with selectors to solve this. 
However, I would not recommend using selectors if they can be avoided at
all.



--
Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-Dev-f2368404.html

Re: Guarantee delivery response message to origin producer

Posted by Justin Bertram <jb...@apache.org>.
> So if client 2 sends "hello" with a correlation ID of unique UUID to
server 1 when server 1 sends the response will the broker know to send the
message back to client 2.

No.  As stated previously, the correlation ID is not used by the broker to
dispatch messages to clients.  I'm not exactly sure how to state the answer
to your question any more plainly than that.  Your original question was
sufficiently clear.


Justin

On Wed, Sep 19, 2018 at 5:17 PM SlomanShield <sl...@gmail.com> wrote:

> I'm sorry i guess my question was not clear. Basically what it boils down
> to,
> is if a client sets a correlation ID that is unique and sends a message.
> When the server responds will the broker know based on the correlation ID
> which client sent the data. i.e
>
> client/producer 1: 192.168.1.2
>
> client/producer 2: 192.168.1.3
>
> consumer/server 1: 192.168.1.4
>
> consumer/server 2: 192.168.1.5
>
> Broker: 192.168.1.6
>
> Queue name: TestQueue
>
> In this example if all clients are sending messages (and listening on temp
> queues for responses) to the servers with unique correlation IDs. When the
> server sends the response will it go to the client at originated the
> message.
>
> So if client 2 sends "hello" with a correlation ID of unique UUID to server
> 1 when server 1 sends the response will the broker know to send the message
> back to client 2.
>
> Thanks
>
> PS thanks for the heads up ill post anymore new questions I have on the
> other board :)
>
>
>
> --
> Sent from:
> http://activemq.2283324.n4.nabble.com/ActiveMQ-Dev-f2368404.html
>

Re: Guarantee delivery response message to origin producer

Posted by SlomanShield <sl...@gmail.com>.
I'm sorry i guess my question was not clear. Basically what it boils down to,
is if a client sets a correlation ID that is unique and sends a message.
When the server responds will the broker know based on the correlation ID
which client sent the data. i.e

client/producer 1: 192.168.1.2

client/producer 2: 192.168.1.3

consumer/server 1: 192.168.1.4

consumer/server 2: 192.168.1.5

Broker: 192.168.1.6

Queue name: TestQueue 

In this example if all clients are sending messages (and listening on temp
queues for responses) to the servers with unique correlation IDs. When the
server sends the response will it go to the client at originated the
message.

So if client 2 sends "hello" with a correlation ID of unique UUID to server
1 when server 1 sends the response will the broker know to send the message
back to client 2. 

Thanks

PS thanks for the heads up ill post anymore new questions I have on the
other board :)



--
Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-Dev-f2368404.html

Re: Guarantee delivery response message to origin producer

Posted by Justin Bertram <jb...@apache.org>.
The correlation ID is not used by the broker to dispatch messages to
clients.  The correlation ID is set by a client and can be used in a
client's selector to implement a request-response pattern.  There's lots of
documentation about this on the Internet.

For what it's worth, messages are never sent to producers.  Message are
only sent to consumers.

In the future please put questions like on the user list rather than
developer list.  The developer list is for discussions about the
development of the broker itself.


Justin

On Wed, Sep 19, 2018 at 7:43 AM SlomanShield <sl...@gmail.com> wrote:

> So i am reading and one thing I am trying to look for is. If i have a
> multiple producers and multiple consumers. When the producer sends a
> message
> with a correlation ID and the consumer receives the message and responds
> back with the same correlation ID will the broker return the message back
> to
> the producer that originated the message?
>
> I read up on correlation ID and I still can't seem to figure out if it is
> possible or not. Another way i thought about it is if each producer creates
> a unique correlation ID per message something like
> sha512(hostname+ip+timeInNano+salt) then if the reply is with that
> correlation ID it can only belong to 1 producer.
>
> Am i thinking about this right?
>
> Because the other method would be a counter on all the producer which means
> the correlation IDs would overlap.
>
> Any insight would be much appreciated, thanks :)
>
>
>
> --
> Sent from:
> http://activemq.2283324.n4.nabble.com/ActiveMQ-Dev-f2368404.html
>