1 Reply Latest reply on Feb 12, 2010 12:46 PM by Mirek Sz

    Send message from stateless

    Mirek Sz Newbie

      Hello, I have simple service which should send message to queue


      public class PracownikServiceImpl implements PracownikService {
           @Resource(mappedName = "queue/TotalOrderQueue")
           private Queue queue;
           @Resource(mappedName = "ConnectionFactory")
           private ConnectionFactory jmsConnectionFactory;
           public void akcja() {
                Connection connection = null;
                Destination dest = (Destination) queue;
                Session session = null;
                try {
                     connection = jmsConnectionFactory.createConnection();
                     session = connection.createSession(true, Session.AUTO_ACKNOWLEDGE);
                     MessageProducer producer = session.createProducer(dest);
                     TextMessage message = session.createTextMessage();
                     System.out.println("Sending message: " + message.getText());
                } catch (JMSException e) {
      But it didn't. When I change
      connection.createSession(true, Session.AUTO_ACKNOWLEDGE);
      connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
      this works fine but I want send message trasactionaly. 
      I don't know why it dosen't work, it looks like the session don't integrate with container transaction
      How to resolve this problem
      Best regards