@@ -79,6 +79,8 @@ public class JmsSenderConnection extends AbstractSenderConnection {
7979
8080 private MessagePostProcessor postProcessor ;
8181
82+ private boolean sessionTransacted = false ;
83+
8284 /** Constructs a new JMS connection with the given parameters. */
8385 protected JmsSenderConnection (ConnectionFactory connectionFactory ,
8486 Connection connection ,
@@ -142,6 +144,10 @@ void setPostProcessor(MessagePostProcessor postProcessor) {
142144 this .postProcessor = postProcessor ;
143145 }
144146
147+ void setSessionTransacted (boolean sessionTransacted ) {
148+ this .sessionTransacted = sessionTransacted ;
149+ }
150+
145151 /*
146152 * URI
147153 */
@@ -209,6 +215,9 @@ protected void onSendAfterWrite(WebServiceMessage message) throws IOException {
209215 }
210216 connection .start ();
211217 messageProducer .send (requestMessage );
218+ if (session .getTransacted () && isSessionLocallyTransacted (session )) {
219+ JmsUtils .commitIfNecessary (session );
220+ }
212221 }
213222 catch (JMSException ex ) {
214223 throw new JmsTransportException (ex );
@@ -218,9 +227,14 @@ protected void onSendAfterWrite(WebServiceMessage message) throws IOException {
218227 }
219228 }
220229
230+ /** @see org.springframework.jms.core.JmsTemplate#isSessionLocallyTransacted(Session) */
231+ private boolean isSessionLocallyTransacted (Session session ) {
232+ return sessionTransacted && !ConnectionFactoryUtils .isSessionTransactional (session , connectionFactory );
233+ }
234+
221235 /*
222- * Receiving
223- */
236+ * Receiving
237+ */
224238
225239 protected void onReceiveBeforeRead () throws IOException {
226240 MessageConsumer messageConsumer = null ;
0 commit comments