Results 1 to 9 of 9

Thread: Sending messages TO JMS Queue without Spring JMSTemplate

  1. #1

    Default 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. #2
    Join Date
    Oct 2005
    Location
    Boston, MA
    Posts
    2,854

    Default

    Can you explain why you can't use JmsTemplate?

  3. #3

    Default

    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.

  4. #4
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,695

    Default

    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.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  5. #5
    Join Date
    Oct 2005
    Location
    Boston, MA
    Posts
    2,854

    Default

    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.

  6. #6

    Default

    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

  7. #7
    Join Date
    Oct 2005
    Location
    Boston, MA
    Posts
    2,854

    Default

    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.

  8. #8

    Default

    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

  9. #9
    Join Date
    Oct 2005
    Location
    Boston, MA
    Posts
    2,854

    Default

    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).

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •