org.springframework.amqp.core.ExchangeBuilder Java Examples
The following examples show how to use
org.springframework.amqp.core.ExchangeBuilder.
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: RabbitExchangeQueueProvisioner.java From spring-cloud-stream-binder-rabbit with Apache License 2.0 | 6 votes |
private Exchange buildExchange(RabbitCommonProperties properties, String exchangeName) { try { ExchangeBuilder builder = new ExchangeBuilder(exchangeName, properties.getExchangeType()); builder.durable(properties.isExchangeDurable()); if (properties.isExchangeAutoDelete()) { builder.autoDelete(); } if (properties.isDelayedExchange()) { builder.delayed(); } return builder.build(); } catch (Exception e) { throw new ProvisioningException("Failed to create exchange object", e); } }
Example #2
Source File: RabbitTemplateMessageQueueFactory.java From elasticactors with Apache License 2.0 | 5 votes |
private void ensureQueueExists(String queueName) { // ensure we have the queue created on the broker Queue queue = QueueBuilder.durable(queueName).build(); amqpAdmin.declareQueue(queue); // and bound to the exchange DirectExchange exchange = ExchangeBuilder.directExchange(exchangeName).build(); amqpAdmin.declareBinding(BindingBuilder.bind(queue).to(exchange).with(queueName)); }
Example #3
Source File: AmqpConfiguration.java From ESarch with Apache License 2.0 | 4 votes |
@Bean public Exchange eventsExchange() { return ExchangeBuilder.topicExchange("trading-engine-events").build(); }
Example #4
Source File: AmqpMessageBrokerConfiguration.java From piper with Apache License 2.0 | 4 votes |
@Bean Exchange tasksExchange () { return ExchangeBuilder.directExchange(Exchanges.TASKS) .durable(true) .build(); }
Example #5
Source File: AmqpMessageBrokerConfiguration.java From piper with Apache License 2.0 | 4 votes |
@Bean Exchange controlExchange () { return ExchangeBuilder.fanoutExchange(Exchanges.CONTROL) .durable(true) .build(); }
Example #6
Source File: RabbitExchangeQueueProvisioner.java From spring-cloud-stream-binder-rabbit with Apache License 2.0 | 4 votes |
/** * 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 baseQueueName The base name for the queue (including the binder prefix, if * any). * @param routingKey The routing key for the queue. * @param properties the properties. */ private void autoBindDLQ(final String baseQueueName, String routingKey, RabbitCommonProperties properties) { boolean autoBindDlq = properties.isAutoBindDlq(); if (this.logger.isDebugEnabled()) { this.logger.debug("autoBindDLQ=" + autoBindDlq + " for: " + baseQueueName); } if (autoBindDlq) { String dlqName; if (properties.getDeadLetterQueueName() == null) { dlqName = constructDLQName(baseQueueName); } else { dlqName = properties.getDeadLetterQueueName(); } Queue dlq = new Queue(dlqName, true, false, false, queueArgs(dlqName, properties, true)); declareQueue(dlqName, dlq); String dlxName = deadLetterExchangeName(properties); if (properties.isDeclareDlx()) { declareExchange(dlxName, new ExchangeBuilder(dlxName, properties.getDeadLetterExchangeType()).durable(true) .build()); } Map<String, Object> arguments = new HashMap<>(properties.getDlqBindingArguments()); Binding dlqBinding = new Binding(dlq.getName(), DestinationType.QUEUE, dlxName, properties.getDeadLetterRoutingKey() == null ? routingKey : properties.getDeadLetterRoutingKey(), arguments); declareBinding(dlqName, dlqBinding); if (properties instanceof RabbitConsumerProperties && ((RabbitConsumerProperties) properties).isRepublishToDlq()) { /* * Also bind with the base queue name when republishToDlq is used, which * does not know about partitioning */ declareBinding(dlqName, new Binding(dlq.getName(), DestinationType.QUEUE, dlxName, baseQueueName, arguments)); } } }
Example #7
Source File: RabbitConfig.java From POC with Apache License 2.0 | 4 votes |
@Bean Exchange ordersExchange() { return ExchangeBuilder.topicExchange(EXCHANGE_ORDERS).build(); }
Example #8
Source File: AmqpReactiveController.java From tutorials with MIT License | 4 votes |
@PostConstruct public void setupTopicDestinations() { // For topic each consumer will have its own Queue, so no binding destinationsConfig.getTopics() .forEach((key, destination) -> { log.info("[I98] Creating TopicExchange: name={}, exchange={}", key, destination.getExchange()); Exchange ex = ExchangeBuilder.topicExchange(destination.getExchange()) .durable(true) .build(); amqpAdmin.declareExchange(ex); log.info("[I107] Topic Exchange successfully created."); }); }
Example #9
Source File: AmqpReactiveController.java From tutorials with MIT License | 4 votes |
private Queue createTopicQueue(DestinationsConfig.DestinationInfo destination) { Exchange ex = ExchangeBuilder.topicExchange(destination.getExchange()) .durable(true) .build(); amqpAdmin.declareExchange(ex); Queue q = QueueBuilder.nonDurable() .build(); amqpAdmin.declareQueue(q); Binding b = BindingBuilder.bind(q) .to(ex) .with(destination.getRoutingKey()) .noargs(); amqpAdmin.declareBinding(b); return q; }
Example #10
Source File: AmqpReactiveController.java From tutorials with MIT License | 3 votes |
@PostConstruct public void setupQueueDestinations() { log.info("[I48] Creating Destinations..."); destinationsConfig.getQueues() .forEach((key, destination) -> { log.info("[I54] Creating directExchange: key={}, name={}, routingKey={}", key, destination.getExchange(), destination.getRoutingKey()); Exchange ex = ExchangeBuilder.directExchange(destination.getExchange()) .durable(true) .build(); amqpAdmin.declareExchange(ex); Queue q = QueueBuilder.durable(destination.getRoutingKey()) .build(); amqpAdmin.declareQueue(q); Binding b = BindingBuilder.bind(q) .to(ex) .with(destination.getRoutingKey()) .noargs(); amqpAdmin.declareBinding(b); log.info("[I70] Binding successfully created."); }); }