Tabnine Logo
DirectMessageListenerContainer.<init>
Code IndexAdd Tabnine to your IDE (free)

How to use
org.springframework.amqp.rabbit.listener.DirectMessageListenerContainer
constructor

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

origin: spring-projects/spring-amqp

@Override
protected DirectMessageListenerContainer createContainerInstance() {
  return new DirectMessageListenerContainer();
}
origin: org.springframework.amqp/spring-rabbit

@Override
protected DirectMessageListenerContainer createContainerInstance() {
  return new DirectMessageListenerContainer();
}
origin: spring-projects/spring-amqp

/**
 * Construct an instance using the supplied connection factory and event keys. Event
 * keys are patterns to match routing keys for events published to the
 * {@code amq.rabbitmq.event} topic exchange. They can therefore match wildcards;
 * examples are {@code user.#, queue.created}. Refer to the plugin documentation for
 * information about available events. A single-threaded
 * {@link DirectMessageListenerContainer} will be created; its lifecycle will be
 * controlled by this object's {@link SmartLifecycle} methods.
 * @param connectionFactory the connection factory.
 * @param eventKeys the event keys.
 */
public BrokerEventListener(ConnectionFactory connectionFactory, String... eventKeys) {
  this(new DirectMessageListenerContainer(connectionFactory), true, eventKeys);
}
origin: org.springframework.amqp/spring-rabbit

/**
 * Construct an instance using the supplied connection factory and event keys. Event
 * keys are patterns to match routing keys for events published to the
 * {@code amq.rabbitmq.event} topic exchange. They can therefore match wildcards;
 * examples are {@code user.#, queue.created}. Refer to the plugin documentation for
 * information about available events. A single-threaded
 * {@link DirectMessageListenerContainer} will be created; its lifecycle will be
 * controlled by this object's {@link SmartLifecycle} methods.
 * @param connectionFactory the connection factory.
 * @param eventKeys the event keys.
 */
public BrokerEventListener(ConnectionFactory connectionFactory, String... eventKeys) {
  this(new DirectMessageListenerContainer(connectionFactory), true, eventKeys);
}
origin: spring-projects/spring-amqp

@Override
protected AbstractMessageListenerContainer createContainer(AbstractConnectionFactory connectionFactory) {
  return new DirectMessageListenerContainer(connectionFactory);
}
origin: spring-projects/spring-amqp

@Override
protected AbstractMessageListenerContainer createContainer(AbstractConnectionFactory connectionFactory) {
  return new DirectMessageListenerContainer(connectionFactory);
}
origin: spring-projects/spring-integration

public IntegrationFlow amqpDMLCFlow(ConnectionFactory rabbitConnectionFactory, AmqpTemplate amqpTemplate) {
  return IntegrationFlows
      .from(Amqp.inboundGateway(new DirectMessageListenerContainer())
          .id("amqpInboundGateway")
          .configureContainer(c -> c
            .recoveryInterval(5000)
            .consumersPerQueue(1))
          .defaultReplyTo(defaultReplyTo().getName()))
      .transform("hello "::concat)
      .transform(String.class, String::toUpperCase)
      .get();
}
origin: spring-projects/spring-integration

DirectMessageListenerContainer dmlc = new DirectMessageListenerContainer();
dmlc.setConsumersPerQueue(this.consumersPerQueue);
container = dmlc;
origin: spring-projects/spring-amqp

@Test
public void testUninterruptibleListenerDMLC() throws Exception {
  DirectMessageListenerContainer container = new DirectMessageListenerContainer();
  testUninterruptibleListener(container);
}
origin: spring-projects/spring-amqp

@Bean
public AbstractMessageListenerContainer dmlc() {
  AbstractMessageListenerContainer container = new DirectMessageListenerContainer(cf());
  container.setQueues(queue2());
  container.setMessageListener(m -> {
    message().set(m);
    latch3().countDown();
    latch4().countDown();
  });
  container.setFailedDeclarationRetryInterval(1000);
  container.setMissingQueuesFatal(false);
  container.setRecoveryInterval(100);
  container.setAutoStartup(false);
  return container;
}
origin: spring-projects/spring-amqp

