Tabnine Logo
org.springframework.amqp.rabbit
Code IndexAdd Tabnine to your IDE (free)

How to use org.springframework.amqp.rabbit

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

origin: spring-projects/spring-integration

@Override
protected void doStop() {
  this.template.stop();
  super.doStop();
}
origin: spring-projects/spring-integration

@Override
protected void doStart() {
  super.doStart();
  this.template.start();
}
origin: spring-projects/spring-integration

public AsyncAmqpOutboundGateway(AsyncRabbitTemplate template) {
  Assert.notNull(template, "AsyncRabbitTemplate cannot be null");
  this.template = template;
  this.messageConverter = template.getMessageConverter();
  Assert.notNull(this.messageConverter, "the template's message converter cannot be null");
  setConnectionFactory(this.template.getConnectionFactory());
  setAsync(true);
}
origin: spring-projects/spring-integration

@Test
public void testConfirmsAndReturns() throws Exception {
  CachingConnectionFactory ccf = new CachingConnectionFactory("localhost");
  ccf.setPublisherConfirms(true);
  ccf.setPublisherReturns(true);
  RabbitTemplate template = new RabbitTemplate(ccf);
  SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(ccf);
  container.setBeanName("replyContainer");
  container.setQueueNames("asyncRQ1");
  container.afterPropertiesSet();
  container.start();
  AsyncRabbitTemplate asyncTemplate = new AsyncRabbitTemplate(template, container);
  asyncTemplate.setEnableConfirms(true);
  asyncTemplate.setMandatory(true);
  SimpleMessageListenerContainer receiver = new SimpleMessageListenerContainer(ccf);
  receiver.setBeanName("receiver");
  receiver.setQueueNames("asyncQ1");
  final CountDownLatch waitForAckBeforeReplying = new CountDownLatch(1);
  MessageListenerAdapter messageListener = new MessageListenerAdapter(
      (ReplyingMessageListener<String, String>) foo -> {
        try {
  receiver.setMessageListener(messageListener);
  receiver.afterPropertiesSet();
  receiver.start();
  asyncTemplate.setReceiveTimeout(10);
  receiver.setMessageListener(message1 -> { });
origin: spring-projects/spring-integration

@Test
public void testAsyncDelayExpression() {
  ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
  AsyncRabbitTemplate amqpTemplate = spy(new AsyncRabbitTemplate(new RabbitTemplate(connectionFactory),
      new SimpleMessageListenerContainer(connectionFactory), "replyTo"));
  amqpTemplate.setTaskScheduler(mock(TaskScheduler.class));
  AsyncAmqpOutboundGateway gateway = new AsyncAmqpOutboundGateway(amqpTemplate);
  willAnswer(
      invocation -> amqpTemplate.new RabbitMessageFuture("foo", invocation.getArgument(2)))
        .given(amqpTemplate).sendAndReceive(anyString(), anyString(), any(Message.class));
  gateway.setExchangeName("foo");
  gateway.setRoutingKey("bar");
  gateway.setDelayExpressionString("42");
  gateway.setBeanFactory(mock(BeanFactory.class));
  gateway.setOutputChannel(new NullChannel());
  gateway.afterPropertiesSet();
  gateway.start();
  ArgumentCaptor<Message> captor = ArgumentCaptor.forClass(Message.class);
  gateway.handleMessage(new GenericMessage<>("foo"));
  verify(amqpTemplate).sendAndReceive(eq("foo"), eq("bar"), captor.capture());
  assertThat(captor.getValue().getMessageProperties().getDelay(), equalTo(42));
}
origin: spring-projects/spring-amqp

@Test
public void testMessage1Arg() throws Exception {
  ListenableFuture<Message> future = this.asyncTemplate.sendAndReceive(getFooMessage());
  checkMessageResult(future, "FOO");
}
origin: spring-projects/spring-integration

@Override
protected Object handleRequestMessage(Message<?> requestMessage) {
  org.springframework.amqp.core.Message amqpMessage = MappingUtils.mapMessage(requestMessage,
      this.messageConverter, getHeaderMapper(), getDefaultDeliveryMode(), isHeadersMappedLast());
  addDelayProperty(requestMessage, amqpMessage);
  RabbitMessageFuture future = this.template.sendAndReceive(generateExchangeName(requestMessage),
      generateRoutingKey(requestMessage), amqpMessage);
  future.addCallback(new FutureCallback(requestMessage));
  CorrelationData correlationData = generateCorrelationData(requestMessage);
  if (correlationData != null && future.getConfirm() != null) {
    future.getConfirm().addCallback(new CorrelationCallback(correlationData, future));
  }
  return null;
}
origin: spring-projects/spring-amqp

@Test
@DirtiesContext
public void testConvertWithConfirmDirect() throws Exception {
  this.asyncDirectTemplate.setEnableConfirms(true);
  RabbitConverterFuture<String> future = this.asyncDirectTemplate.convertSendAndReceive("sleep");
  ListenableFuture<Boolean> confirm = future.getConfirm();
  assertNotNull(confirm);
  assertTrue(confirm.get(10, TimeUnit.SECONDS));
  checkConverterResult(future, "SLEEP");
}
origin: spring-projects/spring-amqp

@Override
public <C> RabbitConverterFuture<C> convertSendAndReceive(String exchange, String routingKey, Object object,
    MessagePostProcessor messagePostProcessor) {
  return convertSendAndReceive(exchange, routingKey, object, messagePostProcessor, null);
}
origin: spring-projects/spring-amqp

@Test
public void testConvert2Args() throws Exception {
  ListenableFuture<String> future = this.asyncTemplate.convertSendAndReceive(this.requests.getName(), "foo");
  checkConverterResult(future, "FOO");
}
origin: org.springframework.amqp/spring-rabbit

@Override
public <C> RabbitConverterFuture<C> convertSendAndReceiveAsType(String exchange, String routingKey, Object object,
    ParameterizedTypeReference<C> responseType) {
  return convertSendAndReceiveAsType(exchange, routingKey, object, null, responseType);
}
origin: spring-projects/spring-integration

@Bean
public AsyncRabbitTemplate asyncRabbitTemplate(ConnectionFactory rabbitConnectionFactory) {
  return new AsyncRabbitTemplate(rabbitConnectionFactory, "", "", "asyncReplies");
}
origin: spring-projects/spring-integration

@Override
public void onSuccess(Boolean result) {
  try {
    handleConfirm(this.correlationData, result, this.replyFuture.getNackCause());
  }
  catch (Exception e) {
    logger.error("Failed to send publisher confirm");
  }
}
origin: spring-projects/spring-amqp

@Test
public void testMessage3Args() throws Exception {
  ListenableFuture<Message> future = this.asyncTemplate.sendAndReceive("", this.requests.getName(),
      getFooMessage());
  checkMessageResult(future, "FOO");
}
origin: org.springframework.amqp/spring-rabbit

@Override
public <C> RabbitConverterFuture<C> convertSendAndReceive(String exchange, String routingKey, Object object,
    MessagePostProcessor messagePostProcessor) {
  return convertSendAndReceive(exchange, routingKey, object, messagePostProcessor, null);
}
origin: spring-projects/spring-amqp

@Test
public void testConvert3Args() throws Exception {
  ListenableFuture<String> future = this.asyncTemplate.convertSendAndReceive("", this.requests.getName(), "foo");
  checkConverterResult(future, "FOO");
}
origin: spring-projects/spring-amqp

@Override
public <C> RabbitConverterFuture<C> convertSendAndReceiveAsType(String exchange, String routingKey, Object object,
    ParameterizedTypeReference<C> responseType) {
  return convertSendAndReceiveAsType(exchange, routingKey, object, null, responseType);
}
origin: spring-projects/spring-amqp

@Test
public void testMessage2Args() throws Exception {
  ListenableFuture<Message> future = this.asyncTemplate.sendAndReceive(this.requests.getName(), getFooMessage());
  checkMessageResult(future, "FOO");
}
origin: spring-projects/spring-amqp

@Override
public <C> RabbitConverterFuture<C> convertSendAndReceive(String exchange, String routingKey, Object object) {
  return convertSendAndReceive(exchange, routingKey, object, null);
}
origin: org.springframework.amqp/spring-rabbit

@Override
public <C> RabbitConverterFuture<C> convertSendAndReceive(String exchange, String routingKey, Object object) {
  return convertSendAndReceive(exchange, routingKey, object, null);
}
org.springframework.amqp.rabbit

Most used classes

  • RabbitTemplate
    Helper class that simplifies synchronous RabbitMQ access (sending and receiving messages). The de
  • RabbitListener
  • SimpleMessageListenerContainer
  • CachingConnectionFactory
    A ConnectionFactory implementation that (when the cache mode is CacheMode#CHANNEL (default) returns
  • RabbitHandler
  • MessageListenerAdapter,
  • ConnectionFactory,
  • Connection,
  • CorrelationData,
  • SimpleRabbitListenerContainerFactory,
  • EnableRabbit,
  • Exchange,
  • QueueBinding,
  • Queue,
  • RabbitListenerEndpointRegistrar,
  • AbstractMessageListenerContainer,
  • DefaultMessagePropertiesConverter,
  • MessagePropertiesConverter,
  • AsyncRabbitTemplate
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