@Override protected void releaseResource(RabbitResourceHolder resourceHolder, Object resourceKey) { ConnectionFactoryUtils.releaseResources(resourceHolder); }
@Override protected void releaseResource(RabbitResourceHolder resourceHolder, Object resourceKey) { ConnectionFactoryUtils.releaseResources(resourceHolder); }
private void cleanUpAfterAction(Channel channel, boolean invokeScope, RabbitResourceHolder resourceHolder, Connection connection) { if (!invokeScope) { if (resourceHolder != null) { ConnectionFactoryUtils.releaseResources(resourceHolder); } else { RabbitUtils.closeChannel(channel); RabbitUtils.closeConnection(connection); } } }
private void cleanUpAfterAction(Channel channel, boolean invokeScope, RabbitResourceHolder resourceHolder, Connection connection) { if (!invokeScope) { if (resourceHolder != null) { ConnectionFactoryUtils.releaseResources(resourceHolder); } else { RabbitUtils.closeChannel(channel); RabbitUtils.closeConnection(connection); } } }
public synchronized void stop() { if (this.abortStarted == 0) { // signal handle delivery to use offer this.abortStarted = System.currentTimeMillis(); } if (!this.cancelled()) { try { RabbitUtils.closeMessageConsumer(this.channel, getConsumerTags(), this.transactional); } catch (Exception e) { if (logger.isDebugEnabled()) { logger.debug("Error closing consumer " + this, e); } } } if (logger.isDebugEnabled()) { logger.debug("Closing Rabbit Channel: " + this.channel); } RabbitUtils.setPhysicalCloseRequired(this.channel, true); ConnectionFactoryUtils.releaseResources(this.resourceHolder); this.deliveryTags.clear(); this.consumers.clear(); this.queue.clear(); // in case we still have a client thread blocked }
private void cleanUpAfterAction(RabbitResourceHolder resourceHolder, Connection connection, Channel channel, ConfirmListener listener) { if (listener != null) { channel.removeConfirmListener(listener); } this.activeTemplateCallbacks.decrementAndGet(); this.dedicatedChannels.remove(); if (resourceHolder != null) { ConnectionFactoryUtils.releaseResources(resourceHolder); } else { RabbitUtils.closeChannel(channel); RabbitUtils.closeConnection(connection); } }
public synchronized void stop() { if (this.abortStarted == 0) { // signal handle delivery to use offer this.abortStarted = System.currentTimeMillis(); } if (!this.cancelled()) { try { RabbitUtils.closeMessageConsumer(this.channel, getConsumerTags(), this.transactional); } catch (Exception e) { if (logger.isDebugEnabled()) { logger.debug("Error closing consumer " + this, e); } } } if (logger.isDebugEnabled()) { logger.debug("Closing Rabbit Channel: " + this.channel); } RabbitUtils.setPhysicalCloseRequired(this.channel, true); ConnectionFactoryUtils.releaseResources(this.resourceHolder); this.deliveryTags.clear(); this.consumers.clear(); this.queue.clear(); // in case we still have a client thread blocked }
private void cleanUpAfterAction(RabbitResourceHolder resourceHolder, Connection connection, Channel channel, ConfirmListener listener) { if (listener != null) { channel.removeConfirmListener(listener); } this.activeTemplateCallbacks.decrementAndGet(); this.dedicatedChannels.remove(); if (resourceHolder != null) { ConnectionFactoryUtils.releaseResources(resourceHolder); } else { RabbitUtils.closeChannel(channel); RabbitUtils.closeConnection(connection); } }
private void cleanUpAfterInvoke(@Nullable RabbitResourceHolder resourceHolder, Channel channelToUse, boolean boundHere) { if (resourceHolder != null && boundHere) { // so the channel exposed (because exposeListenerChannel is false) will be closed resourceHolder.setSynchronizedWithTransaction(false); } ConnectionFactoryUtils.releaseResources(resourceHolder); // NOSONAR - null check in method if (boundHere) { // unbind if we bound TransactionSynchronizationManager.unbindResource(this.getConnectionFactory()); if (!isExposeListenerChannel() && isChannelLocallyTransacted()) { /* * commit the temporary channel we exposed; the consumer's channel * will be committed later. Note that when exposing a different channel * when there's no transaction manager, the exposed channel is committed * on each message, and not based on txSize. */ RabbitUtils.commitIfNecessary(channelToUse); } } }
channel = resourceHolder.getChannel(); if (channel == null) { ConnectionFactoryUtils.releaseResources(resourceHolder); throw new IllegalStateException("Resource holder returned a null channel");
channel = resourceHolder.getChannel(); if (channel == null) { ConnectionFactoryUtils.releaseResources(resourceHolder); throw new IllegalStateException("Resource holder returned a null channel");
channel = resourceHolder.getChannel(); if (channel == null) { ConnectionFactoryUtils.releaseResources(resourceHolder); throw new IllegalStateException("Resource holder returned a null channel");
private void cleanUpAfterInvoke(@Nullable RabbitResourceHolder resourceHolder, Channel channelToUse, boolean boundHere) { if (resourceHolder != null && boundHere) { // so the channel exposed (because exposeListenerChannel is false) will be closed resourceHolder.setSynchronizedWithTransaction(false); } ConnectionFactoryUtils.releaseResources(resourceHolder); // NOSONAR - null check in method if (boundHere) { // unbind if we bound TransactionSynchronizationManager.unbindResource(this.getConnectionFactory()); if (!isExposeListenerChannel() && isChannelLocallyTransacted()) { /* * commit the temporary channel we exposed; the consumer's channel * will be committed later. Note that when exposing a different channel * when there's no transaction manager, the exposed channel is committed * on each message, and not based on txSize. */ RabbitUtils.commitIfNecessary(channelToUse); } } }
channel = resourceHolder.getChannel(); if (channel == null) { ConnectionFactoryUtils.releaseResources(resourceHolder); throw new IllegalStateException("Resource holder returned a null channel");
@Override protected void doBegin(Object transaction, TransactionDefinition definition) { if (definition.getIsolationLevel() != TransactionDefinition.ISOLATION_DEFAULT) { throw new InvalidIsolationLevelException("AMQP does not support an isolation level concept"); } RabbitTransactionObject txObject = (RabbitTransactionObject) transaction; RabbitResourceHolder resourceHolder = null; try { resourceHolder = ConnectionFactoryUtils.getTransactionalResourceHolder(getConnectionFactory(), true); if (logger.isDebugEnabled()) { logger.debug("Created AMQP transaction on channel [" + resourceHolder.getChannel() + "]"); } // resourceHolder.declareTransactional(); txObject.setResourceHolder(resourceHolder); txObject.getResourceHolder().setSynchronizedWithTransaction(true); int timeout = determineTimeout(definition); if (timeout != TransactionDefinition.TIMEOUT_DEFAULT) { txObject.getResourceHolder().setTimeoutInSeconds(timeout); } TransactionSynchronizationManager.bindResource(getConnectionFactory(), txObject.getResourceHolder()); } catch (AmqpException ex) { if (resourceHolder != null) { ConnectionFactoryUtils.releaseResources(resourceHolder); } throw new CannotCreateTransactionException("Could not create AMQP transaction", ex); } }
@Override protected void doBegin(Object transaction, TransactionDefinition definition) { if (definition.getIsolationLevel() != TransactionDefinition.ISOLATION_DEFAULT) { throw new InvalidIsolationLevelException("AMQP does not support an isolation level concept"); } RabbitTransactionObject txObject = (RabbitTransactionObject) transaction; RabbitResourceHolder resourceHolder = null; try { resourceHolder = ConnectionFactoryUtils.getTransactionalResourceHolder(getConnectionFactory(), true); if (logger.isDebugEnabled()) { logger.debug("Created AMQP transaction on channel [" + resourceHolder.getChannel() + "]"); } // resourceHolder.declareTransactional(); txObject.setResourceHolder(resourceHolder); txObject.getResourceHolder().setSynchronizedWithTransaction(true); int timeout = determineTimeout(definition); if (timeout != TransactionDefinition.TIMEOUT_DEFAULT) { txObject.getResourceHolder().setTimeoutInSeconds(timeout); } TransactionSynchronizationManager.bindResource(getConnectionFactory(), txObject.getResourceHolder()); } catch (AmqpException ex) { if (resourceHolder != null) { ConnectionFactoryUtils.releaseResources(resourceHolder); } throw new CannotCreateTransactionException("Could not create AMQP transaction", ex); } }