org.springframework.amqp.core.BindingBuilder Java Examples
The following examples show how to use
org.springframework.amqp.core.BindingBuilder.
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 File: AmqpMessageBrokerConfiguration.java From piper with Apache License 2.0 | 6 votes |
private void registerListenerEndpoint(RabbitListenerEndpointRegistrar aRegistrar, Queue aQueue, Exchange aExchange, int aConcurrency, Object aDelegate, String aMethodName) { admin(connectionFactory).declareQueue(aQueue); admin(connectionFactory).declareBinding(BindingBuilder.bind(aQueue) .to(aExchange) .with(aQueue.getName()) .noargs()); MessageListenerAdapter messageListener = new MessageListenerAdapter(aDelegate); messageListener.setMessageConverter(jacksonAmqpMessageConverter(objectMapper)); messageListener.setDefaultListenerMethod(aMethodName); SimpleRabbitListenerEndpoint endpoint = new SimpleRabbitListenerEndpoint(); endpoint.setId(aQueue.getName()+"Endpoint"); endpoint.setQueueNames(aQueue.getName()); endpoint.setMessageListener(messageListener); aRegistrar.registerEndpoint(endpoint,createContainerFactory(aConcurrency)); }
Example #2
Source File: RabbitWithoutRabbitTemplateConfig.java From java-spring-rabbitmq with Apache License 2.0 | 6 votes |
@Bean public RabbitAdmin rabbitAdmin(Queue queue, ConnectionFactory connectionFactory) { final TopicExchange exchange = new TopicExchange("myExchange", true, false); final RabbitAdmin admin = new RabbitAdmin(connectionFactory); admin.declareQueue(queue); admin.declareExchange(exchange); admin.declareBinding(BindingBuilder.bind(queue).to(exchange).with("#")); return admin; }
Example #3
Source File: DeadLetterQueueCreator.java From summerframework with Apache License 2.0 | 6 votes |
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 #4
Source File: RabbitMq4PayNotify.java From xxpay-master with MIT License | 5 votes |
@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 #5
Source File: MQServiceTest.java From WeBASE-Front with Apache License 2.0 | 5 votes |
@Test public void testDeclareBind() { Binding bind = BindingBuilder.bind(new Queue(queueName)) .to(new DirectExchange(exchangeName)) .with(routingKey); rabbitAdmin.declareBinding(bind); }
Example #6
Source File: RabbitmqConfig.java From cloud-service with MIT License | 5 votes |
/** * 将角色删除队列和用户的exchange做个绑定 * * @return */ @Bean public Binding bindingRoleDelete() { Binding binding = BindingBuilder.bind(roleDeleteQueue()).to(userTopicExchange()) .with(UserCenterMq.ROUTING_KEY_ROLE_DELETE); return binding; }
Example #7
Source File: CoreRabbitMQConfiguration.java From abixen-platform with GNU Lesser General Public License v2.1 | 5 votes |
@Bean List<Binding> binding(TopicExchange exchange) { List<Binding> bindings = new ArrayList<>(); queues().forEach(queue -> { bindings.add(BindingBuilder.bind(queue).to(exchange).with(queue.getName())); }); return bindings; }
Example #8
Source File: MessageConsumerConfiguration.java From code-examples with MIT License | 5 votes |
@Bean public Binding binding(Queue eventReceivingQueue, TopicExchange receiverExchange) { return BindingBuilder .bind(eventReceivingQueue) .to(receiverExchange) .with("*.*"); }
Example #9
Source File: EventSubscriberConfiguration.java From code-examples with MIT License | 5 votes |
@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 #10
Source File: EventSubscriberConfiguration.java From articles with Apache License 2.0 | 5 votes |
@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 #11
Source File: SpringIntegrationTest.java From rabbitmq-mock with Apache License 2.0 | 5 votes |
private RabbitTemplate queueAndExchangeSetup(BeanFactory context) { RabbitAdmin rabbitAdmin = context.getBean(RabbitAdmin.class); Queue queue = new Queue(QUEUE_NAME, false); rabbitAdmin.declareQueue(queue); TopicExchange exchange = new TopicExchange(EXCHANGE_NAME); rabbitAdmin.declareExchange(exchange); rabbitAdmin.declareBinding(BindingBuilder.bind(queue).to(exchange).with("test.*")); return context.getBean(RabbitTemplate.class); }
Example #12
Source File: RabbitBinderTests.java From spring-cloud-stream-binder-rabbit with Apache License 2.0 | 5 votes |
@Test public void testConsumerPropertiesWithUserInfrastructureNoBind() throws Exception { RabbitAdmin admin = new RabbitAdmin(this.rabbitAvailableRule.getResource()); Queue queue = new Queue("propsUser1.infra"); admin.declareQueue(queue); DirectExchange exchange = new DirectExchange("propsUser1"); admin.declareExchange(exchange); admin.declareBinding(BindingBuilder.bind(queue).to(exchange).with("foo")); RabbitTestBinder binder = getBinder(); ExtendedConsumerProperties<RabbitConsumerProperties> properties = createConsumerProperties(); properties.getExtension().setDeclareExchange(false); properties.getExtension().setBindQueue(false); Binding<MessageChannel> consumerBinding = binder.bindConsumer("propsUser1", "infra", createBindableChannel("input", new BindingProperties()), properties); Lifecycle endpoint = extractEndpoint(consumerBinding); SimpleMessageListenerContainer container = TestUtils.getPropertyValue(endpoint, "messageListenerContainer", SimpleMessageListenerContainer.class); assertThat(TestUtils.getPropertyValue(container, "missingQueuesFatal", Boolean.class)).isFalse(); assertThat(container.isRunning()).isTrue(); consumerBinding.unbind(); assertThat(container.isRunning()).isFalse(); Client client = new Client("http://guest:guest@localhost:15672/api/"); List<?> bindings = client.getBindingsBySource("/", exchange.getName()); assertThat(bindings.size()).isEqualTo(1); }
Example #13
Source File: AmqpConfig.java From articles with Apache License 2.0 | 4 votes |
@Bean("tradeUpdateQueueBinding") public Binding tradeUpdateQueueBinding(@Qualifier("tradeUpdateQueue") Queue tradeUpdateQueue, DirectExchange tradeExchange) { return BindingBuilder.bind(tradeUpdateQueue).to(tradeExchange).withQueueName(); }
Example #14
Source File: AmqpConfig.java From articles with Apache License 2.0 | 4 votes |
@Bean("tradeCreateQueueBinding") public Binding tradeCreateQueueBinding(@Qualifier("tradeCreateQueue") Queue tradeCreateQueue, DirectExchange tradeExchange) { return BindingBuilder.bind(tradeCreateQueue).to(tradeExchange).withQueueName(); }
Example #15
Source File: RabbitMQConfiguration.java From Spring-5.0-By-Example with MIT License | 4 votes |
@Bean("paymentRequestBinding") public Binding paymentRequestBinding(DirectExchange exchange,@Qualifier("paymentRequestQueue") Queue paymentRequestQueue){ return BindingBuilder.bind(paymentRequestQueue).to(exchange).with(this.paymentRequestKey); }
Example #16
Source File: RabbitMQConfigAsync.java From Spring-5.0-Cookbook with MIT License | 4 votes |
@Bean public Binding binding(DirectExchange exchange, Queue requestQueue) { return BindingBuilder.bind(requestQueue).to(exchange).with("packt.async"); }
Example #17
Source File: RabbitMQConfig.java From Spring-5.0-Cookbook with MIT License | 4 votes |
@Bean public Binding bindingAsync(DirectExchange exchange, Queue queue) { return BindingBuilder.bind(queue).to(exchange).with("packt"); }
Example #18
Source File: RabbitConfiguration.java From heimdall with Apache License 2.0 | 4 votes |
@Bean public Binding bindingCleanInterceptorsCache() { return BindingBuilder.bind(queueCleanInterceptorsCache()).to(exchangeFanoutCleanInterceptorsCache()); }
Example #19
Source File: RabbitConfiguration.java From heimdall with Apache License 2.0 | 4 votes |
@Bean public Binding bindingRemoveMiddlewares() { return BindingBuilder.bind(queueRemoveMiddlewares()).to(exchangeFanoutRemoveMiddlewares()); }
Example #20
Source File: RabbitSinkTests.java From spring-cloud-stream-app-starters with Apache License 2.0 | 4 votes |
@Bean public Binding binding() { return BindingBuilder.bind(queue()).to(exchange()).with("scsapp-testrk"); }
Example #21
Source File: AmqpConfig.java From articles with Apache License 2.0 | 4 votes |
@Bean("tradeDeleteQueueBinding") public Binding tradeDeleteQueueBinding(@Qualifier("tradeDeleteQueue") Queue tradeDeleteQueue, DirectExchange tradeExchange) { return BindingBuilder.bind(tradeDeleteQueue).to(tradeExchange).withQueueName(); }
Example #22
Source File: RabbitBinderTests.java From spring-cloud-stream-binder-rabbit with Apache License 2.0 | 4 votes |
@Test public void testRoutingKeyExpression() throws Exception { RabbitTestBinder binder = getBinder(); ExtendedProducerProperties<RabbitProducerProperties> producerProperties = createProducerProperties(); producerProperties.getExtension().setRoutingKeyExpression( spelExpressionParser.parseExpression("payload.field")); DirectChannel output = createBindableChannel("output", createProducerBindingProperties(producerProperties)); output.setBeanName("rkeProducer"); Binding<MessageChannel> producerBinding = binder.bindProducer("rke", output, producerProperties); RabbitAdmin admin = new RabbitAdmin(this.rabbitAvailableRule.getResource()); Queue queue = new AnonymousQueue(); TopicExchange exchange = new TopicExchange("rke"); org.springframework.amqp.core.Binding binding = BindingBuilder.bind(queue) .to(exchange).with("rkeTest"); admin.declareQueue(queue); admin.declareBinding(binding); output.addInterceptor(new ChannelInterceptor() { @Override public Message<?> preSend(Message<?> message, MessageChannel channel) { assertThat(message.getHeaders() .get(RabbitExpressionEvaluatingInterceptor.ROUTING_KEY_HEADER)) .isEqualTo("rkeTest"); return message; } }); output.send(new GenericMessage<>(new Pojo("rkeTest"))); Object out = spyOn(queue.getName()).receive(false); assertThat(out).isInstanceOf(byte[].class); assertThat(new String((byte[]) out, StandardCharsets.UTF_8)) .isEqualTo("{\"field\":\"rkeTest\"}"); producerBinding.unbind(); }
Example #23
Source File: RabbitConfiguration.java From heimdall with Apache License 2.0 | 4 votes |
@Bean public Binding bindingRefreshAllInterceptors() { return BindingBuilder.bind(queueRefreshAllInterceptors()).to(exchangeFanoutRefreshAllInterceptors()); }
Example #24
Source File: RabbitConfiguration.java From heimdall with Apache License 2.0 | 4 votes |
@Bean public Binding bindingInterceptors() { return BindingBuilder.bind(queueInterceptors()).to(exchangeFanoutAddInterceptors()); }
Example #25
Source File: RabbitConfiguration.java From heimdall with Apache License 2.0 | 4 votes |
@Bean public Binding bindingRemoveInterceptors() { return BindingBuilder.bind(queueRemoveInterceptors()).to(exchangeFanoutRemoveInterceptors()); }
Example #26
Source File: RabbitConfiguration.java From heimdall with Apache License 2.0 | 4 votes |
@Bean public Binding bindingRoutes() { return BindingBuilder.bind(queueRoutes()).to(exchangeFanoutRoutes()); }
Example #27
Source File: RabbitConfig.java From iot-dc3 with Apache License 2.0 | 4 votes |
@Bean Binding pointValueBinding() { return BindingBuilder.bind(pointValueQueue()).to(exchange()).with("value.*"); }
Example #28
Source File: TopicRabbitConfig.java From iot-dc3 with Apache License 2.0 | 4 votes |
@Bean Binding driverNotifyBinding() { return BindingBuilder.bind(driverNotifyQueue()).to(exchange()).with("driver." + this.serviceName); }
Example #29
Source File: MQConsumerConfig.java From lemon-rabbitmq with Apache License 2.0 | 4 votes |
@Bean public Binding binding(Queue queue, TopicExchange exchange){ return BindingBuilder.bind(queue).to(exchange).with(routingkey); }
Example #30
Source File: FanoutRabbitConfig.java From springboot-learning-experience with Apache License 2.0 | 4 votes |
@Bean Binding bindingExchangeC(Queue CMessage, FanoutExchange fanoutExchange) { return BindingBuilder.bind(CMessage).to(fanoutExchange); }