Skip to content

Commit 7d4b41d

Browse files
committed
SWS-473
1 parent ae74e23 commit 7d4b41d

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

support/src/main/java/org/springframework/ws/transport/jms/JmsMessageSender.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ public WebServiceConnection createConnection(URI uri) throws IOException {
148148
wsConnection.setResponseDestination(resolveResponseDestination(jmsSession, uri));
149149
wsConnection.setTimeToLive(JmsTransportUtils.getTimeToLive(uri));
150150
wsConnection.setTextMessageEncoding(textMessageEncoding);
151+
wsConnection.setSessionTransacted(isSessionTransacted());
151152
wsConnection.setPostProcessor(postProcessor);
152153
return wsConnection;
153154
}

support/src/main/java/org/springframework/ws/transport/jms/JmsSenderConnection.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)