|
Hi,
Im using qpid-client 0.12, and need delete queue from JMS client. the queue is not auto delete regards -- Gastón Quezada |
|
Hi Gastón,
you can use QMF method "delete" with parameters "type" ("queue" in our case) and "name" (name of the queue). Here is the code snippet from C++ program I use: Connection connection(url/*, connectionOptions*/); try { connection.open(); Session session = connection.createSession(); Sender sender = session.createSender("qmf.default.direct/broker"); Address responseQueue("#reply-queue; {create:always, node:{x-declare:{auto-delete:true}}}"); Receiver receiver = session.createReceiver(responseQueue); Message message; Variant::Map content; Variant::Map OID; Variant::Map arguments; OID["_object_name"] = "org.apache.qpid.broker:broker:amqp-broker"; arguments["type"] = "queue"; arguments["name"] = queue_name; // a string of the queue name content["_object_id"] = OID; content["_method_name"] = "delete"; content["_arguments"] = arguments; encode(content, message); message.setReplyTo(responseQueue); message.setProperty("x-amqp-0-10.app-id", "qmf2"); message.setProperty("qmf.opcode", "_method_request"); sender.send(message, true); /* check response if the queue was properly deleted */ Message response; if (receiver.fetch(response,qpid::messaging::Duration(30000)) == true) { qpid::types::Variant::Map recv_props = response.getProperties(); if (recv_props["x-amqp-0-10.app-id"] == "qmf2") if (recv_props["qmf.opcode"] == "_method_response") std::cout << "Response: OK" << std::endl; else if (recv_props["qmf.opcode"] == "_exception") std::cerr << "Error: " << response.getContent() << std::endl; else std::cerr << "Invalid response received!" << std::endl; else std::cerr << "Invalid response not of qmf2 type received!" << std::endl; } else std::cout << "Timeout: No response received within 30 seconds!" << std::endl; connection.close(); return 0; } catch(const std::exception& error) { std::cout << error.what() << std::endl; connection.close(); } Kind regards, Pavel ----- Original Message ----- > From: "Gaston Quezada" <[hidden email]> > To: [hidden email] > Sent: Monday, December 5, 2011 9:14:10 PM > Subject: how to delete queue from jms client > > Hi, > > Im using qpid-client 0.12, and need delete queue from JMS client. > the queue is not auto delete > > regards > > -- > Gastón Quezada > --------------------------------------------------------------------- Apache Qpid - AMQP Messaging Implementation Project: http://qpid.apache.org Use/Interact: mailto:[hidden email] |
|
Here's some Java code for method invocation. This largely follows a
similar pattern to Pavel's C++ example. Note that this method is taken from a much larger QMF2 API that I've written ,so there's some dependencies on other classes (you won't be able to use it directly, but hopefully you'll get the idea especially with Pavel's code - you shouldn't need to tweak much MethodResult really just wraps a Map - see the QMF2 API specification). My QMF2 API stuff is actually finished, I've been promising to release it for weeks, but I've been writing a number of tools and utilities to demo it so I thought it'd be best to hold off until those are done. /** * Invoke the named method on the named Agent. * * @param agent the Agent to invoke the method on. * @param content an unordered set of key/value pairs comprising the method arguments. * @param replyHandle the correlation handle used to tie asynchronous method requests with responses * @param timeout the time to wait for a reply from the Agent, a value of -1 means use the default timeout * @return the method response Arguments in Map form */ public MethodResult invokeMethod(final Agent agent, final Map<String, Object> content, final String replyHandle, int timeout) throws QmfException { if (!agent.isActive()) { throw new QmfException("Called invokeMethod() with inactive agent"); } String agentName = agent.getName(); timeout = (timeout < 1) ? _replyTimeout : timeout; try { Destination destination = (replyHandle == null) ? _replyAddress : _asyncReplyAddress; MapMessage request = _syncSession.createMapMessage(); request.setJMSReplyTo(destination); request.setJMSCorrelationID(replyHandle); request.setStringProperty("x-amqp-0-10.app-id", "qmf2"); request.setStringProperty("method", "request"); request.setStringProperty("qmf.opcode", "_method_request"); request.setStringProperty("qpid.subject", agentName); for (Map.Entry<String, Object> entry : content.entrySet()) { request.setObject(entry.getKey(), entry.getValue()); } // Wrap request & response in synchronized block in case any other threads invoke a request // it would be somewhat unfortunate if their response got interleaved with ours!! synchronized(this) { _requester.send(request); if (replyHandle == null) { // If this is a synchronous request get the response Message response = _responder.receive(timeout*1000); if (response == null) { log.info("No response received in invokeMethod()"); throw new QmfException("No response received for Console.invokeMethod()"); } MethodResult result = new MethodResult(AMQPMessage.getMap(response)); QmfException exception = result.getQmfException(); if (exception != null) { throw exception; } return result; } } // If this is an asynchronous request return without waiting for a response return null; } catch (JMSException jmse) { log.info("JMSException {} caught in invokeMethod()", jmse.getMessage()); throw new QmfException(jmse.getMessage()); } } Pavel Moravec wrote: > Hi Gastón, > you can use QMF method "delete" with parameters "type" ("queue" in our case) and "name" (name of the queue). > > Here is the code snippet from C++ program I use: > > Connection connection(url/*, connectionOptions*/); > try { > connection.open(); > Session session = connection.createSession(); > Sender sender = session.createSender("qmf.default.direct/broker"); > Address responseQueue("#reply-queue; {create:always, node:{x-declare:{auto-delete:true}}}"); > Receiver receiver = session.createReceiver(responseQueue); > > Message message; > Variant::Map content; > Variant::Map OID; > Variant::Map arguments; > OID["_object_name"] = "org.apache.qpid.broker:broker:amqp-broker"; > arguments["type"] = "queue"; > arguments["name"] = queue_name; // a string of the queue name > > content["_object_id"] = OID; > content["_method_name"] = "delete"; > content["_arguments"] = arguments; > > encode(content, message); > message.setReplyTo(responseQueue); > message.setProperty("x-amqp-0-10.app-id", "qmf2"); > message.setProperty("qmf.opcode", "_method_request"); > > sender.send(message, true); > > /* check response if the queue was properly deleted */ > Message response; > if (receiver.fetch(response,qpid::messaging::Duration(30000)) == true) > { > qpid::types::Variant::Map recv_props = response.getProperties(); > if (recv_props["x-amqp-0-10.app-id"] == "qmf2") > if (recv_props["qmf.opcode"] == "_method_response") > std::cout << "Response: OK" << std::endl; > else if (recv_props["qmf.opcode"] == "_exception") > std::cerr << "Error: " << response.getContent() << std::endl; > else > std::cerr << "Invalid response received!" << std::endl; > else > std::cerr << "Invalid response not of qmf2 type received!" << std::endl; > } > else > std::cout << "Timeout: No response received within 30 seconds!" << std::endl; > > connection.close(); > return 0; > } catch(const std::exception& error) { > std::cout << error.what() << std::endl; > connection.close(); > } > > > > Kind regards, > Pavel > > ----- Original Message ----- > >> From: "Gaston Quezada" <[hidden email]> >> To: [hidden email] >> Sent: Monday, December 5, 2011 9:14:10 PM >> Subject: how to delete queue from jms client >> >> Hi, >> >> Im using qpid-client 0.12, and need delete queue from JMS client. >> the queue is not auto delete >> >> regards >> >> -- >> Gastón Quezada >> >> > > --------------------------------------------------------------------- > Apache Qpid - AMQP Messaging Implementation > Project: http://qpid.apache.org > Use/Interact: mailto:[hidden email] > > > --------------------------------------------------------------------- Apache Qpid - AMQP Messaging Implementation Project: http://qpid.apache.org Use/Interact: mailto:[hidden email] |
|
Dear Fraser,
I need to configure the auto-delete arguments, with this parameter: arguments:{'qpid.auto_delete_timeout':120} When I create the queue, the logs show a empty field argument. Log: main 2011-12-06 15:45:54,562 DEBUG [apache.qpid.transport.Connection] SEND: [conn:db23f1] ch=0 id=2 QueueDeclare(queue=10.2.60.69-1671711, alternateExchange=, autoDelete=true, arguments={}) Thanks you for your help, 2011/12/6 Fraser Adams <[hidden email]> > Here's some Java code for method invocation. This largely follows a > similar pattern to Pavel's C++ example. Note that this method is taken from > a much larger QMF2 API that I've written ,so there's some dependencies on > other classes (you won't be able to use it directly, but hopefully you'll > get the idea especially with Pavel's code - you shouldn't need to tweak > much MethodResult really just wraps a Map - see the QMF2 API > specification). My QMF2 API stuff is actually finished, I've been promising > to release it for weeks, but I've been writing a number of tools and > utilities to demo it so I thought it'd be best to hold off until those are > done. > > /** > * Invoke the named method on the named Agent. > * > * @param agent the Agent to invoke the method on. > * @param content an unordered set of key/value pairs comprising the > method arguments. > * @param replyHandle the correlation handle used to tie asynchronous > method requests with responses > * @param timeout the time to wait for a reply from the Agent, a value > of -1 means use the default timeout > * @return the method response Arguments in Map form > */ > public MethodResult invokeMethod(final Agent agent, final Map<String, > Object> content, > final String replyHandle, int timeout) > throws QmfException > { > if (!agent.isActive()) > { > throw new QmfException("Called invokeMethod() with inactive > agent"); > } > String agentName = agent.getName(); > timeout = (timeout < 1) ? _replyTimeout : timeout; > try > { > Destination destination = (replyHandle == null) ? _replyAddress > : _asyncReplyAddress; > MapMessage request = _syncSession.createMapMessage(**); > request.setJMSReplyTo(**destination); > request.setJMSCorrelationID(**replyHandle); > request.setStringProperty("x-**amqp-0-10.app-id", "qmf2"); > request.setStringProperty("**method", "request"); > request.setStringProperty("**qmf.opcode", "_method_request"); > request.setStringProperty("**qpid.subject", agentName); > > for (Map.Entry<String, Object> entry : content.entrySet()) > { > request.setObject(entry.**getKey(), entry.getValue()); > } > > // Wrap request & response in synchronized block in case any > other threads invoke a request > // it would be somewhat unfortunate if their response got > interleaved with ours!! > synchronized(this) > { > _requester.send(request); > if (replyHandle == null) > { // If this is a synchronous request get the response > Message response = _responder.receive(timeout***1000); > if (response == null) > { > log.info("No response received in invokeMethod()"); > throw new QmfException("No response received for > Console.invokeMethod()"); > } > MethodResult result = new MethodResult(AMQPMessage.** > getMap(response)); > QmfException exception = result.getQmfException(); > if (exception != null) > { > throw exception; > } > return result; > } > } > // If this is an asynchronous request return without waiting for > a response > return null; > } > catch (JMSException jmse) > { > log.info("JMSException {} caught in invokeMethod()", > jmse.getMessage()); > throw new QmfException(jmse.getMessage()**); > > } > } > > > > Pavel Moravec wrote: > >> Hi Gastón, >> you can use QMF method "delete" with parameters "type" ("queue" in our >> case) and "name" (name of the queue). >> >> Here is the code snippet from C++ program I use: >> >> Connection connection(url/*, connectionOptions*/); >> try { >> connection.open(); >> Session session = connection.createSession(); >> Sender sender = session.createSender("qmf.** >> default.direct/broker"); >> Address responseQueue("#reply-queue; {create:always, >> node:{x-declare:{auto-delete:**true}}}"); >> Receiver receiver = session.createReceiver(**responseQueue); >> >> Message message; >> Variant::Map content; >> Variant::Map OID; >> Variant::Map arguments; >> OID["_object_name"] = "org.apache.qpid.broker:** >> broker:amqp-broker"; >> arguments["type"] = "queue"; >> arguments["name"] = queue_name; // a string of the queue name >> >> content["_object_id"] = OID; >> content["_method_name"] = "delete"; >> content["_arguments"] = arguments; >> >> encode(content, message); >> message.setReplyTo(**responseQueue); >> message.setProperty("x-amqp-0-**10.app-id", "qmf2"); >> message.setProperty("qmf.**opcode", "_method_request"); >> >> sender.send(message, true); >> >> /* check response if the queue was properly deleted */ >> Message response; >> if (receiver.fetch(response,qpid:**:messaging::Duration(30000)) >> == true) >> { >> qpid::types::Variant::Map recv_props = >> response.getProperties(); >> if (recv_props["x-amqp-0-10.app-**id"] == "qmf2") >> if (recv_props["qmf.opcode"] == "_method_response") >> std::cout << "Response: OK" << std::endl; >> else if (recv_props["qmf.opcode"] == "_exception") >> std::cerr << "Error: " << >> response.getContent() << std::endl; >> else >> std::cerr << "Invalid response received!" >> << std::endl; >> else >> std::cerr << "Invalid response not of qmf2 type >> received!" << std::endl; >> } >> else >> std::cout << "Timeout: No response received within 30 >> seconds!" << std::endl; >> >> connection.close(); >> return 0; >> } catch(const std::exception& error) { >> std::cout << error.what() << std::endl; >> connection.close(); >> } >> >> >> >> Kind regards, >> Pavel >> >> ----- Original Message ----- >> >> >>> From: "Gaston Quezada" <[hidden email]> >>> To: [hidden email] >>> Sent: Monday, December 5, 2011 9:14:10 PM >>> Subject: how to delete queue from jms client >>> >>> Hi, >>> >>> Im using qpid-client 0.12, and need delete queue from JMS client. >>> the queue is not auto delete >>> >>> regards >>> >>> -- >>> Gastón Quezada >>> >>> >>> >> >> ------------------------------**------------------------------**--------- >> Apache Qpid - AMQP Messaging Implementation >> Project: http://qpid.apache.org >> Use/Interact: mailto:users-subscribe@qpid.**apache.org<[hidden email]> >> >> >> >> > > > ------------------------------**------------------------------**--------- > Apache Qpid - AMQP Messaging Implementation > Project: http://qpid.apache.org > Use/Interact: mailto:users-subscribe@qpid.**apache.org<[hidden email]> > > -- Gastón Quezada |
|
Hi Gaston,
Try the following syntax (BTW IIRC you need at least Qpid 0.10 for timed auto deletes to work): Also I can't claim credit for the following, this was a response from uber-guru Gordon Sim when I asked a similar question back in July To create a 'shared' queue on-demand: my-queue; {create: always, node:{x-declare:{auto-delete:True, arguments:{'qpid.auto_delete_timeout':120}}}} To create a subscription queue with the same properties: my-exchange; {link:{name:my-subscription, x-declare:{auto-delete:True, arguments:{'qpid.auto_delete_timeout':120}}}} Unfortunately the x-declare stuff isn't well documented. I'm not aware of the above being documented anywhere, perhaps Gordon knows of a location? There's some useful docs for x-declare here https://cwiki.apache.org/confluence/display/qpid/Qpid+extensions+to+AMQP but it's quite hard to find and doesn't really illustrate that you still need the "auto-delete:True" bit, which is possibly something you've missed? That's about the limit of my knowledge.. HTH, Frase Gaston Quezada wrote: > Dear Fraser, > > I need to configure the auto-delete arguments, with this parameter: > arguments:{'qpid.auto_delete_timeout':120} > When I create the queue, the logs show a empty field argument. > > Log: > main 2011-12-06 <tel:2011-12-06> 15:45:54,562 DEBUG > [apache.qpid.transport.Connection] SEND: [conn:db23f1] ch=0 id=2 > QueueDeclare(queue=10.2.60.69-1671711, alternateExchange=, > autoDelete=true, arguments={}) > > > Thanks you for your help, > > > > 2011/12/6 Fraser Adams <[hidden email] > <mailto:[hidden email]>> > > Here's some Java code for method invocation. This largely follows > a similar pattern to Pavel's C++ example. Note that this method is > taken from a much larger QMF2 API that I've written ,so there's > some dependencies on other classes (you won't be able to use it > directly, but hopefully you'll get the idea especially with > Pavel's code - you shouldn't need to tweak much MethodResult > really just wraps a Map - see the QMF2 API specification). My QMF2 > API stuff is actually finished, I've been promising to release it > for weeks, but I've been writing a number of tools and utilities > to demo it so I thought it'd be best to hold off until those are done. > > /** > * Invoke the named method on the named Agent. > * > * @param agent the Agent to invoke the method on. > * @param content an unordered set of key/value pairs comprising > the method arguments. > * @param replyHandle the correlation handle used to tie > asynchronous method requests with responses > * @param timeout the time to wait for a reply from the Agent, a > value of -1 means use the default timeout > * @return the method response Arguments in Map form > */ > public MethodResult invokeMethod(final Agent agent, final > Map<String, Object> content, > final String replyHandle, int > timeout) throws QmfException > { > if (!agent.isActive()) > { > throw new QmfException("Called invokeMethod() with > inactive agent"); > } > String agentName = agent.getName(); > timeout = (timeout < 1) ? _replyTimeout : timeout; > try > { > Destination destination = (replyHandle == null) ? > _replyAddress : _asyncReplyAddress; > MapMessage request = _syncSession.createMapMessage(); > request.setJMSReplyTo(destination); > request.setJMSCorrelationID(replyHandle); > request.setStringProperty("x-amqp-0-10.app-id", "qmf2"); > request.setStringProperty("method", "request"); > request.setStringProperty("qmf.opcode", "_method_request"); > request.setStringProperty("qpid.subject", agentName); > > for (Map.Entry<String, Object> entry : content.entrySet()) > { > request.setObject(entry.getKey(), entry.getValue()); > } > > // Wrap request & response in synchronized block in case > any other threads invoke a request > // it would be somewhat unfortunate if their response > got interleaved with ours!! > synchronized(this) > { > _requester.send(request); > if (replyHandle == null) > { // If this is a synchronous request get the response > Message response = _responder.receive(timeout*1000); > if (response == null) > { > log.info <http://log.info>("No response > received in invokeMethod()"); > throw new QmfException("No response received > for Console.invokeMethod()"); > } > MethodResult result = new > MethodResult(AMQPMessage.getMap(response)); > QmfException exception = result.getQmfException(); > if (exception != null) > { > throw exception; > } > return result; > } > } > // If this is an asynchronous request return without > waiting for a response > return null; > } > catch (JMSException jmse) > { > log.info <http://log.info>("JMSException {} caught in > invokeMethod()", jmse.getMessage()); > throw new QmfException(jmse.getMessage()); > > } > } > > > > Pavel Moravec wrote: > > Hi Gastón, > you can use QMF method "delete" with parameters "type" > ("queue" in our case) and "name" (name of the queue). > > Here is the code snippet from C++ program I use: > > Connection connection(url/*, connectionOptions*/); > try { > connection.open(); > Session session = connection.createSession(); > Sender sender = > session.createSender("qmf.default.direct/broker"); > Address responseQueue("#reply-queue; {create:always, > node:{x-declare:{auto-delete:true}}}"); > Receiver receiver = session.createReceiver(responseQueue); > > Message message; > Variant::Map content; > Variant::Map OID; > Variant::Map arguments; > OID["_object_name"] = > "org.apache.qpid.broker:broker:amqp-broker"; > arguments["type"] = "queue"; > arguments["name"] = queue_name; // a string of the > queue name > > content["_object_id"] = OID; > content["_method_name"] = "delete"; > content["_arguments"] = arguments; > > encode(content, message); > message.setReplyTo(responseQueue); > message.setProperty("x-amqp-0-10.app-id", "qmf2"); > message.setProperty("qmf.opcode", "_method_request"); > > sender.send(message, true); > > /* check response if the queue was properly deleted */ > Message response; > if > (receiver.fetch(response,qpid::messaging::Duration(30000)) == > true) > { > qpid::types::Variant::Map recv_props = > response.getProperties(); > if (recv_props["x-amqp-0-10.app-id"] == "qmf2") > if (recv_props["qmf.opcode"] == > "_method_response") > std::cout << "Response: OK" << > std::endl; > else if (recv_props["qmf.opcode"] == > "_exception") > std::cerr << "Error: " << > response.getContent() << std::endl; > else > std::cerr << "Invalid response > received!" << std::endl; > else > std::cerr << "Invalid response not of > qmf2 type received!" << std::endl; > } > else > std::cout << "Timeout: No response received > within 30 seconds!" << std::endl; > > connection.close(); > return 0; > } catch(const std::exception& error) { > std::cout << error.what() << std::endl; > connection.close(); > } > > > > Kind regards, > Pavel > > ----- Original Message ----- > > > From: "Gaston Quezada" <[hidden email] > <mailto:[hidden email]>> > To: [hidden email] <mailto:[hidden email]> > Sent: Monday, December 5, 2011 9:14:10 PM > Subject: how to delete queue from jms client > > Hi, > > Im using qpid-client 0.12, and need delete queue from JMS > client. > the queue is not auto delete > > regards > > -- > Gastón Quezada > > > > > --------------------------------------------------------------------- > Apache Qpid - AMQP Messaging Implementation > Project: http://qpid.apache.org > Use/Interact: mailto:[hidden email] > <mailto:[hidden email]> > > > > > > > --------------------------------------------------------------------- > Apache Qpid - AMQP Messaging Implementation > Project: http://qpid.apache.org > Use/Interact: mailto:[hidden email] > <mailto:[hidden email]> > > > > > -- > Gastón Quezada > --------------------------------------------------------------------- Apache Qpid - AMQP Messaging Implementation Project: http://qpid.apache.org Use/Interact: mailto:[hidden email] |
|
Gaston,
I forgot to ask, but you are using the C++ broker aren't you? I'm pretty sure that the Java broker doesn't support timed auto delete, and as I mentioned before the C++ broker supports this from version 0.10 Frase Fraser Adams wrote: > Hi Gaston, > Try the following syntax (BTW IIRC you need at least Qpid 0.10 for > timed auto deletes to work): > Also I can't claim credit for the following, this was a response from > uber-guru Gordon Sim when I asked a similar question back in July > > > To create a 'shared' queue on-demand: > > my-queue; {create: always, node:{x-declare:{auto-delete:True, > arguments:{'qpid.auto_delete_timeout':120}}}} > > To create a subscription queue with the same properties: > > my-exchange; {link:{name:my-subscription, x-declare:{auto-delete:True, > arguments:{'qpid.auto_delete_timeout':120}}}} > > > Unfortunately the x-declare stuff isn't well documented. I'm not aware > of the above being documented anywhere, perhaps Gordon knows of a > location? > > There's some useful docs for x-declare here > https://cwiki.apache.org/confluence/display/qpid/Qpid+extensions+to+AMQP > but it's quite hard to find and doesn't really illustrate that you > still need the "auto-delete:True" bit, which is possibly something > you've missed? > > That's about the limit of my knowledge.. > > HTH, > Frase > > > > Gaston Quezada wrote: >> Dear Fraser, >> >> I need to configure the auto-delete arguments, with this parameter: >> arguments:{'qpid.auto_delete_timeout':120} >> When I create the queue, the logs show a empty field argument. >> >> Log: >> main 2011-12-06 <tel:2011-12-06> 15:45:54,562 DEBUG >> [apache.qpid.transport.Connection] SEND: [conn:db23f1] ch=0 id=2 >> QueueDeclare(queue=10.2.60.69-1671711, alternateExchange=, >> autoDelete=true, arguments={}) >> >> >> Thanks you for your help, >> >> >> >> 2011/12/6 Fraser Adams <[hidden email] >> <mailto:[hidden email]>> >> >> Here's some Java code for method invocation. This largely follows >> a similar pattern to Pavel's C++ example. Note that this method is >> taken from a much larger QMF2 API that I've written ,so there's >> some dependencies on other classes (you won't be able to use it >> directly, but hopefully you'll get the idea especially with >> Pavel's code - you shouldn't need to tweak much MethodResult >> really just wraps a Map - see the QMF2 API specification). My QMF2 >> API stuff is actually finished, I've been promising to release it >> for weeks, but I've been writing a number of tools and utilities >> to demo it so I thought it'd be best to hold off until those are >> done. >> >> /** >> * Invoke the named method on the named Agent. >> * >> * @param agent the Agent to invoke the method on. >> * @param content an unordered set of key/value pairs comprising >> the method arguments. >> * @param replyHandle the correlation handle used to tie >> asynchronous method requests with responses >> * @param timeout the time to wait for a reply from the Agent, a >> value of -1 means use the default timeout >> * @return the method response Arguments in Map form >> */ >> public MethodResult invokeMethod(final Agent agent, final >> Map<String, Object> content, >> final String replyHandle, int >> timeout) throws QmfException >> { >> if (!agent.isActive()) >> { >> throw new QmfException("Called invokeMethod() with >> inactive agent"); >> } >> String agentName = agent.getName(); >> timeout = (timeout < 1) ? _replyTimeout : timeout; >> try >> { >> Destination destination = (replyHandle == null) ? >> _replyAddress : _asyncReplyAddress; >> MapMessage request = _syncSession.createMapMessage(); >> request.setJMSReplyTo(destination); >> request.setJMSCorrelationID(replyHandle); >> request.setStringProperty("x-amqp-0-10.app-id", "qmf2"); >> request.setStringProperty("method", "request"); >> request.setStringProperty("qmf.opcode", >> "_method_request"); >> request.setStringProperty("qpid.subject", agentName); >> >> for (Map.Entry<String, Object> entry : content.entrySet()) >> { >> request.setObject(entry.getKey(), entry.getValue()); >> } >> >> // Wrap request & response in synchronized block in case >> any other threads invoke a request >> // it would be somewhat unfortunate if their response >> got interleaved with ours!! >> synchronized(this) >> { >> _requester.send(request); >> if (replyHandle == null) >> { // If this is a synchronous request get the response >> Message response = >> _responder.receive(timeout*1000); >> if (response == null) >> { >> log.info <http://log.info>("No response >> received in invokeMethod()"); >> throw new QmfException("No response received >> for Console.invokeMethod()"); >> } >> MethodResult result = new >> MethodResult(AMQPMessage.getMap(response)); >> QmfException exception = result.getQmfException(); >> if (exception != null) >> { >> throw exception; >> } >> return result; >> } >> } >> // If this is an asynchronous request return without >> waiting for a response >> return null; >> } >> catch (JMSException jmse) >> { >> log.info <http://log.info>("JMSException {} caught in >> invokeMethod()", jmse.getMessage()); >> throw new QmfException(jmse.getMessage()); >> >> } >> } >> >> >> >> Pavel Moravec wrote: >> >> Hi Gastón, >> you can use QMF method "delete" with parameters "type" >> ("queue" in our case) and "name" (name of the queue). >> >> Here is the code snippet from C++ program I use: >> >> Connection connection(url/*, connectionOptions*/); >> try { >> connection.open(); >> Session session = connection.createSession(); >> Sender sender = >> session.createSender("qmf.default.direct/broker"); >> Address responseQueue("#reply-queue; {create:always, >> node:{x-declare:{auto-delete:true}}}"); >> Receiver receiver = >> session.createReceiver(responseQueue); >> >> Message message; >> Variant::Map content; >> Variant::Map OID; >> Variant::Map arguments; >> OID["_object_name"] = >> "org.apache.qpid.broker:broker:amqp-broker"; >> arguments["type"] = "queue"; >> arguments["name"] = queue_name; // a string of the >> queue name >> content["_object_id"] = OID; >> content["_method_name"] = "delete"; >> content["_arguments"] = arguments; >> encode(content, message); >> message.setReplyTo(responseQueue); >> message.setProperty("x-amqp-0-10.app-id", "qmf2"); >> message.setProperty("qmf.opcode", "_method_request"); >> >> sender.send(message, true); >> /* check response if the queue was >> properly deleted */ >> Message response; >> if >> (receiver.fetch(response,qpid::messaging::Duration(30000)) == >> true) >> { >> qpid::types::Variant::Map recv_props = >> response.getProperties(); >> if (recv_props["x-amqp-0-10.app-id"] == "qmf2") >> if (recv_props["qmf.opcode"] == >> "_method_response") >> std::cout << "Response: OK" << >> std::endl; >> else if (recv_props["qmf.opcode"] == >> "_exception") >> std::cerr << "Error: " << >> response.getContent() << std::endl; >> else >> std::cerr << "Invalid response >> received!" << std::endl; >> else >> std::cerr << "Invalid response not of >> qmf2 type received!" << std::endl; >> } >> else >> std::cout << "Timeout: No response received >> within 30 seconds!" << std::endl; >> >> connection.close(); >> return 0; >> } catch(const std::exception& error) { >> std::cout << error.what() << std::endl; >> connection.close(); >> } >> >> >> >> Kind regards, >> Pavel >> >> ----- Original Message ----- >> >> From: "Gaston Quezada" <[hidden email] >> <mailto:[hidden email]>> >> To: [hidden email] <mailto:[hidden email]> >> Sent: Monday, December 5, 2011 9:14:10 PM >> Subject: how to delete queue from jms client >> >> Hi, >> >> Im using qpid-client 0.12, and need delete queue from JMS >> client. >> the queue is not auto delete >> >> regards >> >> -- >> Gastón Quezada >> >> >> >> >> --------------------------------------------------------------------- >> Apache Qpid - AMQP Messaging Implementation >> Project: http://qpid.apache.org >> Use/Interact: mailto:[hidden email] >> <mailto:[hidden email]> >> >> >> >> >> >> >> --------------------------------------------------------------------- >> Apache Qpid - AMQP Messaging Implementation >> Project: http://qpid.apache.org >> Use/Interact: mailto:[hidden email] >> <mailto:[hidden email]> >> >> >> >> >> -- >> Gastón Quezada >> > > > --------------------------------------------------------------------- > Apache Qpid - AMQP Messaging Implementation > Project: http://qpid.apache.org > Use/Interact: mailto:[hidden email] > > --------------------------------------------------------------------- Apache Qpid - AMQP Messaging Implementation Project: http://qpid.apache.org Use/Interact: mailto:[hidden email] |
|
In reply to this post by fadams
On 12/06/2011 07:46 PM, Fraser Adams wrote:
> There's some useful docs for x-declare here > https://cwiki.apache.org/confluence/display/qpid/Qpid+extensions+to+AMQP > but it's quite hard to find and doesn't really illustrate that you still > need the "auto-delete:True" bit, which is possibly something you've missed? BTW I added a page on the wiki to collect some common example addresses for different cases. Comments, suggestions improvements always welcome! https://cwiki.apache.org/confluence/display/qpid/Addressing+Examples --------------------------------------------------------------------- Apache Qpid - AMQP Messaging Implementation Project: http://qpid.apache.org Use/Interact: mailto:[hidden email] |
|
Dear Gordon,
how to configure the auto-delete-timeout tag in the format BURL this is my code: String address = "BURL:direct://exchange-output/" + this.replyTo + "/" + this.replyTo + "?routingkey='"+this.replyTo"; AMQDestination dest1 = new AMQAnyDestination(address); if the option is ADRR format, how to defined by the exchange, queue, routingkey a single URL? thanks a lot... 2011/12/7 Gordon Sim <[hidden email]> > On 12/06/2011 07:46 PM, Fraser Adams wrote: > >> There's some useful docs for x-declare here >> https://cwiki.apache.org/**confluence/display/qpid/Qpid+** >> extensions+to+AMQP<https://cwiki.apache.org/confluence/display/qpid/Qpid+extensions+to+AMQP> >> but it's quite hard to find and doesn't really illustrate that you still >> need the "auto-delete:True" bit, which is possibly something you've >> missed? >> > > BTW I added a page on the wiki to collect some common example addresses > for different cases. Comments, suggestions improvements always welcome! > > https://cwiki.apache.org/**confluence/display/qpid/**Addressing+Examples<https://cwiki.apache.org/confluence/display/qpid/Addressing+Examples> > > > ------------------------------**------------------------------**--------- > Apache Qpid - AMQP Messaging Implementation > Project: http://qpid.apache.org > Use/Interact: mailto:users-subscribe@qpid.**apache.org<[hidden email]> > > -- Gastón Quezada |
|
On 12/07/2011 08:06 PM, Gaston Quezada wrote:
> Dear Gordon, > > how to configure the auto-delete-timeout tag in the format BURL I don't think you can do that with the BURL syntax. > this is my code: > > String address = "BURL:direct://exchange-output/" + this.replyTo + "/" + > this.replyTo + "?routingkey='"+this.replyTo"; > AMQDestination dest1 = new AMQAnyDestination(address); > > if the option is ADRR format, how to defined by the exchange, queue, > routingkey a single URL? I'm not entirely sure what it is you want to do (and I don't know enough about how the BURL syntax above is supposed to work to deduce this reliably from your string above). However, assuming that what you want is to create a named queue on-demand with the delayed auto-deletion function enabled, and also ensure that the queue is bound to a given exchange, you could use the following (with the ADDR style syntax and an exchange called my-exchange, a queue called my-queue and a routing key with value my-key): my-queue; {create: always, node:{x-declare:{queue:'my-queue',auto-delete:True, arguments:{'qpid.auto_delete_timeout':30}}, x-bindings:[{exchange:'my-exchange', key:'my-key'}]}} Note however that when you create a producer for that address it will publish straight to the queue, not go through the exchange. If it's the latter you want you could instead use: my-exchange/my-key; {link:{name:'my-queue', x-declare:{auto-delete:True, arguments:{'qpid.auto_delete_timeout':30}}}} Hope this helps, but if not perhaps you can give some more context for what you are trying to do. --------------------------------------------------------------------- Apache Qpid - AMQP Messaging Implementation Project: http://qpid.apache.org Use/Interact: mailto:[hidden email] |
|
Dear Gordon,
I appreciate all your support. Your advice on the creation of the queue worked well. thank you very much. Gastón, 2011/12/7 Gordon Sim <[hidden email]> > On 12/07/2011 08:06 PM, Gaston Quezada wrote: > >> Dear Gordon, >> >> how to configure the auto-delete-timeout tag in the format BURL >> > > I don't think you can do that with the BURL syntax. > > > this is my code: >> >> String address = "BURL:direct://exchange-**output/" + this.replyTo + "/" >> + >> this.replyTo + "?routingkey='"+this.replyTo"; >> AMQDestination dest1 = new AMQAnyDestination(address); >> >> if the option is ADRR format, how to defined by the exchange, queue, >> routingkey a single URL? >> > > I'm not entirely sure what it is you want to do (and I don't know enough > about how the BURL syntax above is supposed to work to deduce this reliably > from your string above). > > However, assuming that what you want is to create a named queue on-demand > with the delayed auto-deletion function enabled, and also ensure that the > queue is bound to a given exchange, you could use the following (with the > ADDR style syntax and an exchange called my-exchange, a queue called > my-queue and a routing key with value my-key): > > my-queue; {create: always, node:{x-declare:{queue:'my-**queue',auto-delete:True, > arguments:{'qpid.auto_delete_**timeout':30}}, x-bindings:[{exchange:'my-**exchange', > key:'my-key'}]}} > > Note however that when you create a producer for that address it will > publish straight to the queue, not go through the exchange. If it's the > latter you want you could instead use: > > my-exchange/my-key; {link:{name:'my-queue', x-declare:{auto-delete:True, > arguments:{'qpid.auto_delete_**timeout':30}}}} > > Hope this helps, but if not perhaps you can give some more context for > what you are trying to do. > > > ------------------------------**------------------------------**--------- > Apache Qpid - AMQP Messaging Implementation > Project: http://qpid.apache.org > Use/Interact: mailto:users-subscribe@qpid.**apache.org<[hidden email]> > > -- Gastón Quezada |
|
In reply to this post by Gordon Sim
Hi Gordon,
These examples are great, however I have to admit that I find the "cwiki.apache.org/confluence/" hard to find. It's only because I bookmarked a link you previously sent on https://cwiki.apache.org/confluence/display/qpid/Qpid+extensions+to+AMQP that I ever made it there at all. I think that my preference would be for these examples and the info on the x-declare to be included in the Programming in Apache Qpid book, which seems to be becoming somewhat of the canonical reference book. What do you think? If you're not keen on that then perhaps hyperlinks to the wiki pages? if https://cwiki.apache.org/confluence/display/qpid/Index represents the "real" Wiki "root" it might be better if that was what was linked off the Qpid home page Wiki link rather than https://cwiki.apache.org/qpid/ if I'm honest I find it a bit confusing and it's not obvious which is canonical. Finally Re (from the addressing examples page) "Another use case for more complex addresses is where shared queues are to be created on demand, conforming to a specific configuration. My own advice is to think carefully about whether this is needed in any given situation or whether a static configuration might be more appropriate. However for those who feel they require it," I've noticed you're views on this in some of your other posts on the mailing list and I'm really curious as to your reasoning behind it. My personal view is that I really like the idea of "self service" subscription. In my particular scenario I've got producers delivering to a headers exchange and acting kind of like a "data mart", where consumers can come along and pick up subsets of data that they want. I'm personally not especially "anti" administratively created queues either (indeed I do this for setting up queue routes) however I think it's a bit inconvenient for general subscribers. Also there are currently general inconveniences with administratively created queues/etc. (which would be nice to get sorted IMHO) in particular the configuration doesn't persist broker restart. In other words if one actually wants a non-durable queue (as in the messages aren't persisted) you have to put up with it getting blatted when the broker restarts. This is pretty annoying - especially for queue routes!!! you'll recall some conversations we've had with respect to that. Adding bindings administratively for lots of clients is fiddly too, especially headers clients. In my scenario I've got dozens of consumers with quite sophisticated headers bindings and when I need to restart the broker the clients automatically reconnect and the queues & bindings get recreated and the data just starts flowing. If I had to use administratively created stuff yeah I could script it, but why is that better than "on-demand" queues? Also I'd need to add some way to detect the broker restart to cause my script to run - IMHO that all gets just a bit messy. I'm already grumbling under my breath about the cron job I've had to introduce to periodically attempt to re-create queues and links from my source brokers in case they've restarted. So I'm curious why you seem anti "on demand" creation and how you'd go about managing a fairly large and complex environment via administratively created queues/bindings given the sort of broker restart scenario I describe above. I look forward to your thoughts. Cheers, Frase Gordon Sim wrote: > On 12/06/2011 07:46 PM, Fraser Adams wrote: >> There's some useful docs for x-declare here >> https://cwiki.apache.org/confluence/display/qpid/Qpid+extensions+to+AMQP >> but it's quite hard to find and doesn't really illustrate that you still >> need the "auto-delete:True" bit, which is possibly something you've >> missed? > > BTW I added a page on the wiki to collect some common example > addresses for different cases. Comments, suggestions improvements > always welcome! > > https://cwiki.apache.org/confluence/display/qpid/Addressing+Examples > > --------------------------------------------------------------------- > Apache Qpid - AMQP Messaging Implementation > Project: http://qpid.apache.org > Use/Interact: mailto:[hidden email] > > --------------------------------------------------------------------- Apache Qpid - AMQP Messaging Implementation Project: http://qpid.apache.org Use/Interact: mailto:[hidden email] |
|
On 12/09/2011 05:15 PM, Fraser Adams wrote:
> These examples are great, however I have to admit that I find the > "cwiki.apache.org/confluence/" hard to find. It's only because I > bookmarked a link you previously sent on > https://cwiki.apache.org/confluence/display/qpid/Qpid+extensions+to+AMQP > that I ever made it there at all. > > I think that my preference would be for these examples and the info on > the x-declare to be included in the Programming in Apache Qpid book, > which seems to be becoming somewhat of the canonical reference book. > What do you think? I wouldn't consider these addressing examples as canonical reference material! The Programming in Apache Qpid book is a bit of a mixture of things. I'm not yet sure if or how these would fit in with that. In the meantime I wanted to at least have somewhere where we could start collecting 'recipes'. [...] > Finally Re (from the addressing examples page) "Another use case for > more complex addresses is where shared queues are to be created on > demand, conforming to a specific configuration. My own advice is to > think carefully about whether this is needed in any given situation or > whether a static configuration might be more appropriate. However for > those who feel they require it," > > I've noticed you're views on this in some of your other posts on the > mailing list and I'm really curious as to your reasoning behind it. I distinguish between on-demand creation of *shared* queues and/or exchanges as addressable entities in their own right and the very necessary on-demand (and hopefully increasingly transparent) creation of 'subscription' queues as required by the AMQP 0-10 model. With regard to the former, my opinion is simply that it is worth considering carefully whether it is required. If it is not, keeping the configuration entirely separate from the clients has advantages and static creation avoids any race conditions. I certainly accept that having no durable record of queue configuration (as distinct from having the messages on them persisted) is an unfortunate limitation. --------------------------------------------------------------------- Apache Qpid - AMQP Messaging Implementation Project: http://qpid.apache.org Use/Interact: mailto:[hidden email] |
|
Gordon Sim wrote:
> > I wouldn't consider these addressing examples as canonical reference > material! The Programming in Apache Qpid book is a bit of a mixture of > things. I'm not yet sure if or how these would fit in with that. In > the meantime I wanted to at least have somewhere where we could start > collecting 'recipes'. I guess, though that book does contain a few address examples, but they're a bit basic compared to your ones. What's your thinking on how easy (or otherwise) the confluence wiki stuff is to find from the main web site? As I said earlier I only found these pages after you posted the link, it's not easy to find from the main site. > > I distinguish between on-demand creation of *shared* queues and/or > exchanges as addressable entities in their own right and the very > necessary on-demand (and hopefully increasingly transparent) creation > of 'subscription' queues as required by the AMQP 0-10 model. I think I see what you're getting at here. I think that there are subtleties though. In my case I have subscribers that may be considered single "logical" entities, however in practice they may comprise several physical instances each consuming messages from a given queue - in effect the shared queue enables a fairly simple approach to scaling out across multiple servers. > > With regard to the former, my opinion is simply that it is worth > considering carefully whether it is required. If it is not, keeping > the configuration entirely separate from the clients has advantages > and static creation avoids any race conditions. What sort of race conditions would you expect to crop up? I'm not aware of seeing any issues with out > > I certainly accept that having no durable record of queue > configuration (as distinct from having the messages on them persisted) > is an unfortunate limitation. Are there any plans to introduce such a feature? From what I've gathered the Java broker has something like this, though I'm not familiar with that and it may just be hearsay. --------------------------------------------------------------------- Apache Qpid - AMQP Messaging Implementation Project: http://qpid.apache.org Use/Interact: mailto:[hidden email] |
|
On 12/09/2011 07:58 PM, Fraser Adams wrote:
> Gordon Sim wrote: >> >> I wouldn't consider these addressing examples as canonical reference >> material! The Programming in Apache Qpid book is a bit of a mixture of >> things. I'm not yet sure if or how these would fit in with that. In >> the meantime I wanted to at least have somewhere where we could start >> collecting 'recipes'. > I guess, though that book does contain a few address examples, but > they're a bit basic compared to your ones. > > What's your thinking on how easy (or otherwise) the confluence wiki > stuff is to find from the main web site? As I said earlier I only found > these pages after you posted the link, it's not easy to find from the > main site. I would agree that it is not well enough organised or easy to find things if you don't know they are there already. >> I distinguish between on-demand creation of *shared* queues and/or >> exchanges as addressable entities in their own right and the very >> necessary on-demand (and hopefully increasingly transparent) creation >> of 'subscription' queues as required by the AMQP 0-10 model. > I think I see what you're getting at here. I think that there are > subtleties though. In my case I have subscribers that may be considered > single "logical" entities, however in practice they may comprise several > physical instances each consuming messages from a given queue - in > effect the shared queue enables a fairly simple approach to scaling out > across multiple servers. >> >> With regard to the former, my opinion is simply that it is worth >> considering carefully whether it is required. If it is not, keeping >> the configuration entirely separate from the clients has advantages >> and static creation avoids any race conditions. > What sort of race conditions would you expect to crop up? I'm not aware > of seeing any issues with out If you have multiple clients using the node, then the first to try and use it will create it. If there are any differences in node properties between these clients, then the properties used depend on who tries to use it first. >> I certainly accept that having no durable record of queue >> configuration (as distinct from having the messages on them persisted) >> is an unfortunate limitation. > Are there any plans to introduce such a feature? I don't know of anyone actively pursuing that as a priority at this point. --------------------------------------------------------------------- Apache Qpid - AMQP Messaging Implementation Project: http://qpid.apache.org Use/Interact: mailto:[hidden email] |
| Powered by Nabble | Edit this page |
