This commit is contained in:
Arjen Poutsma
2009-01-13 11:56:52 +00:00
parent ae74e23d45
commit 7d4b41dbfe
2 changed files with 17 additions and 2 deletions

View File

@@ -148,6 +148,7 @@ public class JmsMessageSender extends JmsDestinationAccessor implements WebServi
wsConnection.setResponseDestination(resolveResponseDestination(jmsSession, uri));
wsConnection.setTimeToLive(JmsTransportUtils.getTimeToLive(uri));
wsConnection.setTextMessageEncoding(textMessageEncoding);
wsConnection.setSessionTransacted(isSessionTransacted());
wsConnection.setPostProcessor(postProcessor);
return wsConnection;
}

View File

@@ -79,6 +79,8 @@ public class JmsSenderConnection extends AbstractSenderConnection {
private MessagePostProcessor postProcessor;
private boolean sessionTransacted = false;
/** Constructs a new JMS connection with the given parameters. */
protected JmsSenderConnection(ConnectionFactory connectionFactory,
Connection connection,
@@ -142,6 +144,10 @@ public class JmsSenderConnection extends AbstractSenderConnection {
this.postProcessor = postProcessor;
}
void setSessionTransacted(boolean sessionTransacted) {
this.sessionTransacted = sessionTransacted;
}
/*
* URI
*/
@@ -209,6 +215,9 @@ public class JmsSenderConnection extends AbstractSenderConnection {
}
connection.start();
messageProducer.send(requestMessage);
if (session.getTransacted() && isSessionLocallyTransacted(session)) {
JmsUtils.commitIfNecessary(session);
}
}
catch (JMSException ex) {
throw new JmsTransportException(ex);
@@ -218,9 +227,14 @@ public class JmsSenderConnection extends AbstractSenderConnection {
}
}
/** @see org.springframework.jms.core.JmsTemplate#isSessionLocallyTransacted(Session) */
private boolean isSessionLocallyTransacted(Session session) {
return sessionTransacted && !ConnectionFactoryUtils.isSessionTransactional(session, connectionFactory);
}
/*
* Receiving
*/
* Receiving
*/
protected void onReceiveBeforeRead() throws IOException {
MessageConsumer messageConsumer = null;