Codota Logo
ActiveObjectCounter
Code IndexAdd Codota to your IDE (free)

How to use
ActiveObjectCounter
in
org.springframework.amqp.rabbit.listener

Best Java code snippets using org.springframework.amqp.rabbit.listener.ActiveObjectCounter (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
Connection c =
  • Codota IconDataSource dataSource;dataSource.getConnection()
  • Codota IconString url;DriverManager.getConnection(url)
  • Codota IconIdentityDatabaseUtil.getDBConnection()
  • Smart code suggestions by Codota
}
origin: spring-projects/spring-amqp

@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());
}
origin: spring-projects/spring-amqp

@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());
}
origin: spring-projects/spring-amqp

boolean finished = this.cancellationLock.await(getShutdownTimeout(), TimeUnit.MILLISECONDS);
if (finished) {
  logger.info("Successfully waited for workers to finish.");
this.cancellationLock.deactivate();
origin: spring-projects/spring-amqp

@Override
public void handleShutdownSignal(String consumerTag, ShutdownSignalException sig) {
  if (logger.isDebugEnabled()) {
    if (RabbitUtils.isNormalShutdown(sig)) {
      logger.debug("Received shutdown signal for consumer tag=" + consumerTag + ": " + sig.getMessage());
    }
    else {
      logger.debug("Received shutdown signal for consumer tag=" + consumerTag, sig);
    }
  }
  BlockingQueueConsumer.this.shutdown = sig;
  // The delivery tags will be invalid if the channel shuts down
  BlockingQueueConsumer.this.deliveryTags.clear();
  BlockingQueueConsumer.this.activeObjectCounter.release(BlockingQueueConsumer.this);
}
origin: spring-projects/spring-amqp

@Test
public void testTimeoutWaitForLocks() throws Exception {
  final Object object1 = new Object();
  counter.add(object1);
  assertEquals(false, counter.await(200L, TimeUnit.MILLISECONDS));
}
origin: spring-projects/spring-amqp

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();
}
origin: spring-projects/spring-amqp

@ManagedMetric(metricType = MetricType.GAUGE)
public int getActiveConsumerCount() {
  return this.cancellationLock.getCount();
}
origin: spring-projects/spring-amqp

if (this.cancellationLock.await(getShutdownTimeout(), TimeUnit.MILLISECONDS)) {
  this.logger.info("Successfully waited for consumers to finish.");
origin: spring-projects/spring-amqp

protected int initializeConsumers() {
  int count = 0;
  synchronized (this.consumersMonitor) {
    if (this.consumers == null) {
      this.cancellationLock.reset();
      this.consumers = new HashSet<BlockingQueueConsumer>(this.concurrentConsumers);
      for (int i = 0; i < this.concurrentConsumers; i++) {
        BlockingQueueConsumer consumer = createBlockingQueueConsumer();
        this.consumers.add(consumer);
        count++;
      }
    }
  }
  return count;
}
origin: spring-projects/spring-amqp

private void testRequeueOrNotDefaultYes(Exception ex, boolean expectedRequeue) throws Exception {
  ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
  Channel channel = mock(Channel.class);
  BlockingQueueConsumer blockingQueueConsumer = new BlockingQueueConsumer(connectionFactory,
      new DefaultMessagePropertiesConverter(), new ActiveObjectCounter<BlockingQueueConsumer>(),
      AcknowledgeMode.AUTO, true, 1, "testQ");
  testRequeueOrNotGuts(ex, expectedRequeue, channel, blockingQueueConsumer);
}
origin: spring-projects/spring-amqp

protected boolean cancelled() {
  return this.cancelled.get() || (this.abortStarted > 0 &&
      this.abortStarted + this.shutdownTimeout > System.currentTimeMillis())
      || !this.activeObjectCounter.isActive();
}
origin: org.springframework.amqp/spring-rabbit

@Override
public void handleShutdownSignal(String consumerTag, ShutdownSignalException sig) {
  if (logger.isDebugEnabled()) {
    if (RabbitUtils.isNormalShutdown(sig)) {
      logger.debug("Received shutdown signal for consumer tag=" + consumerTag + ": " + sig.getMessage());
    }
    else {
      logger.debug("Received shutdown signal for consumer tag=" + consumerTag, sig);
    }
  }
  BlockingQueueConsumer.this.shutdown = sig;
  // The delivery tags will be invalid if the channel shuts down
  BlockingQueueConsumer.this.deliveryTags.clear();
  BlockingQueueConsumer.this.activeObjectCounter.release(BlockingQueueConsumer.this);
}
origin: org.springframework.amqp/spring-rabbit

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();
}
origin: org.springframework.amqp/spring-rabbit

