You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@qpid.apache.org by Sumi <su...@newedge.com> on 2012/04/19 07:32:14 UTC

Creation of Request and Response quese

Hi,
I am very new to Qpid , How do i create Request and response queues 
For ex:request queue , durable , direct exchange
"response queue" : is an temporary queue and what should be my reply to
property and how to bind these two queues so that when my producer  send
message to request queue , the consumer should be able to recieve from the
response queue ? Please help this might be basic question  but i am very new
to qpid and have been asked to create req , response queues?

--
View this message in context: http://qpid.2158936.n2.nabble.com/Creation-of-Request-and-Response-quese-tp7479418p7479418.html
Sent from the Apache Qpid users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org


Re: Creation of Request and Response quese

Posted by Jakub Scholz <ja...@scholz.cz>.
Hi Sumi,

I think the attached code snippet does pretty much what you need using
the JMS API. The reply to address is set as a property to the request
message in the step 6 (to the destination specified in a properties
file). The creation of the temporary response queue and its binding to
the response exchange is done when creating the receiver in step 4. It
is encoded in the destination.

/*
 * Step 1: Initializing the context based on the properties file
 */
Properties properties = new Properties();
InitialContext ctx;

properties.load(new FileInputStream("examples.properties"));
ctx = new InitialContext(properties);

/*
 * Step 2: Preparing the connection and session
 */
ConnectionFactory fact = (ConnectionFactory) ctx.lookup("connection");
Connection conn;
Session sess;
conn = fact.createConnection();
sess = conn.createSession(false, Session.CLIENT_ACKNOWLEDGE);

/*
 * Step 3: Creating a producer
 */
Destination requestDestination = (Destination) ctx.lookup("requestAddress");
MessageProducer requestProducer;
requestProducer = sess.createProducer(requestDestination);

/*
 * Step 4: Creating a broadcast receiver / consumer
 */
Destination responseDest = (Destination) ctx.lookup("responseAddress");
MessageConsumer responseConsumer;
responseConsumer = sess.createConsumer(responseDest);

/*
 * Step 5: Starting the connection
 */
conn.start();

/*
 * Step 6: Sending a request
 */
TextMessage message = sess.createTextMessage("<FIXML>...</FIXML>");
message.setJMSReplyTo((Destination) ctx.lookup("replyAddress"));
requestProducer.send(message);
System.out.println();
System.out.println("MESSAGE SENT:");
System.out.println("#############");
System.out.println(message.toString());
System.out.println();

/*
 * Step 7: Receiving responses - waiting 10 seconds
 */
Message msg = responseConsumer.receive(10000);
System.out.println(msg.toString());

/*
 * Step 8: Closing the connection
 */
requestProducer.close();
sess.close();
conn.close();

The example.properties file should contain something like this:

java.naming.factory.initial =
org.apache.qpid.jndi.PropertiesFileInitialContextFactory

# connectionfactory.[jndiname] = [ConnectionURL]
connectionfactory.connection =
amqp://user1:pass1@client1/?brokerlist='tcp://amqp-broker:5672'

# destination.[jndiname] = [address_string]
destination.requestAddress = request_exchange/request_rtg_key; { node:
{ type: topic }, create: never }
destination.replyAddress = response_exchange/response_rtg_key; {
create: receiver, node: {type: topic } }
destination.responseAddress = response_queue; {create: receiver,
assert: never, node: { type: queue, x-declare: { auto-delete: true,
exclusive: false, arguments: {'qpid.policy_type': ring,
'qpid.max_count': 1000, 'qpid.max_size': 1024000}}, x-bindings:
[{exchange: 'response_exchange', queue: 'response_queue', key:
'response_rtg_key'}]}}

I hope this helps you ...

Regards
Jakub

