Java Code Examples for org.springframework.amqp.core.Binding

The following examples show how to use org.springframework.amqp.core.Binding. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: summerframework   Source File: DeadLetterQueueCreator.java    License: Apache License 2.0 6 votes vote down vote up
public void createDeadLetterQueue(String fromExchange, String byRouteKey, String delayOrRetryRouteKey,
    String sourceQueue, String delayOrRetryQueueName, Long ttl) {
    if (sourceQueue == null || sourceQueue.isEmpty()) {
        logger.warn(
            "Have not config destination Queue, will not create delay queue by automatic,may be you must maintain binding by youself");
        return;
    }
    Properties properties = rabbitAdmin.getQueueProperties(delayOrRetryQueueName);
    if (properties == null) {
        Map<String, Object> delayQueueArgs = Maps.newHashMap();
        delayQueueArgs.put("x-message-ttl", ttl);
        delayQueueArgs.put("x-dead-letter-exchange", fromExchange);
        delayQueueArgs.put("x-dead-letter-routing-key", byRouteKey);
        Queue delayQueue = new Queue(delayOrRetryQueueName, true, false, false, delayQueueArgs);
        String returnQueueName = rabbitAdmin.declareQueue(delayQueue);
        if (returnQueueName != null) {
            Binding binding = BindingBuilder.bind(delayQueue)//
                .to(new DirectExchange(DeadLetterConstant.DEFAULT_DEADLETTEREXCHANGE_NAME))//
                .with(delayOrRetryRouteKey);//
            rabbitAdmin.declareBinding(binding);
        }
    }
}
 
Example 2
Source Project: WeBASE-Front   Source File: MQServiceTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testDeclareBind() {
	Binding bind = BindingBuilder.bind(new Queue(queueName))
			.to(new DirectExchange(exchangeName))
			.with(routingKey);
	rabbitAdmin.declareBinding(bind);
}
 
Example 3
Source Project: cloud-service   Source File: RabbitmqConfig.java    License: MIT License 5 votes vote down vote up
/**
 * 将角色删除队列和用户的exchange做个绑定
 * 
 * @return
 */
@Bean
public Binding bindingRoleDelete() {
	Binding binding = BindingBuilder.bind(roleDeleteQueue()).to(userTopicExchange())
			.with(UserCenterMq.ROUTING_KEY_ROLE_DELETE);
	return binding;
}
 
Example 4
Source Project: articles   Source File: EventSubscriberConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
public Binding binding(Queue eventReceivingQueue, TopicExchange receiverExchange) {
    if (routingKey == null) {
        throw new IllegalStateException("No events to listen to! Please specify the routing key for the events to listen to with the property 'subscriber.routingKey' (see EventPublisher for available routing keys).");
    }
    return BindingBuilder
            .bind(eventReceivingQueue)
            .to(receiverExchange)
            .with(routingKey);
}
 
Example 5
Source Project: code-examples   Source File: EventSubscriberConfiguration.java    License: MIT License 5 votes vote down vote up
@Bean
public Binding binding(Queue eventReceivingQueue, TopicExchange receiverExchange) {
  if (routingKey == null) {
    throw new IllegalStateException("No events to listen to! Please specify the routing key for the events to listen to with the property 'subscriber.routingKey' (see EventPublisher for available routing keys).");
  }
  return BindingBuilder
          .bind(eventReceivingQueue)
          .to(receiverExchange)
          .with(routingKey);
}
 
Example 6
Source Project: code-examples   Source File: MessageConsumerConfiguration.java    License: MIT License 5 votes vote down vote up
@Bean
public Binding binding(Queue eventReceivingQueue, TopicExchange receiverExchange) {
	return BindingBuilder
					.bind(eventReceivingQueue)
					.to(receiverExchange)
					.with("*.*");
}
 
Example 7
Source Project: xxpay-master   Source File: RabbitMq4PayNotify.java    License: MIT License 5 votes vote down vote up
@PostConstruct
public void init() {
	DirectExchange exchange = new DirectExchange(PAY_NOTIFY_EXCHANGE_NAME);
	exchange.setDelayed(true);
	Queue queue = new Queue(PAY_NOTIFY_QUEUE_NAME);
	Binding binding = BindingBuilder.bind(queue).to(exchange).withQueueName();
	amqpAdmin.declareExchange(exchange);
	amqpAdmin.declareQueue(queue);
	amqpAdmin.declareBinding(binding);
}
 
Example 8
Source Project: Spring-Boot-Book   Source File: RabbitmqConfig.java    License: Apache License 2.0 4 votes vote down vote up
@Bean
Binding bindingExchangeMessage(Queue queueMessage, TopicExchange exchange) {
    return BindingBuilder.bind(queueMessage).to(exchange).with("topic.a");
}
 
Example 9
Source Project: Spring-Boot-Book   Source File: RabbitmqConfig.java    License: Apache License 2.0 4 votes vote down vote up
@Bean
Binding bindingExchangeMessages(Queue queueMessages, TopicExchange exchange) {
    return BindingBuilder.bind(queueMessages).to(exchange).with("topic.#");
}
 
Example 10
Source Project: Spring-Boot-Book   Source File: RabbitmqConfig.java    License: Apache License 2.0 4 votes vote down vote up
@Bean
public Binding binding() {
    return BindingBuilder.bind(queue()).to(delayExchange()).with("delay_queue_1").noargs();
}
 
Example 11
Source Project: Spring-Boot-Book   Source File: RabbitmqConfig.java    License: Apache License 2.0 4 votes vote down vote up
@Bean
Binding bindingExchangeA(Queue queueA, FanoutExchange fanoutExchanger) {
    return BindingBuilder.bind(queueA).to(fanoutExchanger);
}
 
