Uploaded image for project: 'Spring Web Services'
  1. Spring Web Services
  2. SWS-473

JmsSenderConnection does not commit transaction after send, leading to messages never being sent if sessionTransacted is true

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.5.3, 1.5.4, 1.5.5
    • Fix Version/s: 1.5.6
    • Component/s: Core
    • Labels:
      None

      Description

      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:

      JmsTemplate.java

      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.
      				JmsUtils.commitIfNecessary(session);
      			}
      		}
      		finally {
      			JmsUtils.closeMessageProducer(producer);
      		}
      	}

      Similarly, the following should be done in JmsSenderConnection:

      JmsSenderConnection.java

      protected void onSendAfterWrite(WebServiceMessage message) throws IOException {
              MessageProducer messageProducer = null;
              try {
                  messageProducer = session.createProducer(requestDestination);
                  messageProducer.setDeliveryMode(deliveryMode);
                  messageProducer.setTimeToLive(timeToLive);
                  messageProducer.setPriority(priority);
                  if (responseDestination == null) {
                      responseDestination = session.createTemporaryQueue();
                  }
                  requestMessage.setJMSReplyTo(responseDestination);
                  connection.start();
                  messageProducer.send(requestMessage);
                  if (session.getTransacted()) {
                     JmsUtils.commitIfNecessary(session);
                  }
              }
              catch (JMSException ex) {
                  throw new JmsTransportException(ex);
              }
              finally {
                  JmsUtils.closeMessageProducer(messageProducer);
              }
          }

        Activity

        jdenly Jon Denly created issue -
        Hide
        arjen.poutsma Arjen Poutsma added a comment -

        Thanks for spotting this, it will be fixed in 1.5.6

        Show
        arjen.poutsma Arjen Poutsma added a comment - Thanks for spotting this, it will be fixed in 1.5.6
        arjen.poutsma Arjen Poutsma made changes -
        Field Original Value New Value
        Fix Version/s 1.5.6 [ 11141 ]
        arjen.poutsma Arjen Poutsma made changes -
        Status Open [ 1 ] In Progress [ 3 ]
        Hide
        arjen.poutsma Arjen Poutsma added a comment -

        Fixed. Thanks for spotting this!

        Show
        arjen.poutsma Arjen Poutsma added a comment - Fixed. Thanks for spotting this!
        arjen.poutsma Arjen Poutsma made changes -
        Resolution Fixed [ 1 ]
        Status In Progress [ 3 ] Resolved [ 5 ]
        Hide
        arjen.poutsma Arjen Poutsma added a comment -

        Closing old issues

        Show
        arjen.poutsma Arjen Poutsma added a comment - Closing old issues
        arjen.poutsma Arjen Poutsma made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open In Progress In Progress
        5d 8h 6m 1 Arjen Poutsma 12/Jan/09 9:00 PM
        In Progress In Progress Resolved Resolved
        57m 1 Arjen Poutsma 12/Jan/09 9:57 PM
        Resolved Resolved Closed Closed
        1207d 9h 6m 1 Arjen Poutsma 04/May/12 7:03 AM

          People

          • Assignee:
            arjen.poutsma Arjen Poutsma
            Reporter:
            jdenly Jon Denly
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: