Announcement Announcement Module
Collapse
No announcement yet.
Problem with defaultDestination in JsmTemplate Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem with defaultDestination in JsmTemplate

    I'm trying to follow an online example and get the below error message. I don't see where from many examples I would have to provide one, let alone HOW to apply one.

    Code:
    DEBUG - tcp://localhost/127.0.0.1:9999 before negotiation: OpenWireFormat{version=5, cacheEnabled=false, stackTraceEnabled=false, tightEncodingEnabled=false, sizePrefixDisabled=false}
    DEBUG - tcp://localhost/127.0.0.1:9999 after negotiation: OpenWireFormat{version=5, cacheEnabled=true, stackTraceEnabled=true, tightEncodingEnabled=true, sizePrefixDisabled=false}
    DEBUG - Setting up new connection: /127.0.0.1:36197
    DEBUG - localhost adding destination: topic://ActiveMQ.Advisory.Connection
    DEBUG - localhost adding consumer: ID:E53AEDA-44344-1269277001918-2:0:-1:1 for destination: topic://ActiveMQ.Advisory.TempQueue,topic://ActiveMQ.Advisory.TempTopic
    DEBUG - localhost adding consumer: ID:E53AEDA-44344-1269277001918-2:0:1:1 for destination: topic://org.apache.activemq.spring.Test.spring.topic
    DEBUG - localhost adding destination: topic://org.apache.activemq.spring.Test.spring.topic
    DEBUG - flush starting ...
    DEBUG - localhost adding destination: topic://ActiveMQ.Advisory.Topic
    DEBUG - localhost adding destination: topic://org.apache.activemq.spring.Test.spring.topic
    DEBUG - localhost adding destination: topic://ActiveMQ.Advisory.Consumer.Topic.org.apache.activemq.spring.Test.spring.topic
    Exception in thread "AWT-EventQueue-0" java.lang.IllegalStateException: No 'defaultDestination' or 'defaultDestinationName' specified. Check configuration of JmsTemplate.
    	at org.springframework.jms.core.JmsTemplate.getRequiredDefaultDestinationName(JmsTemplate.java:217)
    	at org.springframework.jms.core.JmsTemplate.send(JmsTemplate.java:529)
    	at org.mitre.mandi.JmsQueueSender.actionPerformed(JmsQueueSender.java:131)
    	at javax.swing.Timer.fireActionPerformed(Timer.java:293)
    	at javax.swing.Timer$DoPostEvent.run(Timer.java:224)
    	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:226)
    	at java.awt.EventQueue.dispatchEvent(EventQueue.java:602)
    	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:275)
    	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:200)
    	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
    	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:185)
    	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:177)
    	at java.awt.EventDispatchThread.run(EventDispatchThread.java:138)
    Here's the XML Spring configuration:
    Code:
    <beans xmlns="http://www.springframework.org/schema/beans"
    	xmlns:amq="http://activemq.apache.org/schema/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
      http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
    
    <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
    
      <!-- an embedded broker -->
    
      <bean id="broker" class="org.apache.activemq.broker.BrokerService" init-method="start">
        <property name="transportConnectorURIs">
          <list>
            <value>tcp://localhost:9999</value>
          </list>
        </property>
      </bean>
    
      <!-- JMS ConnectionFactory to use -->
      <bean id="jmsFactory"    class="org.apache.activemq.ActiveMQConnectionFactory">
        <property name="brokerURL" value="tcp://localhost:9999" />
      </bean>
    
      <!-- Spring JMS Template -->
      <bean id="myJmsTemplate"    class="org.springframework.jms.core.JmsTemplate">
        <property name="connectionFactory">
          <!-- lets wrap in a pool to avoid creating a connection per send -->
          <bean
            class="org.springframework.jms.connection.SingleConnectionFactory">
            <property name="targetConnectionFactory">
              <ref local="jmsFactory" />
            </property>
          </bean>
        </property>
      </bean>
      
      <!-- Spring JMS Template -->
      <bean id="consumerJmsTemplate" class="org.springframework.jms.core.JmsTemplate">
        <property name="connectionFactory" ref="jmsFactory"/>
      </bean>
    
      <bean id="destination" class="org.apache.activemq.command.ActiveMQTopic"
        autowire="constructor">
        <constructor-arg>
          <value>org.apache.activemq.spring.Test.spring.topic</value>
        </constructor-arg>
      </bean>
    
    	<!-- a sample POJO which uses a Spring JmsTemplate -->
    	<bean id="producer" class="org.mitre.mandi.JmsQueueSender">
    		<property name="jmsTemplate">
    			<ref bean="myJmsTemplate"></ref>
    		</property>
    
    		<property name="destination">
    			<ref bean="destination" />
    		</property>
    
    		<property name="messageCount">
    			<value>10</value>
    		</property>
    	</bean>
    
    	<!-- a sample POJO consumer -->
    	<bean id="consumer" class="org.mitre.mandi.JmsSynchronousListener">
    		<property name="jmsTemplate" ref="consumerJmsTemplate" />
    		<property name="destination" ref="destination" />
    	</bean>
    
    
    </beans>
    Any help would be appreciated.
    Kurt

  • #2
    Well, I found the some examples have:
    Code:
    getJmsTemplate().send(getDestination(),new MessageCreator() {
    			public Message createMessage(Session session) throws JMSException {
    				String text ="Using SendMessage. number="+incrementMe;
                    TextMessage message = session.createTextMessage(text);
                    logger.trace("*******"+text);
                    message.setStringProperty("next", "foo");
    
    				return message;
    
    			}
    		});
    and some leave out the "getDestination()," meaning it will attempt to use the default destination. If it (the default) is not in the applicationContext, good luck! I couldn't get the two defaults to agree, so it wouldn't work.

    Kurt

    Comment

    Working...
    X