Example 12
Source Project: Spring-Boot-Book   Source File: RabbitmqConfig.java    License: Apache License 2.0 4 votes vote down vote up
@Bean
Binding bindingExchangeB(Queue queueB, FanoutExchange fanoutExchanger) {
    return BindingBuilder.bind(queueB).to(fanoutExchanger);
}
 
Example 13
Source Project: Spring-Boot-Book   Source File: RabbitConfig.java    License: Apache License 2.0 4 votes vote down vote up
@Bean
public Binding binding() {
    return BindingBuilder.bind(queue()).to(delayExchange()).with("delay_queue_1").noargs();
}
 
Example 14
@Bean
Binding binding(Queue queue, @Qualifier("input") TopicExchange exchange) {
	return BindingBuilder.bind(queue).to(exchange).with("#");
}
 
Example 15
@Bean
public Binding binding(final Queue queue, final DirectExchange directExchange){
    return BindingBuilder.bind(queue).to(directExchange).with(routingName);
}
 
Example 16
Source Project: gpmall   Source File: RabbitMqConfig.java    License: Apache License 2.0 4 votes vote down vote up
@Bean
public Binding delayBind(){
	return BindingBuilder.bind(delayQueue()).to(delayExchange());
}
 
Example 17
@Bean
public Binding bindToInventoryChanged() {
    return new Binding(properties.getReceiveQ(), QUEUE, "order-publish-x", "com.ecommerce.order.sdk.event.order.#", null);
}
 
Example 18
@Bean
public Binding bindToInventoryChanged() {
    return new Binding(properties.getReceiveQ(), QUEUE, "inventory-publish-x", InventoryChangedEvent.class.getName(), null);
}
 
Example 19
Source Project: springboot-example   Source File: DirectConfig.java    License: Apache License 2.0 4 votes vote down vote up
@Bean
Binding bindingExchangeDirectQueue(Queue directQueue, DirectExchange directExchange) {
    return BindingBuilder.bind(directQueue).to(directExchange).with(DirectConfig.QUEUE_NAME);
}
 
Example 20
Source Project: springboot-example   Source File: TopicConfig.java    License: Apache License 2.0 4 votes vote down vote up
@Bean
Binding bindingtopicExchangeQueue(Queue queuetopic, TopicExchange topicExchange) {
    return BindingBuilder.bind(queuetopic).to(topicExchange).with("log.#");
}
 
Example 21
Source Project: springboot-example   Source File: TopicConfig.java    License: Apache License 2.0 4 votes vote down vote up
@Bean
Binding bindingtopicExchangeQueue2(Queue queuetopic2, TopicExchange topicExchange) {
    return BindingBuilder.bind(queuetopic2).to(topicExchange).with("log.*");
}
 
Example 22
Source Project: springboot-example   Source File: TopicConfig.java    License: Apache License 2.0 4 votes vote down vote up
@Bean
Binding bindingtopicExchangeQueue3(Queue queuetopic3, TopicExchange topicExchange) {
    return BindingBuilder.bind(queuetopic3).to(topicExchange).with("log.*.error");
}
 
Example 23
Source Project: rabbitmq-mock   Source File: AmqpApplication.java    License: Apache License 2.0 4 votes vote down vote up
@Bean
public Binding binding(Queue queue, TopicExchange exchange) {
    return BindingBuilder.bind(queue).to(exchange).with(QUEUE_NAME);
}
 
Example 24
Source Project: java-specialagent   Source File: SpringRabbitMQITest.java    License: Apache License 2.0 4 votes vote down vote up
@Bean
Binding binding(final Queue queue, final TopicExchange exchange) {
  return BindingBuilder.bind(queue).to(exchange).with("foo.bar.#");
}
 
Example 25
@Bean("requestPaymentExchangeBinding")
public Binding requestPaymentExchangeBinding(@Qualifier("requestPaymentQueue") Queue requestPaymentQueue,@Qualifier("requestPaymentExchange") TopicExchange requestPaymentExchange) {
  return BindingBuilder.bind(requestPaymentQueue).to(requestPaymentExchange).with("*");
}
 
Example 26
@Bean("responsePaymentExchangeBinding")
public Binding responsePaymentExchangeBinding(@Qualifier("responsePaymentQueue") Queue responsePaymentQueue,@Qualifier("responsePaymentExchange") TopicExchange responsePaymentExchange) {
  return BindingBuilder.bind(responsePaymentQueue).to(responsePaymentExchange).with("*");
}
 
Example 27
@Bean
public Binding mailExchangeBinding(Queue mailQueue) {
  return BindingBuilder.bind(mailQueue).to(emailExchange()).with("*");
}
 
Example 28
@Bean
Binding exchangeBinding(DirectExchange directExchange, Queue queue) {
	return BindingBuilder.bind(queue).to(directExchange).with(ROUTING_KEY);
}
 
Example 29
Source Project: fw-cloud-framework   Source File: RabbitConfiguration.java    License: MIT License 4 votes vote down vote up
/**
 * 将per_queue_ttl_exchange绑定到delay_queue_per_queue_ttl队列
 */
@Bean
Binding queueTTLBinding(Queue delayQueuePerQueueTTL, DirectExchange perQueueTTLExchange) {
	return BindingBuilder.bind(delayQueuePerQueueTTL).to(perQueueTTLExchange).with(
			PAY_NOTIFY_DELAY_QUENU_ALL_TTL);
}
 
Example 30
Source Project: java-tutorial   Source File: Tut6Config.java    License: MIT License 4 votes vote down vote up
@Bean
public Binding binding(DirectExchange exchange, Queue queue) {
    return BindingBuilder.bind(queue).to(exchange).with("rpc");
}