public void start() throws AmqpException { if (logger.isDebugEnabled()) { logger.debug("Starting consumer " + this); } this.thread = Thread.currentThread(); try { this.resourceHolder = ConnectionFactoryUtils.getTransactionalResourceHolder(this.connectionFactory, this.transactional); this.channel = this.resourceHolder.getChannel(); ClosingRecoveryListener.addRecoveryListenerIfNecessary(this.channel); // NOSONAR never null here } catch (AmqpAuthenticationException e) { throw new FatalListenerStartupException("Authentication failure", e); } this.deliveryTags.clear(); this.activeObjectCounter.add(this); passiveDeclarations(); setQosAndreateConsumers(); }
public void start() throws AmqpException { if (logger.isDebugEnabled()) { logger.debug("Starting consumer " + this); } this.thread = Thread.currentThread(); try { this.resourceHolder = ConnectionFactoryUtils.getTransactionalResourceHolder(this.connectionFactory, this.transactional); this.channel = this.resourceHolder.getChannel(); ClosingRecoveryListener.addRecoveryListenerIfNecessary(this.channel); // NOSONAR never null here } catch (AmqpAuthenticationException e) { throw new FatalListenerStartupException("Authentication failure", e); } this.deliveryTags.clear(); this.activeObjectCounter.add(this); passiveDeclarations(); setQosAndreateConsumers(); }
@Test public void testTimeoutWaitForLocks() throws Exception { final Object object1 = new Object(); counter.add(object1); assertEquals(false, counter.await(200L, TimeUnit.MILLISECONDS)); }
@Test public void testWaitForLocks() throws Exception { final Object object1 = new Object(); final Object object2 = new Object(); counter.add(object1); counter.add(object2); Future<Boolean> future = Executors.newSingleThreadExecutor().submit(() -> { counter.release(object1); counter.release(object2); counter.release(object2); return true; }); assertEquals(true, counter.await(1000L, TimeUnit.MILLISECONDS)); assertEquals(true, future.get()); }
synchronized (this.consumersMonitor) { if (consumer != null) { this.cancellationLock.add(consumer); this.consumers.add(consumer); this.consumersByQueue.add(queue, consumer);
synchronized (this.consumersMonitor) { if (consumer != null) { this.cancellationLock.add(consumer); this.consumers.add(consumer); this.consumersByQueue.add(queue, consumer);
@Test public void testActiveCount() throws Exception { final Object object1 = new Object(); final Object object2 = new Object(); counter.add(object1); counter.add(object2); assertEquals(2, counter.getCount()); counter.release(object2); assertEquals(1, counter.getCount()); counter.release(object1); counter.release(object1); assertEquals(0, counter.getCount()); }