activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Timothy Bish <tabish...@gmail.com>
Subject Re: Questions about getCMSReplyTo
Date Fri, 05 Dec 2008 14:11:04 GMT
On Fri, 2008-12-05 at 05:03 -0800, Sodan wrote:
> So I get a message and create a producer based on the destination 
>   const cms::Destination *cmsdst = map->getCMSReplyTo();
>   session->createProducer(cmsdst);
> which works fine.
> 
> The thing is that I dont need to reply instantly back, when I get a message,
> instead I will send back messages after 1 minute or 1 hour.
> So is the above Destination valid forever or ?
> 
> So the 2 questions are:
> 1) the above 'const cms::Destination' objects, who owns that and for how
> long,
> or can/should I make a copy of it or ?
> 2) tried to do
>   string providerstring = cmsdst->toProviderString();
>   t = session->createQUEUE(providerstring);
>   session->createProducer(t);
> but this does not work... no messages seems to hit the other end
> 
> The providerstring returned is:  "ID:verisign-45349-1228314908106-0:32:1"
> 
> So I get a message... and need to reply later, sometimes much later...
> What is the best approach ?
> 

cms::Destination provides a clone method that will create a valid copy
of the Destination that you can keep around for a later response.  Any
pointers that are returned from CMS interfaces as const are considered
to be the property of the CMS classes and should not be deleted or
assumed to exist for any longer that the current scope you are in, e.g.
Message's received in onMessage callbacks are only guaranteed to exist
during the lifetime of that onMessage call and no longer so the
cms::Destination pointer returned from getCMSReplyTo is subject to the
same lifetime.

Regards
Tim.



-- 
Tim Bish
http://fusesource.com
http://timbish.blogspot.com/




Mime
View raw message