You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by sodandk <so...@sodan.dk> on 2010/09/23 15:21:10 UTC

CMS: get name of destination - how to ?

Hi there

I do
const cms::Destination *jmsdest = msg->getCMSReplyTo()->clone();
and now and then use the saved jmsdest, to send messages back...

many of my objects gets the same destination, so I dont want to have
hundreds
of the same destinations hanging around, instead I was to compare two
destinations, so I only has one of each.

How to do that ?

Is there a way to do dest->getname or something, so I can compare two
destinations
to see if they are indeed the same ?

sincerely,
Søren

-- 
View this message in context: http://activemq.2283324.n4.nabble.com/CMS-get-name-of-destination-how-to-tp2552032p2552032.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: CMS: get name of destination - how to ?

Posted by sodandk <so...@sodan.dk>.
oops. had to use dynamic_cast... now its ok again...

Søren

-- 
View this message in context: http://activemq.2283324.n4.nabble.com/CMS-get-name-of-destination-how-to-tp2552032p2718590.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: CMS: get name of destination - how to ?

Posted by Timothy Bish <ta...@gmail.com>.
On Tue, 2010-09-28 at 14:56 -0700, sodandk wrote:
> const cms::Destination *d =
> DestinationManager.Manage(jmsmsg->getCMSReplyTo());
> 
> 
> 
> from .h file
> vector<const cms::Destination *> destinations;
> 
> 
> from .cpp file
> const cms::Destination *DestinationManager::Manage(
> 	const cms::Destination *inDestination)
> {
> 	ActiveMQDestination *newmqdest = (ActiveMQDestination*)inDestination;
> 
> 	for (size_t x=0;x<destinations.size();x++)
> 	{
> 		ActiveMQDestination *oldmqdest = (ActiveMQDestination*)destinations[x];
> 		if (newmqdest->equals(oldmqdest))
> 			return destinations[x];
> 	}
> 
> 	const cms::Destination *clone = inDestination->clone();	// clone it
> 	destinations.push_back(clone);	// and save the clone
> 
> 	return clone;
> }
> 

Well don't see anything obvious other than some missing NULL checks and
not using dynamic_cast.  If you can provide a complete sample or CPPUnit
test we can look into it further.  

Have you tried building a release binary with debug symbols enabled so
you can get a stack trace?

Regards

-- 
Tim Bish

Open Source Integration: http://fusesource.com

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


Re: CMS: get name of destination - how to ?

Posted by sodandk <so...@sodan.dk>.
const cms::Destination *d =
DestinationManager.Manage(jmsmsg->getCMSReplyTo());



from .h file
vector<const cms::Destination *> destinations;


from .cpp file
const cms::Destination *DestinationManager::Manage(
	const cms::Destination *inDestination)
{
	ActiveMQDestination *newmqdest = (ActiveMQDestination*)inDestination;

	for (size_t x=0;x<destinations.size();x++)
	{
		ActiveMQDestination *oldmqdest = (ActiveMQDestination*)destinations[x];
		if (newmqdest->equals(oldmqdest))
			return destinations[x];
	}

	const cms::Destination *clone = inDestination->clone();	// clone it
	destinations.push_back(clone);	// and save the clone

	return clone;
}

-- 
View this message in context: http://activemq.2283324.n4.nabble.com/CMS-get-name-of-destination-how-to-tp2552032p2718019.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: CMS: get name of destination - how to ?

Posted by Timothy Bish <ta...@gmail.com>.
On Tue, 2010-09-28 at 14:03 -0700, sodandk wrote:
> Weird... the 'equals' works fine in debugging mode, but when I compile for
> release,
> then it crashes !
> 
> ActiveMQDestination *oldmqdest = (ActiveMQDestination*)destinations[x];
> if (oldmqdest->equals(newmqdest))   CRASH
> 
> help,
> Søren

Would need to see a complete sample app to really be able to really know
what might be going wrong.  Usually though in these cases it means that
something in your pointer handling isn't right and the debug build was
letting it slip by.  You might want to ensure you aren't overstepping
the bounds of the array of accessing an element that should be NULL.

Regards


-- 
Tim Bish

Open Source Integration: http://fusesource.com

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


Re: CMS: get name of destination - how to ?

Posted by sodandk <so...@sodan.dk>.
Weird... the 'equals' works fine in debugging mode, but when I compile for
release,
then it crashes !

ActiveMQDestination *oldmqdest = (ActiveMQDestination*)destinations[x];
if (oldmqdest->equals(newmqdest))   CRASH

help,
Søren

-- 
View this message in context: http://activemq.2283324.n4.nabble.com/CMS-get-name-of-destination-how-to-tp2552032p2717938.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: CMS: get name of destination - how to ?

Posted by sodandk <so...@sodan.dk>.
works just fine :-)

thank you.
Søren

-- 
View this message in context: http://activemq.2283324.n4.nabble.com/CMS-get-name-of-destination-how-to-tp2552032p2553301.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: CMS: get name of destination - how to ?

Posted by sodandk <so...@sodan.dk>.
will try.

thanx!
Søren

-- 
View this message in context: http://activemq.2283324.n4.nabble.com/CMS-get-name-of-destination-how-to-tp2552032p2552809.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: CMS: get name of destination - how to ?

Posted by Timothy Bish <ta...@gmail.com>.
On Thu, 2010-09-23 at 06:21 -0700, sodandk wrote:
> Hi there
> 
> I do
> const cms::Destination *jmsdest = msg->getCMSReplyTo()->clone();
> and now and then use the saved jmsdest, to send messages back...
> 
> many of my objects gets the same destination, so I dont want to have
> hundreds
> of the same destinations hanging around, instead I was to compare two
> destinations, so I only has one of each.
> 
> How to do that ?
> 
> Is there a way to do dest->getname or something, so I can compare two
> destinations
> to see if they are indeed the same ?
> 
> sincerely,
> Søren
> 

You could cast them to ActiveMQDestination pointers and call the equals
method on one, passing in the target pointer.

Regards

-- 
Tim Bish

Open Source Integration: http://fusesource.com

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