[SWS-473] JmsSenderConnection does not commit transaction after send, leading to messages never being sent if sessionTransacted is true Created: 07/Jan/09  Updated: 04/May/12  Resolved: 12/Jan/09

Status: Closed
Project: Spring Web Services
Component/s: Core
Affects Version/s: 1.5.3, 1.5.4, 1.5.5
Fix Version/s: 1.5.6

Type: Bug Priority: Major
Reporter: Jon Denly Assignee: Arjen Poutsma
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


When sending a JMS message using a org.springframework.ws.transport.jms.JmsMessageSender with sessionTransacted set to true, the org.springframework.ws.transport.jms.JmsSenderConnection.onSendAfterWrite method doesn't commit the transaction. This leads to the transaction being rolled back when the connection is closed so the message is never sent. JMSUtils.commitIfNecessary should be called before closing the message producer.

An example of how this is done in JmsTemplate:

protected void doSend(Session session, Destination destination, MessageCreator messageCreator)
			throws JMSException {

		Assert.notNull(messageCreator, "MessageCreator must not be null");
		MessageProducer producer = createProducer(session, destination);
		try {
			Message message = messageCreator.createMessage(session);
			if (logger.isDebugEnabled()) {
				logger.debug("Sending created message: " + message);
			doSend(producer, message);
			// Check commit - avoid commit call within a JTA transaction.
			if (session.getTransacted() && isSessionLocallyTransacted(session)) {
				// Transacted session created by this template -> commit.
		finally {

Similarly, the following should be done in JmsSenderConnection:

protected void onSendAfterWrite(WebServiceMessage message) throws IOException {
        MessageProducer messageProducer = null;
        try {
            messageProducer = session.createProducer(requestDestination);
            if (responseDestination == null) {
                responseDestination = session.createTemporaryQueue();
            if (session.getTransacted()) {
        catch (JMSException ex) {
            throw new JmsTransportException(ex);
        finally {

Comment by Arjen Poutsma [ 07/Jan/09 ]

Thanks for spotting this, it will be fixed in 1.5.6

Comment by Arjen Poutsma [ 12/Jan/09 ]

Fixed. Thanks for spotting this!

Comment by Arjen Poutsma [ 04/May/12 ]

Closing old issues

Generated at Mon Oct 22 19:37:19 UTC 2018 using JIRA 7.9.2#79002-sha1:3bb15b68ecd99a30eb364c4c1a393359bcad6278.