Hello everyone ,
I want to use activeMQ in jboss global transaction.
In fact, I will  have  a project with an oracle datasource and ActiveMQ.
What I want to do is combining in the same trasaction database update and
messages sending.
To do that , I followed the instructions here : 
http://activemq.apache.org/integrating-apache-activemq-with-jboss.html

To test it , i made this EJB for message sending :



package com.dams.test;

import javax.annotation.Resource;
import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.Destination;
import javax.jms.Message;
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.transaction.RollbackException;

import org.jboss.annotation.ejb.RemoteBinding;



@Stateless
@RemoteBinding(jndiBinding = MessageSenderInterface.JNDI_NAME)
public class MessageSender implements MessageSenderInterface{
        
        @Resource(mappedName="java:/activemq/QueueConnectionFactory")
        private ConnectionFactory queueConnectionFactory;
        
        final String queue ="queue/testDams";
        
        @TransactionAttribute(TransactionAttributeType.REQUIRED)
        public void sendMessage(String message,boolean throwError) throws 
Exception
{

                Connection connection 
=queueConnectionFactory.createConnection();
                Session session =connection.createSession(Boolean.TRUE,
Session.SESSION_TRANSACTED);
                Destination dest=session.createQueue(queue);
                MessageProducer producer=session.createProducer(dest);
                Message messages=session.createTextMessage(message);
                producer.send(messages);
                
                if(throwError) throw new 
RollbackException("Exceptiooooooooooooooooooon");      
        }
        
}


The problem is the message is send by the resource adapter even if tthe
rollBack exception is throw.

Help please.

Thank





--
View this message in context: 
http://activemq.2283324.n4.nabble.com/ActiveMQ-integration-in-jboss-tp4515292p4515292.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Reply via email to