On 06/29/2010 04:23 PM, Steve Huston wrote:
I'm working on some code that sends messages to a topic exchange. I
create a Receiver to get messages by key. When I use
Receiver::fetch(Message, Duration) all appears ok; when I use
Session::nextReceiver I never get a message. Here is some lines copied
out of the real code to show usage:
qpid::messaging::Connection connection (broker_url_);
connection.open ();
session = connection.createSession();
sender = session.createSender("amq.topic");
...
qpid::messaging::Message msg (content, length);
std::string dest ("a.b.c", 5);
msg.setSubject (dest);
sender.send(msg);
... In the receiving part ...
std::string addr = "amq.topic/" + "a.b.#";
receivers.push_back (session.createReceiver(addr));
#if 1
// This next couple of lines works...
qpid::messaging::Message message;
if (receivers[0].fetch (message, qpid::messaging::Duration::SECOND *
1))
{ // do something - this works }
#else
// This does not work. nextReceiver() doesn't ever return true
qpid::messaging::Receiver r;
if (session.nextReceiver (r, qpid::messaging::Duration::SECOND * 1))
{
qpid::messaging::Message message = r.fetch();
// do something
}
#endif
Is this a bug in my code, or in Qpid? If mine, what's the difference
from fetching a message on a specific receiver and getting the next
receiver then its message?
Thanks,
-Steve
--
Steve Huston, Riverace Corporation
Total Lifecycle Support for Your Networked Applications
http://www.riverace.com
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:users-subscr...@qpid.apache.org
Steve,
Try adding r.setCapacity(1) for all receivers r prior to calling
session.nextReceiver(). Without setting a capacity, no credit will be
issued to the broker and the local queue will never have any messages in it.
If you call fetch() on a receiver with no capacity, it will issue a
credit and wait for a message.
-Ted
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:users-subscr...@qpid.apache.org