@Bean
 public Binding binding_rpcIncomingQueue_to_rpcDefaultExchange() {
   return BindingBuilder.bind(rpcIncomingQueue())
       .to(rpcDefaultExchange())
       .with("incoming")
       .noargs();
 }
Beispiel #2
0
 private HeartBeatListener() {
   setAlive(false);
   RabbitAdmin rabbitAdmin = RabbitConfiguration.getRabbitAdmin();
   Queue queue = rabbitAdmin.declareQueue();
   FanoutExchange exchange = new FanoutExchange(HEART_BEAT_EXCHANGE);
   rabbitAdmin.declareBinding(BindingBuilder.bind(queue).to(exchange));
   HeartBeatMessageListener heartBeatMessageListener = new HeartBeatMessageListener();
   SimpleMessageListenerContainer messageListenerContainer = new SimpleMessageListenerContainer();
   messageListenerContainer.setQueues(queue);
   messageListenerContainer.setConnectionFactory(RabbitConfiguration.getConnectionFactory());
   messageListenerContainer.setMessageListener(heartBeatMessageListener);
   messageListenerContainer.start();
   Thread thread =
       new Thread(
           new Runnable() {
             @Override
             public void run() {
               while (true) {
                 try {
                   Message result;
                   result = heartBeats.poll(TIMEOUT, TimeUnit.MILLISECONDS);
                   if (result == null) {
                     setAlive(false);
                   } else {
                     setAlive(true);
                   }
                 } catch (InterruptedException e) {
                   setAlive(false);
                 }
               }
             }
           },
           "server-heart-beat-listener");
   thread.start();
 }
 private boolean tryUsingQueue(final RabbitAdmin admin) {
   try {
     final Queue queue = admin.declareQueue();
     final DirectExchange exchange = new DirectExchange("player-direct", true, false);
     admin.declareBinding(BindingBuilder.bind(queue).to(exchange).with("TEST"));
     return true;
   } catch (Exception e) {
     return false;
   }
 }
 /**
  * If so requested, declare the DLX/DLQ and bind it. The DLQ is bound to the DLX with a routing
  * key of the original queue name because we use default exchange routing by queue name for the
  * original message.
  *
  * @param name The name.
  * @param properties The properties accessor.
  */
 private void autoBindDLQ(final String name, RabbitPropertiesAccessor properties) {
   if (logger.isDebugEnabled()) {
     logger.debug(
         "autoBindDLQ=" + properties.getAutoBindDLQ(this.defaultAutoBindDLQ) + " for: " + name);
   }
   if (properties.getAutoBindDLQ(this.defaultAutoBindDLQ)) {
     String prefix = properties.getPrefix(this.defaultPrefix);
     String queueName = applyPrefix(prefix, name);
     String dlqName = constructDLQName(queueName);
     Queue dlq = new Queue(dlqName);
     declareQueueIfNotPresent(dlq);
     final String dlxName = deadLetterExchangeName(prefix);
     final DirectExchange dlx = new DirectExchange(dlxName);
     declareExchangeIfNotPresent(dlx);
     this.rabbitAdmin.declareBinding(BindingBuilder.bind(dlq).to(dlx).with(queueName));
   }
 }
 @Override
 public void bindPubSubConsumer(
     String name, MessageChannel moduleInputChannel, Properties properties) {
   String exchangeName = BinderUtils.removeGroupFromPubSub(name);
   if (logger.isInfoEnabled()) {
     logger.info("declaring pubsub for inbound: " + name + ", bound to: " + exchangeName);
   }
   RabbitPropertiesAccessor accessor = new RabbitPropertiesAccessor(properties);
   validateConsumerProperties(name, properties, SUPPORTED_PUBSUB_CONSUMER_PROPERTIES);
   String prefix = accessor.getPrefix(this.defaultPrefix);
   FanoutExchange exchange = new FanoutExchange(applyPrefix(prefix, applyPubSub(exchangeName)));
   declareExchangeIfNotPresent(exchange);
   Queue queue;
   boolean durable = accessor.isDurable(this.defaultDurableSubscription);
   String queueName = applyPrefix(prefix, name);
   if (durable) {
     Map<String, Object> args = queueArgs(accessor, queueName);
     queue = new Queue(queueName, true, false, false, args);
   } else {
     queue = new Queue(queueName, false, false, true);
   }
   declareQueueIfNotPresent(queue);
   org.springframework.amqp.core.Binding binding = BindingBuilder.bind(queue).to(exchange);
   this.rabbitAdmin.declareBinding(binding);
   // register with context so they will be redeclared after a connection failure
   if (!this.autoDeclareContext.containsBean(applyPubSub(name))) {
     this.autoDeclareContext.getBeanFactory().registerSingleton(applyPubSub(name), queue);
   }
   String bindingBeanName = exchange.getName() + "." + queue.getName() + ".binding";
   if (!this.autoDeclareContext.containsBean(bindingBeanName)) {
     this.autoDeclareContext.getBeanFactory().registerSingleton(bindingBeanName, binding);
   }
   doRegisterConsumer(name, moduleInputChannel, queue, accessor, true);
   if (durable) {
     autoBindDLQ(name, accessor);
   }
 }
 /** Binds to the service topic exchange */
 @Bean
 public Binding serviceTopicBinding(AmqpAdmin amqpAdmin) {
   return BindingBuilder.bind(clientQueue(amqpAdmin))
       .to(labTopicExchange())
       .with(Topic.SERVICE.getRoutingKey());
 }
 @Bean
 public Binding binding_rpcReplyQueue_to_rpcDefaultExchange() {
   return BindingBuilder.bind(rpcReplyQueue()).to(rpcDefaultExchange()).with("reply").noargs();
 }
 /**
  * Create the Binding deadLetterQueue to exchangeDeadLetter.
  *
  * @return the binding
  */
 @Bean
 public Binding bindDeadLetterQueueToLwm2mExchange() {
   return BindingBuilder.bind(deadLetterQueue()).to(exchangeDeadLetter());
 }
 /**
  * Create the Binding {@link AmqpConfiguration#receiverQueueFromSp()} to {@link
  * AmqpConfiguration#senderConnectorToSpExchange()}.
  *
  * @return the binding and create the queue and exchange
  */
 @Bean
 public Binding bindSenderExchangeToSpQueue() {
   return BindingBuilder.bind(receiverQueue()).to(senderExchange());
 }
 @Bean
 Binding delayBinding(Queue delayQueue, TopicExchange delayExchange) {
   return BindingBuilder.bind(delayQueue).to(delayExchange).with("#");
 }
 @Bean
 Binding binding(Queue queue, TopicExchange exchange) {
   return BindingBuilder.bind(queue).to(exchange).with("cmd.message.#");
 }
 @Bean
 public Binding marketDataBinding() throws Throwable {
   return BindingBuilder.bind(customerQueue()).to(customerExchange()).with(this.stocks);
 }
 @Bean
 Binding bindingExchangeMessages(Queue queueMessages, TopicExchange exchange) {
   return BindingBuilder.bind(queueMessages).to(exchange).with("queue.messages");
 }