activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alex Karasulu" <akaras...@apache.org>
Subject [ActiveMQ] Trying to decipher confusing exception message
Date Fri, 25 Apr 2008 03:46:30 GMT
Hi all,

I just started using ActiveMQ 5.1.0 and it's just wonderful.  I just wish I
had a better understanding of it.  Trying to get up to speed reading the
code, the bundled test cases and playing with some of my own as well.

Unfortunately I hit a brick wall today when trying to tinker with temporary
queues.  I got the following exception:

javax.jms.InvalidDestinationException: Cannot use a Temporary
destination from another Connection
	at org.apache.activemq.ActiveMQMessageConsumer.<init>(ActiveMQMessageConsumer.java:160)
	at org.apache.activemq.ActiveMQSession.createConsumer(ActiveMQSession.java:1004)
	at org.apache.activemq.ActiveMQSession.createConsumer(ActiveMQSession.java:948)
	at org.apache.activemq.ActiveMQSession.createConsumer(ActiveMQSession.java:861)
	at org.apache.activemq.ActiveMQSession.createConsumer(ActiveMQSession.java:834)


Here's my environment in case that may factor in:
    Linux 2.6.22-14-generic SMP AMD x86_64
    Java HotSpot(TM) 64-Bit Server VM (build 1.6.0_03-b05, mixed mode)
    Maven version: 2.0.8

This is coming from the following code snippet from a test.  The code
producing the exception is below but please excuse the use of actual
ActiveMQXxxxx objects instead of the JMS equivalents - I've been doing this
just to investigate, and learn about the internals.

        if ( create )
        {
            factory = new ActiveMQConnectionFactory(
"vm://localhost?create=true&broker.persistent=false" );
        }
        else
        {
            factory = new ActiveMQConnectionFactory(
"vm://localhost?broker.persistent=false" );
        }
        factory.setObjectMessageSerializationDefered( true );
        factory.setCopyMessageOnSend( false );
        factory.setUseAsyncSend( true );
        factory.setStatsEnabled( true );

        ...

        String destination = "testQueue";
        connection = ( ActiveMQConnection ) factory.createConnection();
        connection.start();
        session = ( ActiveMQSession ) connection.createSession( false,
Session.AUTO_ACKNOWLEDGE );
        queue = ( ActiveMQTempQueue )
ActiveMQDestination.createDestination( destination,
ActiveMQDestination.TEMP_QUEUE_TYPE );
====>>>        consumer = ( ActiveMQMessageConsumer )
session.createConsumer( queue );
        consumer.setMessageListener( this );
        consumer.start();
        producer = ( ActiveMQMessageProducer ) session.createProducer( queue );



The marked line above (see ====>>>>) where the consumer is created throws
this exception.  The interesting thing is when it does this, I'm using the
same connection as well as the the same session.  Why would the exception
above say "Cannot use a Temporary destination from another Connection" if
I'm using the same connection?

I tracked it down to a constructor of ActiveMQMessageConsumer on line 160
here:

            String connectionID =
session.connection.getConnectionInfo().getConnectionId().getValue();

            if (physicalName.indexOf(connectionID) < 0) {
                throw new InvalidDestinationException(
                                                      "Cannot use a
Temporary destination from another Connection");
            }

The value for my queue's physicalName is showing "testQueue" and the value
of the connectionID is showing "ID:newton-58167-1209094847149-2:0".
Obviously the connectionID will not be found in "testQueue".  I'm wondering
why these values are the way they are and this check is failing?

These are probably some dumb questions and I must be doing something dumb
here.  Looking for enlightenment :).

Thanks much,
Alex

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message