Announcement Announcement Module
Collapse
No announcement yet.
JMS Destination error Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • JMS Destination error

    Hi,

    I converted to JMS namespaces and it doesn't seem to work. The original code which works:
    Code:
    	<!-- Listener used to process JMS messages -->
    	<bean id="messageListenerContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
    		<property name="connectionFactory" ref="connectionFactory" />
    		<property name="destination" ref="queue" />
    		<property name="messageListener" ref="messageListener" />
    		<property name="concurrentConsumers" value="${concurrent.consumers}" />
    		<property name="pubSubDomain" value="false" />
    		<property name="cacheLevel" value="0" />
    		<property name="sessionTransacted" value="false" />
    		<property name="autoStartup" value="true" />
    	</bean>
    
    	<jee:jndi-lookup id="connectionFactory" jndi-name="${my.connection.factory}"/>
    
    	<jee:jndi-lookup id="queue" jndi-name="${my.queue}"/>
    Wanted to use the JMS namespaces, so I replaced the "messageListenerContainer" bean with:
    Code:
    	<jms:listener-container connection-factory="connectionFactory" concurrency="10">
    		<jms:listener destination="${my.queue}" ref="messageListener"/>
    	</jms:listener-container>
    and I get the error:

    Code:
    11:45:40,286 INFO  [STDOUT] INFO [2009-10-13 11:45:40,285] org.springframework.jms.listener.DefaultMessageListenerContainer:744 - Setup of JMS message listener invoker failed for destination 'queue/myQueue' - trying to recover. Cause: This destination does not exist !QUEUE.queue/myQueue
    The value of ${my.queue} = "queue/myQueue".

    Any ideas?

  • #2
    And why would you expect it to work... You are replacing a JNDI lookup with a reference that is obviously not going to work. Configure a JndiDestinatioNResolver and attach that to your listener-container.

    Comment


    • #3
      Why would I expect it to work? I would expect it to work because the name of the property for the messageListener bean is named "destination". And the <jms:listener-container> has an attribute named "destination" (seems kind of obvious, isn't it?). What do you think? Why would you expect this NOT to work is my question? If this is not the case then please update the documentation. You do not have one example of a "DesitinationResolver" and how to implement. Shouldn't Spring default to use a JndiDestinationResolver, anyway? No where in the docs does it say what the default destination resolver is for a <jms:listener-container>.

      Please enlighten me.

      Anyway I added the following and it still doesn't work (I get the same error):
      Code:
      	<jms:listener-container connection-factory="connectionFactory" concurrency="10" destination-resolver="destinationResolver">
      		<jms:listener destination="${my.queue}" ref="messageListener"/>
      	</jms:listener-container>
      
      	<bean id="destinationResolver" class="org.springframework.jms.support.destination.JndiDestinationResolver"/>
      What do I need to configure on the JndiDestinationResolver?
      Last edited by backofthecup; Oct 13th, 2009, 01:12 PM.

      Comment


      • #4
        Ok, I did get this to work based on your suggestion. Thank You.

        However, one example, ONE SIMPLE EXAMPLE, in the documentation could solve these unnecessary posts. The documentation focuses on the <bean> namespace and not enough on the new namespaces. Spring created these namespace to make configuration easier, not harder.

        Spring use to have great documentation, but not anymore.
        Last edited by backofthecup; Oct 13th, 2009, 01:27 PM.

        Comment


        • #5
          You expect

          Code:
          <jee:jndi-lookup id="queue" jndi-name="${my.queue}"/>
          To be the same as

          Code:
          <jms:listener destination="${my.queue}" ref="messageListener"/>
          It translates to

          Code:
          <bean id="messageListenerContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
          		<property name="connectionFactory" ref="connectionFactory" />
          		<property name="destinationName" value="${my.queue)" />
          		<property name="messageListener" ref="messageListener" />
          		<property name="concurrentConsumers" value="${concurrent.consumers}" />
          		<property name="pubSubDomain" value="false" />
          		<property name="cacheLevel" value="0" />
          		<property name="sessionTransacted" value="false" />
          		<property name="autoStartup" value="true" />
          	</bean>
          So no it is not the same.

          And the <jms:listener-container> has an attribute named "destination"
          Which you give it a reference to a queue not the name of the queue to lookup (you do the lookup, manual configureation or whatever you like yourself spring isn't doing that for you). However that behavior can be configured....

          Shouldn't Spring default to use a JndiDestinationResolver, anyway? No where in the docs does it say what the default destination resolver is for a <jms:listener-container>
          The default is a DynamicDestinationResolver which basically tries to create a Queue/Topic based on the configuration. You can switch out which DestinationResolver to use and as such change the default behavior. The JNDI one isn't the default because well in general you just pass in a reference to a queue and do the lookup yourself.

          Originally posted by Spring Reference Guide
          DynamicDestinationResolver is the default implementation used .....
          So it IS in the reference guide.

          If you still get the SAME exception then you probably have a refreshing issue with your application/configuration. Please post whole stacktrace.

          Comment


          • #6
            You say:
            Originally posted by Marten Deinum View Post
            So it IS in the reference guide.
            No its not....you should have continued with the rest of the sentence:
            DynamicDestinationResolver is the default implementation used by JmsTemplate

            Also you say the in <jms:listener destination="myDest"/>

            that "destination" is a ref. This is clearly not the case (this is what I initially tried when changing to the jms namespace). If that were the case I could use this:
            Code:
            	<jms:listener-container connection-factory="connectionFactory" concurrency="10">
            		<jms:listener destination="myQueue" ref="messageListener"/>
            	</jms:listener-container>
            
            	<jee:jndi-lookup id="myQueue" jndi-name="${my.queue}"/>
            In the above case, destination should be set the bean myQueue (which in turn would not need a DestinationResolver), but instead it tries to find a queue with the name "myQueue".

            The docs say:
            The destination name for this listener, resolved through the DestinationResolver strategy.
            The attributes of the namespaces used to alway use "-ref' when referencing a bean. That naming convention has obviously been abandoned.
            Last edited by backofthecup; Oct 13th, 2009, 02:27 PM.

            Comment


            • #7
              So, according to what you say these should be identical:
              Code:
              <bean id="messageListenerContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
              		<property name="connectionFactory" ref="connectionFactory" />
              		<property name="destination" ref="myQueue" />
              		<property name="messageListener" ref="messageListener" />
              		<property name="concurrentConsumers" value="${concurrent.consumers}" />
              		<property name="pubSubDomain" value="false" />
              		<property name="cacheLevel" value="0" />
              		<property name="sessionTransacted" value="false" />
              		<property name="autoStartup" value="true" />
              	</bean>
              
              	<jee:jndi-lookup id="connectionFactory" jndi-name="${my.connection.factory}"/>
              
              	<jee:jndi-lookup id="myQueue" jndi-name="${my.queue}"/>
              should be the same as:
              Code:
              	<jms:listener-container connection-factory="connectionFactory" concurrency="10">
              		<jms:listener destination="myQueue" ref="messageListener"/>
              	</jms:listener-container>
              
              	<jee:jndi-lookup id="connectionFactory" jndi-name="${my.connection.factory}"/>
              
              	<jee:jndi-lookup id="myQueue" jndi-name="${my.queue}"/>
              I would think these would be identical, but they are not. Please explain why? Also, when I try use a property placeholder for "concurrency" attribute, I get a number format exception.

              Comment


              • #8
                No its not....you should have continued with the rest of the sentence:
                DynamicDestinationResolver is the default implementation used by JmsTemplate
                If you would understand the JMS support you would know that the JmsTemplate (actually the JmsDestinationAccessor) is the base for all JMS stuff in Spring, also for the MessageListenContainer infrastructure so it also applies to that.

                So, according to what you say these should be identical:
                No they aren't as I explained the DestinationResolver used is a DynamicDestinationResolver and you set the name of the destination not the reference.

                The destination attribute is quite clearly explained in the reference guide (chapter 19.6).

                Originally posted by Reference Guide
                destination: The destination name for this listener, resolved through the DestinationResolver strategy
                Not sure how that cannot be clear.

                I try use a property placeholder for "concurrency" attribute, I get a number format exception
                The concurrency is directly being parsed to an Integer, placeholders aren't supported there. This has to do with the difference in configuring different types of MessageListeners. You could try raising a JIRA for this.

                Comment


                • #9
                  Marten Deinum ,

                  Is there any way of referencing the jndi lookup in <jms:listener destination="RefJndiQueue", there is some attribute in JNDIDestinationResolver to see the references?

                  thanks,

                  Sucram
                  Last edited by Sucram; Jan 11th, 2011, 12:59 PM.

                  Comment


                  • #10
                    Hi,

                    Could you please tell me how did you resolve this issue? i am also having the same setup.. and my listener configuration follows.

                    It works with DefaultMessageListener when i try to change with JMS namespace its not working.And i am not getting any errors.

                    Queue-0 is my queue name not a JNDI name.

                    Code:
                    <jee:jndi-lookup id="connectionFactory" jndi-name="connectionFactory">
                    		<jee:environment>
                    			java.naming.factory.initial=weblogic.jndi.WLInitialContextFactory
                    			java.naming.provider.url=t3://localhost:7001
                    		</jee:environment>
                    	</jee:jndi-lookup>
                    
                    
                    
                    <bean id="jmsDestinationResolver" class="org.springframework.jms.support.destination.BeanFactoryDestinationResolver" />
                    	 
                    <jms:listener-container container-type="default" connection-factory="connectionFactory" 
                    							acknowledge="auto" destination-resolver="jmsDestinationResolver">
                            <jms:listener destination="Queue-0" ref="messageListener" />
                    </jms:listener-container>
                    Last edited by snsancar; May 30th, 2013, 10:26 PM.

                    Comment

                    Working...
                    X