Announcement Announcement Module
Collapse
No announcement yet.
Drawbacks of using JmsTemplate? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Drawbacks of using JmsTemplate?

    Hi,

    I'm pretty familiar with JMS and its use outside of the Spring Framework. However, I'm looking into using JmsTemplate and had a few questions.

    1. If the message producer uses JmsTemplate to create the message, then the consumer uses JmsTemplate to receive the call, will this cause the message producer to block until the consumer returns with a reply? Is there some safeguard on the producer's side to always send the message asynchronously and not have to block? Is there a way to prohibit the consumer from blocking the call?

    2. Why can JmsTemplate only be used for synchronous message consumption and not asynchronous consumption? Will there be any future support for asynchronous messages in a Spring template?

    3. What are the pros/cons of using JmsTemplate over a regular JMS provider? I've read the Spring JMS documentation (http://www.springframework.org/docs/reference/jms.html), but it doesn't provide any gotchas or drawbacks of using JmsTemplate as a provider.

    Thanks in advance!
    Last edited by lam6252; Feb 20th, 2007, 05:29 PM.

  • #2
    Originally posted by lam6252 View Post
    1. If the message producer uses JmsTemplate to create the message, then the consumer uses JmsTemplate to receive the call, will this cause the message producer to block until the consumer returns with a reply? Is there some safeguard on the producer's side to always send the message asynchronously and not have to block? Is there a way to prohibit the consumer from blocking the call?
    One of the main points of JMS is to decouple producers and consumers from each other in terms of location and time. So a send only blocks until the broker receives it - not until the consumer has processed it.


    2. Why can JmsTemplate only be used for synchronous message consumption and not asynchronous consumption? Will there be any future support for asynchronous messages in a Spring template?
    Try the message container stuff in Spring 2 or Jencks


    3. What are the pros/cons of using JmsTemplate over a regular JMS provider? I've read the Spring JMS documentation (http://www.springframework.org/docs/reference/jms.html), but it doesn't provide any gotchas or drawbacks of using JmsTemplate as a provider.
    Here's the JmsTemplate gotchas

    Comment


    • #3
      jmstempalte Send hangs

      I am trying to put a message in a specific topic.But the program hangs on the send call. I see the message is put in the IBM MQ Series Queue. Can you provide any suggestions on this ?

      Java call
      Code:
      public void sendMesage(){
      		
      		System.out.println("sending message for " + getDestinationName());
      		//jmsTemplate102.setDeliveryMode(org.springframework.jms.core.JmsTemplate.)setReceiveTimeout(1000);
      		//jmsTemplate102.setSessionAcknowledgeMode(Session.AUTO_ACKNOWLEDGE);
      		jmsTemplate102.send(getDestinationName(), new MessageCreator() {
      			      public Message createMessage(Session session) throws JMSException {
      		    	  System.out.println( session.getAcknowledgeMode());
      		    	  Message message = session.createTextMessage("This is a sample message for -  " + getDestinationName());
      		           return message ;
      		      }
      		     
      		    });
      Configuration
      Code:
      <!-- Internal JMS Topic Connection Factory -->
          <bean id="internalJmsTopicConnectionFactory"
              class="org.springframework.jndi.JndiObjectFactoryBean">
              <property name="jndiTemplate">
                  <ref bean="jndiTemplate"/>
              </property>
              <property name="jndiName">
                  <value>MQ_JMS_TOPIC_MANAGER</value>
              </property>
          </bean>
      
        <!-- Spring JMS Topic Connection Factory -->
       <bean id="jmsTopicConnectionFactory"
              class="org.springframework.jms.connection.SingleConnectionFactory102">
              <property name="targetConnectionFactory">
                  <ref bean="internalJmsTopicConnectionFactory"/>
              </property>
          <property name="pubSubDomain">
                  <value>true</value>
              </property> 
          </bean>
      
      <bean id="jmsDestinationResolver"
              class="org.springframework.jms.support.destination.JndiDestinationResolver">
              <property name="jndiTemplate">
                  <ref bean="jndiTemplate"/>
              </property>
              <property name="cache">
                  <value>true</value>
              </property>
          </bean>
      
      
        <bean id="jmsTopicTemplate" class="org.springframework.jms.core.JmsTemplate">
              <property name="connectionFactory">
                  <ref bean="jmsTopicConnectionFactory"/>
              </property>
              <property name="destinationResolver">
                  <ref bean="jmsDestinationResolver"/>
              </property>
               <property name="pubSubDomain">
                  <value>true</value>
              </property>
               <property name="receiveTimeout">
                  <value>10</value>
              </property> 
             </bean>
      
         <bean id="jmsTopicPublisher" class="springexample.client.JMSSender" >
            <property name="jmsTemplate102">
                  <ref bean="jmsTopicTemplate"/>
              </property>
              <property name="destinationName">
                  <value>JMS_TopicQueue</value>
              </property>
            </bean>

      Comment

      Working...
      X