You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by sreekar <tr...@gmail.com> on 2012/04/12 13:00:54 UTC

Can we connect multiple connection for the same destination ?

Hi Team,

The following question might sound stupid, but need a confirmation to
proceed further in my task, without any qualms.

Can we have multiple connections connecting to the same destination?

Let us say there are 3 process SS1, SS2 & SS3 which needs to communicate to
SR1, SR2 & SR3.

Can i create 3 new connections for same destination (QUEUE)
(C1 for SS1 which starts producer P1...similarly (C2, P2) ==> SS2  and  (C3,
P3 ) ==> SS3) ?

Now the process SR1 will read the messages from QUEUE using C1 at
will......i.e whenever it wants any message :
==>  it will create a consumer thread 
==>  read the message from QUEUE
==>  finish the consumer thread (destroy the connection)
Whenever it (SR1) wants to read another message it creates another thread to
read the message.

Similar process will be followed by SR2 (using connection C2) and SR3 (using
connection C3).

The consuming order by services SR1, SR2 and SR3 might be in any order.

With ActiveMQ-CMS is it possible (or guaranteed) that we get our messages
separately for each process ?

===========================================================================
Suppose under one connection, i have created separate sessions with
different ACKNOWLEDGE Modes, for
separate process. Can i get the messages destined for each process
separately  (without any inter-mixing) ?


To sum-up make long story short,
Can we get messages separately (#1 for each connection.....#2 for each
session under same connection) without any intermixing...(i.e Messages
received by wrong consumer of different connection (or) session) ?

Any help would be appreciable.

Thanks & Regards,
Sreekar



--
View this message in context: http://activemq.2283324.n4.nabble.com/Can-we-connect-multiple-connection-for-the-same-destination-tp4551545p4551545.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Can we connect multiple connection for the same destination ?

Posted by sreekar <tr...@gmail.com>.
Hi Mick,

Yes you are correct.

> A major value of a JMS broker is when there are any number of clients or
> indeed none 
> (who don't need to know about each other's existence) sending to and
> receiving from a Destination.

I am trying to use it, by violating it major principle.

Thank you very much for responding and clarifying my doubts.

We are creating the producer and consumer process from the *session*. So i
thought if we use same session, there might be a chance of one-to-one
correspondence between producer Vs consumer.

ActiveMQ might be able to support (as an additional feature) this type of
(producer Vs consumer) mapping (i might be GREEDY to think like
that.......violate the basic advantage of QUEUE for the sake of an
additional feature........definitely GREEDY), but that might (most probably
will) significantly degrade the performance of ActiveMQ.

Once again many thanks for your inputs which put my thoughts on the right
track.

Thanks & Regards,
Sreekar

--
View this message in context: http://activemq.2283324.n4.nabble.com/Can-we-connect-multiple-connection-for-the-same-destination-tp4551545p4573017.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Can we connect multiple connection for the same destination ?

Posted by mickhayes <mi...@gmail.com>.
For a small no. of such pairs, with a reasonably static existence, I would
use a Destination per pair.

I hope it's not heresy here to suggest that maybe what you need is RMI
rather than JMS. A major value of a JMS broker is when there are any number
of clients or indeed none (who don't need to know about each other's
existence) sending to and receiving from a Destination.

To answer your questions about connection handle etc., basically it's all
about the JMS Destination. In the simplest case, subscribers to a
Destination can receive messages which have been produced onto that
Destination.

If you want to each consumer to fish "his own" messages from a single queue,
there are multiple ways of doing that, but it means each message must carry
some form of routing information.


-----
Michael Hayes B.Sc. (NUI), M.Sc. (DCU), SCSA SCNA 

--
View this message in context: http://activemq.2283324.n4.nabble.com/Can-we-connect-multiple-connection-for-the-same-destination-tp4551545p4571006.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Can we connect multiple connection for the same destination ?

Posted by sreekar <tr...@gmail.com>.
Hi Mickhayes,

> I think that if you draw the picture for what you have described, you will
> see that you are trying to share > a JMS Connection CX between your
> producing process (JMS client) SSX and a different consuming process > SRX
> (a different JMS Client).

> Process SS1 cannot have the the same JMS Connection C1 as a different
> process SR1.

> I think you might be proposing using a single Queue Destination to pass
> messages from each SSX to its 
> counterpart SRX, with each consumer only getting the messages produced by
> its counterpart producer.

> Can you clarify if this is what you are trying to achieve?

*Yes, this is exactly what i intend to achieve.*

We have a simple API to read the message
*read_queue (queue_handle, ack_mode, char* msg_holder);*
*queue_handle* : mapping which stores the connection_info, session_info,
session_mode
*ack_mode*      : whether using session_transacted or not
*msg_holder*    :  holds the message read from the queue

The above API can be called from any other application process.
((which stores the queue [[connection]] handle information ))

My doubt when i use the same connection handle.........same connection, same
session (opened in same mode [with which producer sent messages])....*will i
get only those messages (messages sent using that particular session* ?

I have 2 producers P1 & P2.

Scenario 1 :
~~~~~~~~
P1 and P2 are created from connections C1 and C2, which pumps messages to
same QUEUE.
Conn1 stores info of (C1, sesion1, session1_mode, destination,
P1).......when i create a consumer using session1 (in session1_mode)
........will i get only the messages sent by P1 ? or is there a chance to
receive messages sent by P2 (other connection) as well ?

Scenario 2 :
~~~~~~~~
P1 and P2 are created using the same connection, same session.

P1 created with session in AUTO_ACK Mode.
P2 created with session in SESSION_TRANSACTED Mode.

When i create the corresponding consumers, will they receive the messages
sent by the  corresponding producers ?

Hope i made my self clear.

> Note the first Anti-Pattern, the "Single-Purpose Queue" in the O'Reilly
> JMS book, 2ed in Chapter 11 
> "Messaging Design Considerations." 

I have read the above section.
The code which we are (were) using is a Legacy one and i am trying to
replace the queue mechanism for IPC with Active MQ.

Creating a separate Queue for each process will be very good idea, but my
architect wanted to explore all the options available.

Thanks for the response.

Please let me know your comments.

Thanks & Regards,
Sreekar

--
View this message in context: http://activemq.2283324.n4.nabble.com/Can-we-connect-multiple-connection-for-the-same-destination-tp4551545p4570428.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Can we connect multiple connection for the same destination ?

Posted by mickhayes <mi...@gmail.com>.
I /think /that if you draw the picture for what you have described, you will
see that you are trying to share a JMS Connection *CX *between your
producing process (JMS client) *SSX *and a different consuming process *SRX
*(a different JMS Client).

Process SS1 cannot have the the same JMS Connection C1 as a different
process SR1.

I think you might be proposing using a single Queue Destination to pass
messages from each SSX to its counterpart SRX, with each consumer only
getting the messages produced by its counterpart producer.

Can you clarify if this is what you are trying to achieve? 

Note the first Anti-Pattern, the "Single-Purpose Queue" in the O'Reilly JMS
book, 2ed in Chapter 11 "Messaging Design Considerations."





-----
Michael Hayes B.Sc. (NUI), M.Sc. (DCU), SCSA SCNA 

--
View this message in context: http://activemq.2283324.n4.nabble.com/Can-we-connect-multiple-connection-for-the-same-destination-tp4551545p4564321.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.