Announcement Announcement Module
Collapse
No announcement yet.
Sending messages TO JMS Queue without Spring JMSTemplate Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Sending messages TO JMS Queue without Spring JMSTemplate

    have a spring based application and I want to initialize a message producer in the spring beans configuration file to send the messages. I cannot use JMS template to send the messages. So i want to initialize a message producer in spring beans file that can be used to send messages. But I cant find any implementation of Messageproducer in Spring 3.x and cant find how to initialize the Message producer through spring beans configuration file. I tried something like this shown below. A part of the configuration file to intialize MessageProducer :-

    <bean id="connection" class="org.springframework.jms.JmsConnectionFactor yBean">
    <property name="connectionFactory"><ref bean="connectionFactory"/></property>
    </bean>

    <bean id="jmsSession" class="org.springframework.jms.JmsSessionFactoryBe an">
    <property name="connection"><ref bean="connection"/></property>
    </bean>

    <bean id="producer" class="org.springframework.jms.JmsProducerFactoryB ean">
    <property name="session"><ref bean="jmsSession"/></property>
    <property name="destination"><ref bean="senderDestination"/></property>
    </bean>
    But these API's are not supported in spring 3.x. Any help would be appreciated.

    Regards

  • #2
    Can you explain why you can't use JmsTemplate?

    Comment


    • #3
      as per few posts, it is said that production environment where high performance is required, jmstmeplate should not be used as it has some performance issues.

      Comment


      • #4
        Instead of premature optimization first test the JmsTemplate, I never encountered performance issues with JmsTemplate even in high performance situations. In general it is misuse and misconfiguration that lead to performance issues then the JmsTemplate itself.

        Comment


        • #5
          I also replied on your StackOverflow thread, but will add the same here....

          I think you may be referring to some very old posts that were written before Spring added support for caching resources (sessions, producers, etc). See the CachingConnectionFactory documentation for more details.

          Bottom line: there should be no need to avoid JmsTemplate for performance reasons.

          Comment


          • #6
            I would have to do a POC to show it to my seniors that there is no issue with jmstemplate. For now, i cant use jmstemplate immediately, I would really appreciate if you can help in configuring MessageProducer in spring configuration file

            Comment


            • #7
              A MessageProducer is created from a Session which is acquired from a Connection which is established via a ConnectionFactory.

              That chain is precisely what JmsTemplate handles for you, AND with Spring's CachingConnectionFactory it enables caching of the Session as well as generated Producers. So, unless you are going to spend a LOT of time rebuilding what JmsTemplate and CachingConnectionFactory already do, you are not likely to have better performance than what JmsTemplate offers today.

              Hopefully that clarifies a bit.

              Comment


              • #8
                Thanks for the reply MArk. Itried something like this to begin with..
                <bean id="connection" class="org.springframework.jms.JmsConnectionFactor yBean">
                <property name="connectionFactory"><ref bean="connectionFactory"/></property>
                </bean>

                <bean id="jmsSession" class="org.springframework.jms.JmsSessionFactoryBe an">
                <property name="connection"><ref bean="connection"/></property>
                </bean>

                <bean id="producer" class="org.springframework.jms.JmsProducerFactoryB ean">
                <property name="session"><ref bean="jmsSession"/></property>
                <property name="destination"><ref bean="senderDestination"/></property>
                </bean>

                But in spring 3.1, the classes org.springframework.jms.JmsConnectionFactoryBean and other specified above doesnt exist anymore.. And i am not able to fidn the corresponding classes in 3.1

                Comment


                • #9
                  I don't think those classes ever existed in a Spring release. They were in a sandbox prototype in the Spring 1.x days many years ago IIRC.

                  The way to work with JMS via Spring is through JmsTemplate, and if you are still concerned, all I can say is that a huge number of enterprise applications are using JmsTemplate. Can you provide a link to the articles that are making you question that? I am pretty sure they are not relevant if you follow the documented recommendations (e.g. using CachingConnectionFactory).

                  Comment

                  Working...
                  X