@Test
public void testEvents() throws Exception {
  CachingConnectionFactory cf = new CachingConnectionFactory("localhost");
  DirectMessageListenerContainer container = new DirectMessageListenerContainer(cf);
  container.setQueueNames(EQ1, EQ2);
  final List<Long> times = new ArrayList<>();
  final CountDownLatch latch1 = new CountDownLatch(2);
  final CountDownLatch latch2 = new CountDownLatch(2);
  container.setApplicationEventPublisher(event -> {
    if (event instanceof ListenerContainerIdleEvent) {
      times.add(System.currentTimeMillis());
      latch1.countDown();
    }
    else if (event instanceof ListenerContainerConsumerTerminatedEvent) {
      latch2.countDown();
    }
  });
  container.setMessageListener(m -> { });
  container.setIdleEventInterval(50L);
  container.setBeanName("events");
  container.setConsumerTagStrategy(new Tag());
  container.afterPropertiesSet();
  container.start();
  assertTrue(latch1.await(10, TimeUnit.SECONDS));
  assertThat(times.get(1) - times.get(0), greaterThanOrEqualTo(50L));
  brokerRunning.deleteQueues(EQ1, EQ2);
  assertTrue(latch2.await(10, TimeUnit.SECONDS));
  container.stop();
  cf.destroy();
}
origin: spring-projects/spring-amqp

@Test
public void testDeferredAcks() throws Exception {
  CachingConnectionFactory cf = new CachingConnectionFactory("localhost");
  DirectMessageListenerContainer container = new DirectMessageListenerContainer(cf);
  final CountDownLatch latch = new CountDownLatch(2);
  container.setMessageListener(m -> {
    latch.countDown();
  });
  container.setQueueNames(Q1);
  container.setBeanName("deferredAcks");
  container.setMessagesPerAck(2);
  container.afterPropertiesSet();
  container.start();
  RabbitTemplate rabbitTemplate = new RabbitTemplate(cf);
  rabbitTemplate.convertAndSend(Q1, "foo");
  rabbitTemplate.convertAndSend(Q1, "bar");
  assertTrue(latch.await(10, TimeUnit.SECONDS));
  container.stop();
  cf.destroy();
}
origin: spring-projects/spring-amqp

}).given(channel).basicConsume(eq("foo"), anyBoolean(), anyString(), anyBoolean(), anyBoolean(),
    anyMap(), consumerCaptor.capture());
DirectMessageListenerContainer container = new DirectMessageListenerContainer(mockCF);
container.setQueueNames("foo");
container.setBeanName("brokerLost");
origin: spring-projects/spring-amqp

@Test
public void testNonManagedContainerStopsWhenConnectionFactoryDestroyed() throws Exception {
  CachingConnectionFactory cf = new CachingConnectionFactory("localhost");
  ApplicationContext context = mock(ApplicationContext.class);
  cf.setApplicationContext(context);
  DirectMessageListenerContainer container = new DirectMessageListenerContainer(cf);
  final CountDownLatch latch = new CountDownLatch(1);
  container.setMessageListener(m -> {
    latch.countDown();
  });
  container.setQueueNames(Q1);
  container.setBeanName("stopAfterDestroy");
  container.setIdleEventInterval(500);
  container.setFailedDeclarationRetryInterval(500);
  container.afterPropertiesSet();
  container.start();
  new RabbitTemplate(cf).convertAndSend(Q1, "foo");
  assertTrue(latch.await(10, TimeUnit.SECONDS));
  cf.onApplicationEvent(new ContextClosedEvent(context));
  cf.destroy();
  int n = 0;
  while (n++ < 100 && container.isRunning()) {
    Thread.sleep(100);
  }
  assertFalse(container.isRunning());
}
origin: spring-projects/spring-amqp

@Test
public void testContainerNotRecoveredAfterExhaustingRecoveryBackOff() throws Exception {
  ConnectionFactory mockCF = mock(ConnectionFactory.class);
  given(mockCF.createConnection()).willReturn(null).willThrow(new RuntimeException("intended - backOff test"));
  DirectMessageListenerContainer container = new DirectMessageListenerContainer(mockCF);
  container.setQueueNames("foo");
  container.setRecoveryBackOff(new FixedBackOff(100, 3));
  container.setMissingQueuesFatal(false);
  container.setBeanName("backOff");
  container.setConsumerTagStrategy(new Tag());
  container.afterPropertiesSet();
  container.start();
  // Since backOff exhausting makes listenerContainer as invalid (calls stop()),
  // it is enough to check the listenerContainer activity
  int n = 0;
  while (container.isActive() && n++ < 100) {
    Thread.sleep(100);
  }
  assertFalse(container.isActive());
}
origin: spring-projects/spring-amqp

