SwiftMQ 7.5.4 with Spring and com.swiftmq.jms.springsupport.SingleSharedConnectionFactory

View: New views
3 Messages — Rating Filter:   Alert me  

SwiftMQ 7.5.4 with Spring and com.swiftmq.jms.springsupport.SingleSharedConnectionFactory

by bjoernlohrmann :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

We are building a small test-app to evaluate solutions to the problem posted by michaelzilske in http://www.nabble.com/Messages-out-of-sequence-%28jboss-and-swiftmq%29-td12734756.html

Our test-app starts a transaction, sends 5 messages in it and commits. For each message it does the following:
- retrieve a connection from a SingleSharedConnectionFactory and invoke start() on it
- create Session, MessageProducer and Message
- send the message
- close producer, session and connection

The first transaction works fine. The second one gives the following exception when trying to invoke start() on the connection for the first time:

 javax.jms.IllegalStateException: This connection is not associated with a ManagedConnection instance!
        at com.swiftmq.connector.v15.outbound.ConnectionImpl.start(Unknown Source)
        at com.swiftmq.jms.springsupport.SharedJMSConnection.start(Unknown Source)
        at de.ivu.jmsxatest.beans.JMSXAFacadeImpl.sendMessageAndCloseConnection(JMSXAFacadeImpl.java:54)
        [...]

The setup is as follows:
- Websphere 6.1 with SwiftMQ 7.5.4 (extra-vm via RA)
- JMSXAFacadeImpl is a Spring bean into which an instance of SingleSharedConnectionFactory is injected. We have also tried Spring's SingleConnectionFactory and CachingConnectionFactory. They exhibit the same behaviour.
- Transaction manager is JTA as defined by spring config (<tx:jta-transaction-manager/>)

A test EAR that exhibits the described behaviour is attached jmsxatestEAR.ear (contains source code)  If deployed it offers a servlet under /jmsxatestservlet/test. Each call to the servlet corresponds to one transaction, hence you need to call it twice. The EAR uses the JNDI-Names "jms/CF" and "jms/testqueue".


Re: SwiftMQ 7.5.4 with Spring and com.swiftmq.jms.springsupport.SingleSharedConnectionFactory

by IIT Software :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

This is wrong. You may not use SingleSharedConnectionFactory nor can you invoke start() in a J2EE environment. As a J2EE component you have nothing to do with pooling etc. That's the responsibility of the app server in conjunction with the resource adapter. You simple create connection/session/producer, send your messages and close everything down. Behind the scene the app server allocates ManagedConnection instances (out of connection pools) and associates it with the connection you have created. Your connection is only a "handle". Have a look at the sample MDB (with send) in the How To.


Re: SwiftMQ 7.5.4 with Spring and com.swiftmq.jms.springsupport.SingleSharedConnectionFactory

by IIT Software :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Just for clarification: Spring's JMS support is primarily designed to work inside a J2EE container where the container provides connection pooling etc. If you use Spring's JMS support outside a J2EE container - in a normal Spring app - you miss the pooling and it turns sub-optimal. Therefore we provide our springsupport lib which provides the pooling you normally get from the app server.