On Fri, Apr 20, 2012 at 05:22, Sumi <su...@newedge.com> wrote:
> Hi Robbie ,
> Thank you , I am using Qpid -Java client (Qpid 0.14) , I will paste my
> requirement , might be i have not understood the requirement clearly
> Broker at realtime i would be connecting to AMQP broker
> 1.Existing objects in the broker - request exchange: "request.exchange"
> ,request queue: "req.queue"
> response exchange: "xxx.response"
>
> 2. Client creates response queue : xxx.tmp.response.queue
>
> 3. Client creates binding between response queue and response exchange
> binding key: test_routing_key
>
> 4. Client sends request to request exchange routing key of the request
> message (required): XXXXX.rk
> value of the reply-to exchange property of the request message: xxx.response
> value of the reply-to routing key property of the request message:
> test_routing_key
>
> 5. Server sends response
> routing key in the response message: test_routing_key
>
> Request exchange is Direct exchange
>
> For now i have created as below
> Producer code:
> private AMQShortString requestQueue = new AMQShortString("message_queue1");
> private AMQShortString routingKey = new AMQShortString("test_routing_key");
> private AMQShortString exchange = new AMQShortString("message_exchange1");
>
> AMQDestination destinationQueue = new AMQQueue(exchange, routingKey,
> requestQueue);
> //Bind queue
>                        session.bindQueue(requestQueue, destinationQueue.getRoutingKey(),
>                                        arguments, destinationQueue.getExchangeName(),
>                                        destinationQueue);
> and create producer to send the message
>
> My question is what should be the reply to property
> how to create reply to destination .
>
> And at my consumer class am creating  queue
> private AMQShortString responseQueue = new AMQShortString("response.queue");
> private AMQShortString routingKey = new AMQShortString("test_routing_key");
> private AMQShortString exchange = new AMQShortString("message_exchange1");
>
> session.sendCreateQueue(responseQueue, false, true, false, map);
> AMQDestination destinationQueue = new AMQQueue(exchange, routingKey,
> responseQueue);
>
> Now here i wanted to create temporary queue and give it a name , but in new
> qpid i have read that the name cannot be set and the broker creates by
> itself ,
> How to create temporary queue with name ?
> AMQQueue queue = new AMQQueue("response.exchange", "response_queue",
> Boolean.TRUE);
> this code returns null when i try to create temporary queue .. Please help
> !!!!!
>
> This is urgent task , am working on this from past one week still not
> arrived at exact solution , hence posting all the details . Please help .
> Any other info required on this please let me know
>
> Thanks
> Sumi
>
>
> --
> View this message in context: http://qpid.2158936.n2.nabble.com/Creation-of-Request-and-Response-quese-tp7479418p7483017.html
> Sent from the Apache Qpid users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
> For additional commands, e-mail: users-help@qpid.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org


Re: Creation of Request and Response quese

Posted by Sumi <su...@newedge.com>.
Hi Robbie /Jakub,
Thank you so  much , The code you have provided helped me a lotttt . 
I am sorry for the delay , as i got to test the code today because last two
days we were stuck in getting the connection and ssl certificate stuff up
and running....

Frase , you were right i was digging into some thing else which was totally
irrelevant as i have niether used Qpid nor  JMS

Thanks for the links i will definetley go thru the JMS books

Robbie you're code really helped me to get the messages , Thank you so much

Regards
Sumi




--
View this message in context: http://qpid.2158936.n2.nabble.com/Creation-of-Request-and-Response-quese-tp7479418p7498535.html
Sent from the Apache Qpid users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org


Re: Qpid Federation and Failover Question

Posted by rfallon <ri...@atosorigin.com>.

Sorry (obviously) sent my message  to the wrong place.  Ignore my last post.

--
View this message in context: http://qpid.2158936.n2.nabble.com/Creation-of-Request-and-Response-quese-tp7479418p7491761.html
Sent from the Apache Qpid users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org


Qpid Federation and Failover Question

Posted by "Fallon, Richard" <ri...@atos.net>.

All,

I have been successfully using a federated network of Apache Qpid
brokers for some time now, we have had some problems along the way but
generally everything is working very well.  

I have a requirement to introduce more resilience to parts of the
network.  The (simplified) solution is this

"OPERATIONAL BEHAVIOUR"
1. SOURCE -> DESTINATION A : source sends messages to destination A
2. IF DESTINATION A FAILS THEN
3. 	SOURCE -> DESTINATION B : source sends messages to destination B

We have a piece of hardware between the brokers so we refer to the
destination with a generic value (e.g. DESTINATION) and this returns the
correct hostname of the destination (i.e. A OR B).

The above scenario works very well if the source is an amqp publisher,
e.g. a JMS Client using AMQP syntax.

However if the source and destinations are qpid brokers and connected
via a queue route this does not work.

Let me try and explain my rather bizarre results...

1. SOURCE BROKER -> DESTINATION BROKER (hostname = A) - connected
successfully
2. STOP DESTINATION BROKER (hostname = A) 
3. Load Balancer now returns  hostname=B for DESTINATION BROKER
4. SOURCE BROKER shows connection refused to DESTINATION BROKER 


