List of usage examples for org.springframework.amqp.rabbit.connection ConnectionFactoryUtils bindResourceToTransaction
public static RabbitResourceHolder bindResourceToTransaction(RabbitResourceHolder resourceHolder, ConnectionFactory connectionFactory, boolean synched)
From source file:org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.java
private boolean receiveAndExecute(final BlockingQueueConsumer consumer) throws Throwable { if (this.transactionManager != null) { try {//w w w . j a v a2 s .c o m return new TransactionTemplate(this.transactionManager, this.transactionAttribute) .execute(new TransactionCallback<Boolean>() { @Override public Boolean doInTransaction(TransactionStatus status) { ConnectionFactoryUtils.bindResourceToTransaction( new RabbitResourceHolder(consumer.getChannel(), false), getConnectionFactory(), true); try { return doReceiveAndExecute(consumer); } catch (RuntimeException e) { throw e; } catch (Throwable e) { //NOSONAR // ok to catch Throwable here because we re-throw it below throw new WrappedTransactionException(e); } } }); } catch (WrappedTransactionException e) { throw e.getCause(); } } return doReceiveAndExecute(consumer); }