@Test
public void testNonManagedContainerDoesntStartWhenConnectionFactoryDestroyed() throws Exception {
  CachingConnectionFactory cf = new CachingConnectionFactory("localhost");
  ApplicationContext context = mock(ApplicationContext.class);
  cf.setApplicationContext(context);
  cf.addConnectionListener(connection -> {
    cf.onApplicationEvent(new ContextClosedEvent(context));
    cf.destroy();
  });
  DirectMessageListenerContainer container = new DirectMessageListenerContainer(cf);
  container.setMessageListener(m -> { });
  container.setQueueNames(Q1);
  container.setBeanName("stopAfterDestroyBeforeStart");
  container.afterPropertiesSet();
  container.start();
  int n = 0;
  while (n++ < 100 && container.isRunning()) {
    Thread.sleep(100);
  }
  assertFalse(container.isRunning());
}
origin: spring-projects/spring-amqp

@Test
public void testAdvice() throws Exception {
  CachingConnectionFactory cf = new CachingConnectionFactory("localhost");
  DirectMessageListenerContainer container = new DirectMessageListenerContainer(cf);
  container.setQueueNames(Q1, Q2);
  container.setConsumersPerQueue(2);
  final CountDownLatch latch = new CountDownLatch(2);
  container.setMessageListener(m -> latch.countDown());
  final CountDownLatch adviceLatch = new CountDownLatch(2);
  MethodInterceptor advice = i -> {
    adviceLatch.countDown();
    return i.proceed();
  };
  container.setAdviceChain(advice);
  container.setBeanName("advice");
  container.setConsumerTagStrategy(new Tag());
  container.afterPropertiesSet();
  container.start();
  RabbitTemplate template = new RabbitTemplate(cf);
  template.convertAndSend(Q1, "foo");
  template.convertAndSend(Q1, "bar");
  assertTrue(latch.await(10, TimeUnit.SECONDS));
  assertTrue(adviceLatch.await(10, TimeUnit.SECONDS));
  container.stop();
  assertTrue(consumersOnQueue(Q1, 0));
  assertTrue(consumersOnQueue(Q2, 0));
  assertTrue(activeConsumerCount(container, 0));
  assertEquals(0, TestUtils.getPropertyValue(container, "consumersByQueue", MultiValueMap.class).size());
  cf.destroy();
}
origin: spring-projects/spring-amqp

executor.afterPropertiesSet();
cf.setExecutor(executor);
DirectMessageListenerContainer container = new DirectMessageListenerContainer(cf);
container.setQueueNames(Q1, Q2);
container.setConsumersPerQueue(2);
origin: spring-projects/spring-amqp

RabbitAdmin admin = new RabbitAdmin(cf);
admin.declareQueue(q1);
DirectMessageListenerContainer container = new DirectMessageListenerContainer(cf);
container.setQueueNames(Q1);
container.setConsumersPerQueue(2);
origin: spring-projects/spring-amqp

executor.afterPropertiesSet();
cf.setExecutor(executor);
DirectMessageListenerContainer container = new DirectMessageListenerContainer(cf);
container.setConsumersPerQueue(2);
container.setMessageListener(new MessageListenerAdapter((ReplyingMessageListener<String, String>) in -> {
org.springframework.amqp.rabbit.listenerDirectMessageListenerContainer<init>

Javadoc

Create an instance; #setConnectionFactory(ConnectionFactory) must be called before starting.

Popular methods of DirectMessageListenerContainer

  • setConsumersPerQueue
    Each queue runs in its own consumer; set this property to create multiple consumers for each queue.
  • setAckTimeout
    An approximate timeout; when #setMessagesPerAck(int) is greater than 1, and this time elapses since
  • setMessagesPerAck
    Set the number of messages to receive before acknowledging (success). A failed message will short-ci
  • addQueues
  • afterPropertiesSet
  • getAcknowledgeMode
  • getConnectionFactory
  • getQueueNames
  • isActive
  • isRunning
  • removeQueues
  • setIdleEventInterval
  • removeQueues,
  • setIdleEventInterval,
  • setMessageListener,
  • setMissingQueuesFatal,
  • setMonitorInterval,
  • setPrefetchCount,
  • setQueueNames,
  • actualShutDown,
  • actualStart

Popular in Java

  • Finding current android device location
  • onCreateOptionsMenu (Activity)
  • notifyDataSetChanged (ArrayAdapter)
  • setRequestProperty (URLConnection)
  • ObjectMapper (com.fasterxml.jackson.databind)
    ObjectMapper provides functionality for reading and writing JSON, either to and from basic POJOs (Pl
  • String (java.lang)
  • Calendar (java.util)
    Calendar is an abstract base class for converting between a Date object and a set of integer fields
  • SortedMap (java.util)
    A map that has its keys ordered. The sorting is according to either the natural ordering of its keys
  • Manifest (java.util.jar)
    The Manifest class is used to obtain attribute information for a JarFile and its entries.
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now