So maybe I can understand the above, the SOURCE has created a socket
connection to hostname A, and is not releasing it.

However if I stop and start the SOURCE broker, and re add the queue
route using SOURCE and DESTINATION I still get the connection refused
message, but hostname = B is running.  It is like the SOURCE broker is
still trying to connect to the DESTINATION (hostname = A), even after
restart.  That suggests to me that Qpid persists some connection
information throughout a restart.

Does this sound plausible?  If so where would the connection info be
stored?  FYI - I'm using version 0.8.

Thanks in advance 

Richard


_______________________________________________________
Atos and Atos Consulting are trading names used by the Atos group.  The following trading entities are registered in England and Wales:  Atos IT Services UK Limited (registered number 01245534), Atos Consulting Limited (registered number 04312380) and Atos IT Solutions and Services Limited  (registered number 01203466) The registered office for each is at 4 Triton Square, Regents Place, London, NW1 3HG. The VAT No. for each is: GB232327983

This e-mail and the documents attached are confidential and intended solely for the addressee, and may contain confidential or privileged information.  If you receive this e-mail in error, you are not authorised to copy, disclose, use or retain it.  Please notify the sender immediately and delete this email from your systems.   As emails may be intercepted, amended or lost, they are not secure.  Atos therefore can accept no liability for any errors or their content.  Although Atos endeavours to maintain a virus-free network, we do not warrant that this transmission is virus-free and can accept no liability for any damages resulting from any virus transmitted. The risks are deemed to be accepted by everyone who communicates with Atos by email.
_______________________________________________________


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org


Re: Creation of Request and Response quese

Posted by Robbie Gemmell <ro...@gmail.com>.
Hi Sumi,

As alluded to by both Jakub and Fraser in their replies, you really
don't want to continue down the path of using underlying
implementation classes the way your code below does, you will end up
in a world of pain later on when the implementation changes or if you
want to change providers later. The Java client uses JMS as its API
and thats what you should stick to unless there is a very good reason
not to.

I have put together an example client/requester and server/responder
that should help you in undertaking the process outlined below. It
uses the exact values you specified in your email with one exception,
the request queue is name 'reqqueue' instead of 'req.queue'. I did
this because defining queues with dots in their name in the
virtualhosts.xml file of the Java broker is currently problematic due
to the structure of the XML and our usage of Commons Configuration.
You can also create + bind queues (and more) via the brokers JMX
management interface which should successfully let you define the
'req.queue' variant if needed, but I wanted to provide an out-the-box
example using the xml configuration. You can find a copy of the source
and a matching virtualhosts.xml configuration file for the broker (to
define the request+response exchanges and the request queue) at the
following URL:

http://people.apache.org/~robbie/qpid/qpid-users/multi_exchange_req_resp_apr2012/

It is worth noting that this example of request-response is more
complicated than most (requiring different Destination objects for
sending and receiving the requests, as well as different destination
objects for setting the requests reply-to and actually consuming from
the reply queue) due to the use of routing keys which arent simply the
associated queue name. I see you mentioned 'existing objects in the
broker' which suggests you will ultimately be connecting to a
pre-existing service, but if you aren't then I would suggest
considering whether the mismatch between queue names and routing keys
is really necessary.

Robbie

