Skip to content

Commit

Permalink
Merge branch 'pr2931'
Browse files Browse the repository at this point in the history
  • Loading branch information
Brandon Devries committed Oct 2, 2018
2 parents 895323f + 76a9f98 commit b4c8e01
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,6 @@ public void consume(final String destinationName, final boolean durable, final b
this.jmsTemplate.execute(new SessionCallback<Void>() {
@Override
public Void doInJms(final Session session) throws JMSException {
// We need to call recover to ensure that in in the event of
// abrupt end or exception the current session will stop message
// delivery and restarts with the oldest unacknowledged message
session.recover();

final MessageConsumer msgConsumer = createMessageConsumer(session, destinationName, durable, shared, subscriberName);
try {
Expand Down Expand Up @@ -126,6 +122,12 @@ public Void doInJms(final Session session) throws JMSException {
// and if CLIENT_ACKNOWLEDGE is set.
consumerCallback.accept(response);
acknowledge(message, session);
} catch (Exception e) {
// We need to call recover to ensure that in the event of
// abrupt end or exception the current session will stop message
// delivery and restart with the oldest unacknowledged message
session.recover();
throw e;
} finally {
JmsUtils.closeMessageConsumer(msgConsumer);
}
Expand Down

0 comments on commit b4c8e01

Please sign in to comment.