activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Timothy Bish <tabish...@gmail.com>
Subject Re: ActiveMQ-CPP Durable Subscriber Not Working.
Date Wed, 30 Jun 2010 01:11:27 GMT
On Tue, 2010-06-29 at 16:40 -0700, solanki wrote:
> I have searched through all posts related to the subject. Yet I failed to
> find any help. 
> Here is the consumer code, and its not able to receive messages as a durable
> subscriber. (It does receive messages  when its connected to the Broker but
> not the onces that are sent when its not connected). 
> I have seen people ask this exact question few times in the forum but NONE
> of them received any response regarding ActiveMQ-CPP durable subscriber not
> working. Anyone would like to be the first  ?
> 
> many thanks
> 
> 
> 
>     auto_ptr<cms::ConnectionFactory> connectionFactory(
> 	  cms::ConnectionFactory::createCMSConnectionFactory( brokerURI ) );
>     
>     // Create a Connection
>     connection = connectionFactory->createConnection();
>     connection->start();
> 
>     // Create a Session
>     session = connection->createSession( cms::Session::AUTO_ACKNOWLEDGE);
> 
>       cms::Topic* topic = session->createTopic("test.foo");
>       
>       // Create a MessageConsumer from the Session to the Topic or Queue
>       cms::MessageConsumer *consumer =
> session->createDurableConsumer(topic,"mytest","",false);
> 
> 	cms::Message* cmsmsg = consumer->receive();
> 
> //////////////
> 
> 
> 

Given the code I'd say the problem lies in the fact that you haven't set
a client ID on the Connection.  

Depending on what version of the CPP client you are using you can set
the client ID either from the createConnection method:

cms::Connection* createConnection( const std::string& username,
                                   const std::string& password,
                                   const std::string& clientId );

if you had no username or password the call would look like

factory->createConnection( "", "", "MyUniqueClientId" );

Each time the client connects it must use that same client ID.

Or you can set the client Id on the URI as follows:

tcp://127.0.0.1:61616?client-id="MyUniqueClientId"

And just to make things even easier he newest ActiveMQ-CPP release
v3.2.0 also added method in the factory to set these values, so you can
now do it this way as well.

Connection* con = factory->createConnection();

con-setClientId("MyUniqueClientId");

Read this for some more info on how Durable Topics work.
http://activemq.apache.org/how-do-durable-queues-and-topics-work.html

If you still have issues you are welcome to open a new Jira issue and
attach a small but complete sample app that demonstrates the problem
along with info on you OS / Compiler / Architecture / Broker Version.

>From Session::createDurableConsumer:

Regards

-- 
Tim Bish

Open Source Integration: http://fusesource.com
ActiveMQ in Action: http://www.manning.com/snyder/

Follow me on Twitter: http://twitter.com/tabish121
My Blog: http://timbish.blogspot.com/


Mime
View raw message