@ManagedMetric(metricType = MetricType.GAUGE)
public int getActiveConsumerCount() {
  return this.cancellationLock.getCount();
}
origin: org.springframework.amqp/spring-rabbit

if (this.cancellationLock.await(getShutdownTimeout(), TimeUnit.MILLISECONDS)) {
  this.logger.info("Successfully waited for consumers to finish.");
origin: org.springframework.amqp/spring-rabbit

protected int initializeConsumers() {
  int count = 0;
  synchronized (this.consumersMonitor) {
    if (this.consumers == null) {
      this.cancellationLock.reset();
      this.consumers = new HashSet<BlockingQueueConsumer>(this.concurrentConsumers);
      for (int i = 0; i < this.concurrentConsumers; i++) {
        BlockingQueueConsumer consumer = createBlockingQueueConsumer();
        this.consumers.add(consumer);
        count++;
      }
    }
  }
  return count;
}
origin: spring-projects/spring-amqp

private void testRequeueOrNotDefaultNo(Exception ex, boolean expectedRequeue) throws Exception {
  ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
  Channel channel = mock(Channel.class);
  BlockingQueueConsumer blockingQueueConsumer = new BlockingQueueConsumer(connectionFactory,
      new DefaultMessagePropertiesConverter(), new ActiveObjectCounter<BlockingQueueConsumer>(),
      AcknowledgeMode.AUTO, true, 1, false, "testQ");
  testRequeueOrNotGuts(ex, expectedRequeue, channel, blockingQueueConsumer);
}
origin: org.springframework.amqp/spring-rabbit

protected boolean cancelled() {
  return this.cancelled.get() || (this.abortStarted > 0 &&
      this.abortStarted + this.shutdownTimeout > System.currentTimeMillis())
      || !this.activeObjectCounter.isActive();
}
origin: spring-projects/spring-amqp

private void handleDeclarationException(int passiveDeclareRetries, DeclarationException e) {
  if (passiveDeclareRetries > 0 && this.channel.isOpen()) {
    if (logger.isWarnEnabled()) {
      logger.warn("Queue declaration failed; retries left=" + (passiveDeclareRetries), e);
      try {
        Thread.sleep(this.failedDeclarationRetryInterval);
      }
      catch (InterruptedException e1) {
        this.declaring = false;
        Thread.currentThread().interrupt();
        this.activeObjectCounter.release(this);
        throw RabbitExceptionTranslator.convertRabbitAccessException(e1); // NOSONAR stack trace loss
      }
    }
  }
  else if (e.getFailedQueues().size() < this.queues.length) {
    if (logger.isWarnEnabled()) {
      logger.warn("Not all queues are available; only listening on those that are - configured: "
          + Arrays.asList(this.queues) + "; not available: " + e.getFailedQueues());
    }
    this.missingQueues.addAll(e.getFailedQueues());
    this.lastRetryDeclaration = System.currentTimeMillis();
  }
  else {
    this.declaring = false;
    this.activeObjectCounter.release(this);
    throw new QueuesNotAvailableException("Cannot prepare queue for listener. "
        + "Either the queue doesn't exist or the broker will not allow us to use it.", e);
  }
}
origin: org.springframework.amqp/spring-rabbit

boolean finished = this.cancellationLock.await(getShutdownTimeout(), TimeUnit.MILLISECONDS);
if (finished) {
  logger.info("Successfully waited for workers to finish.");
this.cancellationLock.deactivate();
org.springframework.amqp.rabbit.listenerActiveObjectCounter

Javadoc

A mechanism to keep track of active objects.

Most used methods

  • add
  • await
  • getCount
  • release
  • deactivate
  • isActive
  • reset
  • <init>

Popular in Java

  • Updating database using SQL prepared statement
  • getResourceAsStream (ClassLoader)
  • getSupportFragmentManager (FragmentActivity)
    Return the FragmentManager for interacting with fragments associated with this activity.
  • runOnUiThread (Activity)
  • ConnectException (java.net)
    A ConnectException is thrown if a connection cannot be established to a remote host on a specific po
  • Socket (java.net)
    Provides a client-side TCP socket.
  • Permission (java.security)
    Abstract class for representing access to a system resource. All permissions have a name (whose inte
  • Timestamp (java.sql)
    A Java representation of the SQL TIMESTAMP type. It provides the capability of representing the SQL
  • Callable (java.util.concurrent)
    A task that returns a result and may throw an exception. Implementors define a single method with no
  • DateTimeFormat (org.joda.time.format)
    Factory that creates instances of DateTimeFormatter from patterns and styles. Datetime formatting i
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now