Uploaded image for project: 'Qpid JMS'
  1. Qpid JMS
  2. QPIDJMS-332

enable defining destination names in tomcat resource definitions

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 0.25.0
    • 0.26.0
    • qpid-jms-client
    • None

    Description

      Since a few days i am trying to define a queue resource in Tomcat's context.xml. The attribute "name" defines the jndi name. Looking at org.apache.qpid.jms.JmsDestination
      the attribute is called "name", too. This seems to me as a naming conflict. I tried to use the attribute "physicalName" due to the fact that some of the classes are based on ActiveMQ. However I am not sure if I am missing a point somewhere else:

      This is my setup:

      Context.xml

      <Resource name="jms/ConnectionFactory" auth="Container"
      		type="org.apache.qpid.jms.JmsConnectionFactory" factory="org.apache.qpid.jms.jndi.JNDIReferenceFactory"
      		remoteURI="amqp://10.10.10.1:5672" username="a" password="a"
      		maxPoolSize="20" connectionTimeout="60000" />
      
      	<Resource name="jms/queue" auth="Container"
      		type="org.apache.qpid.jms.JmsQueue" factory="org.apache.qpid.jms.jndi.JNDIReferenceFactory"
      		physicalName="name"/>
      

      Init-code using spring:

      @Configuration
      @EnableJms
      public class MessagingConfiguration {
      
      	@Bean
      	public ConnectionFactory connectionFactory() throws NamingException {
      		ConnectionFactory connectionFactory =  (new JndiTemplate())
      				.lookup("java:/comp/env/jms/ConnectionFactory",ConnectionFactory.class);
      		return connectionFactory;
      	}
      	
      	@Bean
      	public DestinationResolver destinationResolver() {
      		JndiDestinationResolver jdr = new JndiDestinationResolver();
      		try {
      			// testing
      			Queue q = jdr.getJndiTemplate().lookup("java:/comp/env/jms/queue", Queue.class);
      			System.out.println("A: " + q.getQueueName());
      			System.out.println("B: " + (new JndiTemplate()).lookup("java:/comp/env/jms/queue", Destination.class).getClass());
      		} catch (Exception e) {
      			// TODO Auto-generated catch block
      			e.printStackTrace();
      		}
      		return jdr; 
      	}
      
      	@Bean
      	public JmsTemplate jmsTemplate() throws NamingException {
      		JmsTemplate template = new JmsTemplate();
      		template.setConnectionFactory(connectionFactory());
      		template.setDestinationResolver(destinationResolver());
      		return template;
      	}
      }
      

      Running the code prints out:

      ...
      A:
      B: class org.apache.qpid.jms.JmsQueue
      

      Attachments

        Activity

          People

            robbie Robbie Gemmell
            sinuswave Bernhard Seidl
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: