qpid-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robbie Gemmell <robbie.gemm...@gmail.com>
Subject Re: Creation of Request and Response quese
Date Sun, 22 Apr 2012 20:28:25 GMT
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 <subha.manjunath@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


Mime
View raw message