On 20 April 2012 04:22, Sumi <su...@newedge.com> wrote:
> Hi Robbie ,
> Thank you , I am using Qpid -Java client (Qpid 0.14) , I will paste my
> requirement , might be i have not understood the requirement clearly
> Broker at realtime i would be connecting to AMQP broker
> 1.Existing objects in the broker - request exchange: "request.exchange"
> ,request queue: "req.queue"
> response exchange: "xxx.response"
>
> 2. Client creates response queue : xxx.tmp.response.queue
>
> 3. Client creates binding between response queue and response exchange
> binding key: test_routing_key
>
> 4. Client sends request to request exchange routing key of the request
> message (required): XXXXX.rk
> value of the reply-to exchange property of the request message: xxx.response
> value of the reply-to routing key property of the request message:
> test_routing_key
>
> 5. Server sends response
> routing key in the response message: test_routing_key
>
> Request exchange is Direct exchange
>
> For now i have created as below
> Producer code:
> private AMQShortString requestQueue = new AMQShortString("message_queue1");
> private AMQShortString routingKey = new AMQShortString("test_routing_key");
> private AMQShortString exchange = new AMQShortString("message_exchange1");
>
> AMQDestination destinationQueue = new AMQQueue(exchange, routingKey,
> requestQueue);
> //Bind queue
>                        session.bindQueue(requestQueue, destinationQueue.getRoutingKey(),
>                                        arguments, destinationQueue.getExchangeName(),
>                                        destinationQueue);
> and create producer to send the message
>
> My question is what should be the reply to property
> how to create reply to destination .
>
> And at my consumer class am creating  queue
> private AMQShortString responseQueue = new AMQShortString("response.queue");
> private AMQShortString routingKey = new AMQShortString("test_routing_key");
> private AMQShortString exchange = new AMQShortString("message_exchange1");
>
> session.sendCreateQueue(responseQueue, false, true, false, map);
> AMQDestination destinationQueue = new AMQQueue(exchange, routingKey,
> responseQueue);
>
> Now here i wanted to create temporary queue and give it a name , but in new
> qpid i have read that the name cannot be set and the broker creates by
> itself ,
> How to create temporary queue with name ?
> AMQQueue queue = new AMQQueue("response.exchange", "response_queue",
> Boolean.TRUE);
> this code returns null when i try to create temporary queue .. Please help
> !!!!!
>
> This is urgent task , am working on this from past one week still not
> arrived at exact solution , hence posting all the details . Please help .
> Any other info required on this please let me know
>
> Thanks
> Sumi
>
>
> --
> View this message in context: http://qpid.2158936.n2.nabble.com/Creation-of-Request-and-Response-quese-tp7479418p7483017.html
> Sent from the Apache Qpid users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
> For additional commands, e-mail: users-help@qpid.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org


Re: Creation of Request and Response quese

Posted by Sumi <su...@newedge.com>.
Hi Robbie ,
Thank you , I am using Qpid -Java client (Qpid 0.14) , I will paste my
requirement , might be i have not understood the requirement clearly
Broker at realtime i would be connecting to AMQP broker
1.Existing objects in the broker - request exchange: "request.exchange"
,request queue: "req.queue"
response exchange: "xxx.response"

2. Client creates response queue : xxx.tmp.response.queue

3. Client creates binding between response queue and response exchange
binding key: test_routing_key

4. Client sends request to request exchange routing key of the request
message (required): XXXXX.rk
value of the reply-to exchange property of the request message: xxx.response
value of the reply-to routing key property of the request message:
test_routing_key

5. Server sends response 
routing key in the response message: test_routing_key

Request exchange is Direct exchange

For now i have created as below
Producer code:
private AMQShortString requestQueue = new AMQShortString("message_queue1");
private AMQShortString routingKey = new AMQShortString("test_routing_key");
private AMQShortString exchange = new AMQShortString("message_exchange1");

AMQDestination destinationQueue = new AMQQueue(exchange, routingKey,
requestQueue); 
//Bind queue
			session.bindQueue(requestQueue, destinationQueue.getRoutingKey(),
					arguments, destinationQueue.getExchangeName(),
					destinationQueue);
and create producer to send the message

My question is what should be the reply to property 
how to create reply to destination .

And at my consumer class am creating  queue
private AMQShortString responseQueue = new AMQShortString("response.queue");
private AMQShortString routingKey = new AMQShortString("test_routing_key");
private AMQShortString exchange = new AMQShortString("message_exchange1");

session.sendCreateQueue(responseQueue, false, true, false, map);
AMQDestination destinationQueue = new AMQQueue(exchange, routingKey,
responseQueue);

Now here i wanted to create temporary queue and give it a name , but in new
qpid i have read that the name cannot be set and the broker creates by
itself , 
How to create temporary queue with name ?
AMQQueue queue = new AMQQueue("response.exchange", "response_queue",
Boolean.TRUE);
this code returns null when i try to create temporary queue .. Please help
!!!!!

This is urgent task , am working on this from past one week still not
arrived at exact solution , hence posting all the details . Please help .
Any other info required on this please let me know

Thanks
Sumi


--
View this message in context: http://qpid.2158936.n2.nabble.com/Creation-of-Request-and-Response-quese-tp7479418p7483017.html
Sent from the Apache Qpid users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org


Re: Creation of Request and Response quese

Posted by Robbie Gemmell <ro...@gmail.com>.
Hi Sumi,

What client are you using (Java/ C++ etc)? Its hard to give you
particularly useful advice without first knowing this first as the
client APIs differ substantially.

