Hello, I have simple service which should send message to queue
@Stateless public class PracownikServiceImpl implements PracownikService { @Resource(mappedName = "queue/TotalOrderQueue") private Queue queue; @Resource(mappedName = "ConnectionFactory") private ConnectionFactory jmsConnectionFactory; @Override @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) 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(); message.setText("Hello"); System.out.println("Sending message: " + message.getText()); producer.send(message); session.close(); connection.close(); } catch (JMSException e) { e.printStackTrace(); } System.out.println("koniec"); } } But it didn't. When I change connection.createSession(true, Session.AUTO_ACKNOWLEDGE); to 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
I found answer,
if you want to sending message to queue integrates with container transaction you should inject
@Resource(mappedName="java:/JmsXA")
private ConnectionFactory jmsConnectionFactory;