List of usage examples for org.springframework.amqp.core DirectExchange DirectExchange
public DirectExchange(String name)
From source file:com.baocy.tut4.Tut4Config.java
@Bean public DirectExchange direct() { return new DirectExchange("tut.direct"); }
From source file:com.expedia.seiso.SeisoRabbitConfig.java
@Bean public Exchange seisoActionRequestsExchange() { // Use a direct exchange since we want to route requests according to their request codes. return new DirectExchange(customProperties.getActionRequestExchange()); }
From source file:crawler.configuration.rabbitmq.RabbitMQConfiguration.java
@Bean Exchange urlExchange() { Exchange exchange = new DirectExchange(urlExchangeName); amqpAdmin.declareExchange(exchange); return exchange; }
From source file:org.farrukh.examples.amqp.Application.java
/** * RabbitMQ message exchange./* w w w . jav a 2 s . co m*/ * @param configuration - exchange name holder object. * @return - direct message exchange. */ @Bean public Exchange exchange(final ApplicationProperties configuration) { return new DirectExchange(configuration.getExchangeName()); }
From source file:org.cloudfoundry.workers.stocks.integration.service.config.ServiceConfiguration.java
@Bean public DirectExchange customerExchange() throws Throwable { DirectExchange directExchange = new DirectExchange(stocks); this.amqpAdmin().declareExchange(directExchange); return directExchange; }
From source file:org.springframework.cloud.netflix.hystrix.amqp.HystrixStreamAutoConfiguration.java
@Bean public DirectExchange hystrixStreamExchange() { DirectExchange exchange = new DirectExchange(HystrixConstants.HYSTRIX_STREAM_NAME); return exchange; }
From source file:org.cloudfoundry.workers.stocks.integration.client.ClientConfiguration.java
@Bean public DirectExchange customerExchange() throws Throwable { DirectExchange directExchange = new DirectExchange(tickers); this.amqpAdmin().declareExchange(directExchange); return directExchange; }
From source file:org.springframework.amqp.rabbit.core.RabbitAdminTests.java
@Test public void testIgnoreDeclarationExeptionsTimeout() throws Exception { com.rabbitmq.client.ConnectionFactory rabbitConnectionFactory = mock( com.rabbitmq.client.ConnectionFactory.class); TimeoutException toBeThrown = new TimeoutException("test"); doThrow(toBeThrown).when(rabbitConnectionFactory).newConnection(any(ExecutorService.class), anyString()); CachingConnectionFactory ccf = new CachingConnectionFactory(rabbitConnectionFactory); RabbitAdmin admin = new RabbitAdmin(ccf); List<DeclarationExceptionEvent> events = new ArrayList<DeclarationExceptionEvent>(); admin.setApplicationEventPublisher(new EventPublisher(events)); admin.setIgnoreDeclarationExceptions(true); admin.declareQueue(new AnonymousQueue()); admin.declareQueue();//www.j a v a2s . c om admin.declareExchange(new DirectExchange("foo")); admin.declareBinding(new Binding("foo", DestinationType.QUEUE, "bar", "baz", null)); assertThat(events.size(), equalTo(4)); assertThat(events.get(0).getSource(), sameInstance(admin)); assertThat(events.get(0).getDeclarable(), instanceOf(AnonymousQueue.class)); assertSame(toBeThrown, events.get(0).getThrowable().getCause()); assertNull(events.get(1).getDeclarable()); assertSame(toBeThrown, events.get(1).getThrowable().getCause()); assertThat(events.get(2).getDeclarable(), instanceOf(DirectExchange.class)); assertSame(toBeThrown, events.get(2).getThrowable().getCause()); assertThat(events.get(3).getDeclarable(), instanceOf(Binding.class)); assertSame(toBeThrown, events.get(3).getThrowable().getCause()); assertSame(events.get(3), admin.getLastDeclarationExceptionEvent()); }
From source file:org.springframework.cloud.stream.binder.rabbit.provisioning.RabbitExchangeQueueProvisioner.java
/** * 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.// w w w . j a va 2 s. c o m */ 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); final DirectExchange dlx = new DirectExchange(dlxName); declareExchange(dlxName, dlx); BindingBuilder.DirectExchangeRoutingKeyConfigurer bindingBuilder = BindingBuilder.bind(dlq).to(dlx); Binding dlqBinding; if (properties.getDeadLetterRoutingKey() == null) { dlqBinding = bindingBuilder.with(routingKey); } else { dlqBinding = bindingBuilder.with(properties.getDeadLetterRoutingKey()); } 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, BindingBuilder.bind(dlq).to(dlx).with(baseQueueName)); } } }
From source file:org.springframework.cloud.stream.binder.rabbit.RabbitBinderTests.java
@Test public void testConsumerPropertiesWithUserInfrastructureNoBind() throws Exception { RabbitAdmin admin = new RabbitAdmin(this.rabbitAvailableRule.getResource()); Queue queue = new Queue("propsUser1.infra"); admin.declareQueue(queue);//from w w w .j a va2 s. c om 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(container.isRunning()).isTrue(); consumerBinding.unbind(); assertThat(container.isRunning()).isFalse(); RabbitManagementTemplate rmt = new RabbitManagementTemplate(); List<org.springframework.amqp.core.Binding> bindings = rmt.getBindingsForExchange("/", exchange.getName()); assertThat(bindings.size()).isEqualTo(1); }