Some further info that would help us advise you:

Do you really have a requirement that your request queue be bound to
an exchange with a binding key other than its name (that would seem
odd for traditional request/response) ?

It is entirely possible to do request/response with a single exchange,
do you really require that the request and response queues are bound
to different exchanges?

Regards,
Robbie

On 19 April 2012 06:32, Sumi <su...@newedge.com> wrote:
> Hi,
> I am very new to Qpid , How do i create Request and response queues
> For ex:request queue , durable , direct exchange
> "response queue" : is an temporary queue and what should be my reply to
> property and how to bind these two queues so that when my producer  send
> message to request queue , the consumer should be able to recieve from the
> response queue ? Please help this might be basic question  but i am very new
> to qpid and have been asked to create req , response queues?
>
> --
> View this message in context: http://qpid.2158936.n2.nabble.com/Creation-of-Request-and-Response-quese-tp7479418p7479418.html
> Sent from the Apache Qpid users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
> For additional commands, e-mail: users-help@qpid.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org


Re: Creation of Request and Response quese

Posted by Fraser Adams <fr...@blueyonder.co.uk>.
Hi Sumi,
I think that you may have misinterpreted what that thread was about, it 
didn't actually have anything to do with request/response at all (not 
sure how you inferred that really) anyway that thread related to qpid 
federation. You can federate between two brokers using a number of 
approaches (static exchange routes, dynamic exchange routes and queue 
routes) but you can't federate/link exchanges on the same broker. The 
point of that thread is that technically it's possible but qpid route 
prevents this (I commented out one line from qpid route and merrily 
connected traffic between a fanout exchange and two headers exchanges on 
the same broker).

None of that helps you of course, but I thought I'd explain.

On your particular problem, I've very much got a suspicion that you are 
digging yourself a massive hole. I've just noticed a post that you aimed 
at Robbie Gemmell you seem to have codeof this Ilk "

