org.springframework.amqp.core.Exchange Java Examples
The following examples show how to use
org.springframework.amqp.core.Exchange.
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: 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 #3
Source File: RabbitMQInitializer.java From sinavi-jfw with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ @Override public void destroy() throws Exception { if (deleted) { L.debug(R.getString("D-AMQP-INITIALIZER#0002")); Map<String, Exchange> exchanges = context.getBeansOfType(Exchange.class); for (Map.Entry<String, Exchange> exchange : exchanges.entrySet()) { Exchange e = exchange.getValue(); L.debug(Strings.substitute(R.getString("D-AMQP-INITIALIZER#0006"), Maps.hash("name", e.getName()))); admin.deleteExchange(e.getName()); } Map<String, Queue> queues = context.getBeansOfType(Queue.class); for (Map.Entry<String, Queue> queue : queues.entrySet()) { Queue q = queue.getValue(); L.debug(Strings.substitute(R.getString("D-AMQP-INITIALIZER#0007"), Maps.hash("name", q.getName()))); admin.deleteQueue(q.getName()); } } else { L.debug(R.getString("D-AMQP-INITIALIZER#0008")); } }
Example #4
Source File: RabbitExchangeQueueProvisioner.java From spring-cloud-stream-binder-rabbit with Apache License 2.0 | 5 votes |
private Binding declareConsumerBindings(String name, String routingKey, ExtendedConsumerProperties<RabbitConsumerProperties> properties, Exchange exchange, boolean partitioned, Queue queue) { if (partitioned) { return partitionedBinding(name, exchange, queue, routingKey, properties.getExtension(), properties.getInstanceIndex()); } else { return notPartitionedBinding(exchange, queue, routingKey, properties.getExtension()); } }
Example #5
Source File: AmqpReporter.java From haven-platform with Apache License 2.0 | 5 votes |
@Override public RabbitTemplate call() throws Exception { ConnectionFactory connectionFactory = connectionFactoryProvider.getObject(); Assert.notNull(connectionFactory, "connectionFactory is null"); if(exchangeFactory != null) { Exchange exchange = exchangeFactory.call(); if(exchange != null) { RabbitAdmin admin = new RabbitAdmin(connectionFactory); admin.declareExchange(exchange); } } return new RabbitTemplate(connectionFactory); }
Example #6
Source File: RabbitMQInitializer.java From sinavi-jfw with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override public void afterPropertiesSet() throws Exception { Args.checkNotNull(admin, R.getObject("E-AMQP-INITIALIZER#0001")); L.debug(R.getString("D-AMQP-INITIALIZER#0001")); Map<String, Exchange> exchanges = context.getBeansOfType(Exchange.class); for (Map.Entry<String, Exchange> exchange : exchanges.entrySet()) { Exchange e = exchange.getValue(); L.debug(Strings.substitute(R.getString("D-AMQP-INITIALIZER#0003"), Maps.hash("name", e.getName()))); admin.declareExchange(e); } Map<String, Queue> queues = context.getBeansOfType(Queue.class); for (Map.Entry<String, Queue> queue : queues.entrySet()) { Queue q = queue.getValue(); L.debug(Strings.substitute(R.getString("D-AMQP-INITIALIZER#0004"), Maps.hash("name", q.getName()))); admin.declareQueue(q); } Map<String, Binding> bindings = context.getBeansOfType(Binding.class); for (Map.Entry<String, Binding> binding : bindings.entrySet()) { Binding b = binding.getValue(); L.debug(Strings.substitute(R.getString("D-AMQP-INITIALIZER#0005"), Maps.hash("ename", b.getExchange()) .map("qname", b.getDestination()) .map("key", b.getRoutingKey()))); admin.declareBinding(b); } }
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 |
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 #9
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 #10
Source File: RabbitMQInitializerTest.java From sinavi-jfw with Apache License 2.0 | 4 votes |
@Bean public Exchange exchange() { return new DirectExchange("etest"); }
Example #11
Source File: RetryTestConsumerContextConfig.java From sinavi-jfw with Apache License 2.0 | 4 votes |
@Bean @DependsOn("amqpAdmin") public Exchange retryTestExchange() { return new DirectExchange("retry.test.exchange"); }
Example #12
Source File: ExceptionQueueContextConfig.java From sinavi-jfw with Apache License 2.0 | 4 votes |
/** * 例外のルーティングキーに応じて配信するキューを決定する{@link Exchange}のインスタンスを生成し、DIコンテナに登録します。 * @return {@link TopicExchange}のインスタンス */ @Bean public Exchange exceptionExchange() { return new TopicExchange(exceptionExchangeKey); }
Example #13
Source File: ExceptionQueueContextConfig.java From sinavi-jfw with Apache License 2.0 | 4 votes |
/** * 例外用の{@link Exchange}のインスタンスを生成し、DIコンテナに登録します。 * @return {@link TopicExchange}のインスタンス */ @Bean public Exchange errorExchange() { return new TopicExchange(errorExchangeKey); }
Example #14
Source File: RabbitMQConfiguration.java From cukes with Apache License 2.0 | 4 votes |
@Bean Exchange exchange() { return new TopicExchange(EXCHANGE_NAME); }
Example #15
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 #16
Source File: RabbitExchangeQueueProvisioner.java From spring-cloud-stream-binder-rabbit with Apache License 2.0 | 4 votes |
RabbitProducerDestination(Exchange exchange, Binding binding) { Assert.notNull(exchange, "exchange must not be null"); this.exchange = exchange; this.binding = binding; }
Example #17
Source File: MessagePublisher.java From spring-cloud-contract with Apache License 2.0 | 4 votes |
public MessagePublisher(RabbitTemplate rabbitTemplate, Exchange exchange) { this.rabbitTemplate = rabbitTemplate; this.exchange = exchange; }
Example #18
Source File: AmqpMessagingApplication.java From spring-cloud-contract with Apache License 2.0 | 4 votes |
@Bean public Exchange testExchange() { return new TopicExchange("test-exchange"); }
Example #19
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 #20
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 #21
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."); }); }