Package org.springframework.amqp.rabbit.core

Examples of org.springframework.amqp.rabbit.core.RabbitAdmin


  }
 
  @Bean
  public RabbitService rabbitService() {
    return new RabbitService(vertx(), rabbitConnectionFactory(),
        new RabbitAdmin(rabbitConnectionFactory()),
        new RabbitTemplate(rabbitConnectionFactory()),
        rabbitTaskExecutor());
  }
View Full Code Here


  }

  public void connect() {

    cf = new CachingConnectionFactory(address.getHost(), address.getPort());
    admin = new RabbitAdmin(cf);

    declarePipelineCreationQueue(admin);
  }
View Full Code Here

    Assert.notNull(connectionFactory, "connectionFactory must not be null");
    Assert.notNull(codec, "codec must not be null");
    this.connectionFactory = connectionFactory;
    this.rabbitTemplate.setConnectionFactory(connectionFactory);
    this.rabbitTemplate.afterPropertiesSet();
    this.rabbitAdmin = new RabbitAdmin(connectionFactory);
    this.autoDeclareContext.refresh();
    this.rabbitAdmin.setApplicationContext(this.autoDeclareContext);
    this.rabbitAdmin.afterPropertiesSet();
    this.setCodec(codec);
  }
View Full Code Here

  }

  @Test
  public void testAutoBindDLQ() throws Exception {
    // pre-declare the queue with dead-lettering, users can also use a policy
    RabbitAdmin admin = new RabbitAdmin(this.rabbitAvailableRule.getResource());
    Map<String, Object> args = new HashMap<String, Object>();
    args.put("x-dead-letter-exchange", "xdbustest.DLX");
    Queue queue = new Queue("xdbustest.dlqtest", true, false, false, args);
    admin.declareQueue(queue);

    MessageBus bus = getMessageBus();
    Properties properties = new Properties();
    properties.put("prefix", "xdbustest.");
    properties.put("autoBindDLQ", "true");
    properties.put("maxAttempts", "1"); // disable retry
    properties.put("requeue", "false");
    DirectChannel moduleInputChannel = new DirectChannel();
    moduleInputChannel.setBeanName("dlqTest");
    moduleInputChannel.subscribe(new MessageHandler() {

      @Override
      public void handleMessage(Message<?> message) throws MessagingException {
        throw new RuntimeException("foo");
      }

    });
    bus.bindConsumer("dlqtest", moduleInputChannel, properties);

    RabbitTemplate template = new RabbitTemplate(this.rabbitAvailableRule.getResource());
    template.convertAndSend("", "xdbustest.dlqtest", "foo");

    int n = 0;
    while (n++ < 100) {
      Object deadLetter = template.receiveAndConvert("xdbustest.dlqtest.dlq");
      if (deadLetter != null) {
        assertEquals("foo", deadLetter);
        break;
      }
      Thread.sleep(100);
    }
    assertTrue(n < 100);

    bus.unbindConsumer("dlqtest", moduleInputChannel);
    admin.deleteQueue("xdbustest.dlqtest.dlq");
    admin.deleteQueue("xdbustest.dlqtest");
    admin.deleteExchange("xdbustest.DLX");
  }
View Full Code Here

  /**
   * Creates an instance of the queue on the rabbit broker. If already present then no action is taken.
   */
  public void createQueue() {
    RabbitAdmin admin = new RabbitAdmin(connectionFactory);
    Queue sourceQueue = new Queue(queue, false, false, true);
    admin.declareQueue(sourceQueue);
    TopicExchange exchange = new TopicExchange(DEFAULT_EXCHANGE);
    admin.declareExchange(exchange);
    admin.declareBinding(
        BindingBuilder.bind(sourceQueue).to(exchange).with("rabbitfixture.*"));
  }
 
View Full Code Here

  /**
   * Creates an instance of the queue on the rabbit broker. If already present then no action is taken.
   */
  public void destroyQueue() {
    RabbitAdmin admin = new RabbitAdmin(connectionFactory);
    admin.deleteQueue(queue);
  }
View Full Code Here

  private static RabbitAdmin rabbitAdmin;

  @BeforeClass
  public static void setupRabbitAdmin() {
    rabbitAdmin = new RabbitAdmin(rabbit.getResource());
    rabbitAdmin.afterPropertiesSet();
  }
View Full Code Here

public class RabbitTestMessageBus extends AbstractTestMessageBus<RabbitMessageBus> {

  private final RabbitAdmin rabbitAdmin;

  public RabbitTestMessageBus(ConnectionFactory connectionFactory) {
    this.rabbitAdmin = new RabbitAdmin(connectionFactory);
  }
View Full Code Here

    RabbitMessageBus messageBus = new RabbitMessageBus(connectionFactory, codec);
    GenericApplicationContext context = new GenericApplicationContext();
    context.refresh();
    messageBus.setApplicationContext(context);
    this.setMessageBus(messageBus);
    this.rabbitAdmin = new RabbitAdmin(connectionFactory);
  }
View Full Code Here

            }
        }
       
        if(this.amqpAdministration == null) {
            //Attempt to construct an AMQP Adminstration instance
            this.amqpAdministration = new RabbitAdmin(this.connectionFactory);
            LOG.info("Created new AMQP Administration instance");
        }
       
        return this.amqpAdministration;
    }
View Full Code Here

TOP

Related Classes of org.springframework.amqp.rabbit.core.RabbitAdmin

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.