AMQDestination destinationQueue = new AMQQueue(exchange, routingKey,

"

You shouldn't really be using the low level Java Qpid code, the 
supported Java API for Qpid is JMS. Qpid is pretty JMS compliant (with a 
few quitks) and request/response code in Qpid follows standard JMS 
patterns using replyTo addresses, correlation IDs etc.

There's a good O'reilly book on JMS just called Java Message Service 
that's worth looking out for (see 
http://shop.oreilly.com/product/9780596522056.do) that has a link off to 
example code. It's worth spending a little time familiarising yourself 
with JMS (google JMS request reply or JMS request response is likely to 
be useful) I just did that and the second link could hopefully help you 
http://www.eaipatterns.com/RequestReplyJmsExample.html. This has some 
sample code that looks like a good start, though skimming through it the 
examples don't look completely self-contained.

This link looks useful too 
http://effectivemessaging.blogspot.co.uk/2009/01/request-respond-messaging.html


A basic pattern would go something like (for the case of a client making 
a request and getting a response)

     private MessageProducer _requester;
     private MessageConsumer _responder;
     private Connection      _connection;
     private Session         _syncSession;

..........
..........


             _syncSession = _connection.createSession(false, 
Session.AUTO_ACKNOWLEDGE);

     // In the createQueue calls below obviously use your own queue 
names..........

                 // Create a MessageProducer for the QMF direct address, 
mainly used for request/response
                 Destination directAddress = 
_syncSession.createQueue("qmf." + _domain + ".direct");
                 _requester = _syncSession.createProducer(directAddress);


                 // Create the JMSReplyTo _replyAddress and MessageConsumer
                 _replyAddress = _syncSession.createQueue(_address + 
syncReplyAddressOptions);
                 _responder = _syncSession.createConsumer(_replyAddress);
.........
.........

             MapMessage request = _syncSession.createMapMessage();
             request.setJMSReplyTo(_replyAddress);
             request.setStringProperty("x-amqp-0-10.app-id", "qmf2");
             request.setStringProperty("method", "request");
             request.setStringProperty("qmf.opcode", "_query_request");
             request.setStringProperty("qpid.subject", agentName);

             // Create a QMF Query for an "SCHEMA_ID" target
             request.setObject("_what", "SCHEMA_ID");

............
.............

             _requester.send(request);
             Message response = _responder.receive(_replyTimeout*1000);


HTH
Frase


On 19/04/12 12:01, Sumi wrote:
> Hi Frase,
> My query on Request response is very similar to you're post
> http://apache-qpid-users.2158936.n2.nabble.com/Connecting-exchanges-on-the-same-broker-tp6775844p6775844.html
>
> There are two exchanges already existing at AMQP broker. I need to send
> request to the Queue q binded(bk) to exchange y sends reposnse to exchange z
>
> Response must be an temporary queue and bound to exchange z
>
> Could you please tell how did you create request and response queues?????
>
> Thanks&  Regards
> Subha M
>
> --
> View this message in context: http://qpid.2158936.n2.nabble.com/Creation-of-Request-and-Response-quese-tp7479418p7480043.html
> Sent from the Apache Qpid users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
> For additional commands, e-mail: users-help@qpid.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org


Re: Creation of Request and Response quese

Posted by Sumi <su...@newedge.com>.
Hi Frase,
My query on Request response is very similar to you're post 
http://apache-qpid-users.2158936.n2.nabble.com/Connecting-exchanges-on-the-same-broker-tp6775844p6775844.html

There are two exchanges already existing at AMQP broker. I need to send
request to the Queue q binded(bk) to exchange y sends reposnse to exchange z

Response must be an temporary queue and bound to exchange z

Could you please tell how did you create request and response queues?????

Thanks & Regards
Subha M

--
View this message in context: http://qpid.2158936.n2.nabble.com/Creation-of-Request-and-Response-quese-tp7479418p7480043.html
Sent from the Apache Qpid users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org


Re: Creation of Request and Response quese

Posted by Sumi <su...@newedge.com>.
Hi Pavel,
Thank you , but this looks simple i have tried them works fine , i have read
lot about qpid , and amqp documents which has made me more confusing to
proceed . Am using Java Qpid Broker
My task is to send request to request queues , recieve respond from response
queue . The most confusing part is While sending the request the message
should contain Binding key(bk) and reply to property set to
exchange(xxxx.response) along with routing key (rk)

At client side Create an temporary queue(xxx.tmp.queue) 
create binding between xxxx.response and routing key (rk)
My question is in qpid broker how to create binding between request queue
and response exchange (xxxx.response) ?
in the Virtualhost.xml i have my request queue created having request
exchange (amq.direct)
<queue>requestQueue</queue>
<exchange>amq.direct</exchange>

Now how do i set the binding key? Should i create another exchange in
virtual host ?
Any one please clarify/help, once this done only i can proceed on
subscribing part !!!!!

Thanks in Advance


--
View this message in context: http://qpid.2158936.n2.nabble.com/Creation-of-Request-and-Response-quese-tp7479418p7479739.html
Sent from the Apache Qpid users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org


Re: Creation of Request and Response quese

Posted by Pavel Moravec <pm...@redhat.com>.
Hi Sumi,
it is enough to set reply-to in the message request and have a subscriber of that response queue. See attached C++ example program (its purpose is to send a QMF query to get some queue details and requesting to get the response to the given queue).

So the key commands are:

//create a receiver of the response queue; I recommend having there "{create:always, delete:always}" part to automatically create it now and delete it once the receiver is closed
Receiver r = session.createReceiver(<response-queue>);

//in the request message m, set reply-to
m.setReplyTo(Address(r.getName()));

(sending the request message)

//fetch / receive the response, wait for it at most 3 seconds
m = r.fetch(3 * Duration::SECOND);


To ensure unique and exclusive access to the response queue, it makes sense to have the queue named with some uuid (i.e. use uuid_generate method in C++) and to use exclusive queue (to grant the only access to the queue only for this subscriber).

Kind regards,
Pavel


----- Original Message -----
> From: "Sumi" <su...@newedge.com>
> To: users@qpid.apache.org
> Sent: Thursday, April 19, 2012 7:32:14 AM
> Subject: Creation of Request and Response quese
> 
> Hi,
> I am very new to Qpid , How do i create Request and response queues
> For ex:request queue , durable , direct exchange
> "response queue" : is an temporary queue and what should be my reply
> to
> property and how to bind these two queues so that when my producer
>  send
> message to request queue , the consumer should be able to recieve
> from the
> response queue ? Please help this might be basic question  but i am
> very new
> to qpid and have been asked to create req , response queues?
> 
> --
> View this message in context:
> http://qpid.2158936.n2.nabble.com/Creation-of-Request-and-Response-quese-tp7479418p7479418.html
> Sent from the Apache Qpid users mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
> For additional commands, e-mail: users-help@qpid.apache.org
> 
>