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 <fraser.ad...@blueyonder.co.uk
<mailto:fraser.ad...@blueyonder.co.uk>>
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" <quezada.gas...@gmail.com
<mailto:quezada.gas...@gmail.com>>
To: users@qpid.apache.org <mailto:users@qpid.apache.org>
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-subscr...@qpid.apache.org
<mailto:users-subscr...@qpid.apache.org>
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:users-subscr...@qpid.apache.org
<mailto:users-subscr...@qpid.apache.org>
--
Gastón Quezada