[jboss-user] [Messaging, JMS & JBossMQ] - MDB and connection to a remote queue with transaction

mclu do-not-reply at jboss.com
Tue Dec 19 10:47:34 EST 2006


Like
http://www.jboss.com/index.html?module=bb&op=viewtopic&t=91589
I have the same or equal problem.

I have 2 JBoss Servers(A and B). Both 4.0.5 with Messaging 1.0.1 GA

On A I have an MDB listen on a local queue
inside the onmessage it should get the message and send a Result to a Queue on Server B.

Inside my MDB on A I create a connection using B´s JNDI and look for XAConnectionFactory.
I open the session like this:
session = conn.createSession(true, Session.AUTO_ACKNOWLEDGE);

But after the onMessage returns the Message is still not in the DB on B.

If I do it like
session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
it works.

It works also, if I use TRUE and commit the session explicitly with session.comit(); But if then an exception on A occurs I have the Message still in A and already in B.

Question:
How can I span my JTA Transaction of Server A to include the send to B?


Now some config stuff follows:
My MDB Config:
<message-driven>
  |             <ejb-name>SyncRequestSenderMDB</ejb-name>
  |             <ejb-class>com.XXX.send.SyncRequestSenderMDB</ejb-class>
  |             <transaction-type>Container</transaction-type>
  |             <message-driven-destination>
  |                <destination-type>javax.jms.Queue</destination-type>
  |             </message-driven-destination>
  |         </message-driven>
  |     </enterprise-beans>
  |     <assembly-descriptor>
  |     <container-transaction>
  |       <method>
  |         <ejb-name>SyncRequestSenderMDB</ejb-name>
  |         <method-name>*</method-name>
  |       </method>
  |       <trans-attribute>Required</trans-attribute>
  |     </container-transaction>
  |      </assembly-descriptor>

My remote send call:

  | Connection conn = null;
  | 	MessageProducer sender = null;
  | 	try {
  | 
  | 		conn = getConnection();
  | 		boolean transacted = true;
  | 		session = conn
  | 				.createSession(transacted, Session.AUTO_ACKNOWLEDGE);
  | 
  | 		sender = session.createProducer(sendQueue);
  | 
  | 		TextMessage tm = session.createTextMessage(syncMessage.getMessageAsString());
  | 		
  | 		sender.send(tm);
  | 		Logger.debug(this, "Message sent to IM Server");
  | 		// with this it will be send
  |                                 // session.commit();
  | 		
  | 	} catch (JMSException e) {
  | 		throw new RuntimeException(
  | 				"Problems sending Sync Message to IM Server Queue.", e);
  | 	} finally {
  | 		if (sender != null)
  | 			try {
  | 				sender.close();
  | 			} catch (Exception ignore) {
  | 			}
  | 		if (session != null)
  | 			try {
  | 				session.close();
  | 			} catch (Exception ignore) {
  | 			}
  | 		if (conn != null)
  | 			try {
  | 				conn.close();
  | 			} catch (Exception ignore) {
  | 			}
  | 	}

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3995038#3995038

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3995038




More information about the jboss-user mailing list