本文整理汇总了Java中org.springframework.amqp.core.DirectExchange类的典型用法代码示例。如果您正苦于以下问题:Java DirectExchange类的具体用法?Java DirectExchange怎么用?Java DirectExchange使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DirectExchange类属于org.springframework.amqp.core包,在下文中一共展示了DirectExchange类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testConsumerPropertiesWithUserInfrastructureNoBind
import org.springframework.amqp.core.DirectExchange; //导入依赖的package包/类
@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();
RabbitManagementTemplate rmt = new RabbitManagementTemplate();
List<org.springframework.amqp.core.Binding> bindings = rmt.getBindingsForExchange("/", exchange.getName());
assertThat(bindings.size()).isEqualTo(1);
}
示例2: autoBindDLQ
import org.springframework.amqp.core.DirectExchange; //导入依赖的package包/类
/**
* 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);
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));
}
}
}
开发者ID:spring-cloud,项目名称:spring-cloud-stream-binder-rabbit,代码行数:46,代码来源:RabbitExchangeQueueProvisioner.java
示例3: bindReplicationBroadcast
import org.springframework.amqp.core.DirectExchange; //导入依赖的package包/类
@Bean
public Binding bindReplicationBroadcast(Queue replicationQueue) {
return BindingBuilder
.bind(replicationQueue)
.to(new DirectExchange(replicationExchange))
.with(broadcastKey);
}
示例4: bindReplicationUnicast
import org.springframework.amqp.core.DirectExchange; //导入依赖的package包/类
@Bean
public Binding bindReplicationUnicast(Queue replicationQueue) {
return BindingBuilder
.bind(replicationQueue)
.to(new DirectExchange(replicationExchange))
.with(nodeId);
}
示例5: bindReplicationUnicast
import org.springframework.amqp.core.DirectExchange; //导入依赖的package包/类
@Bean
public Binding bindReplicationUnicast(Queue replicationQueue) {
return BindingBuilder
.bind(replicationQueue)
.to(new DirectExchange(replicationExchange))
.with(testNodeId);
}
示例6: bindingReplication
import org.springframework.amqp.core.DirectExchange; //导入依赖的package包/类
@Bean
public Binding bindingReplication(Queue replicationQueue, DirectExchange replicationExchange) {
return BindingBuilder
.bind(replicationQueue)
.to(replicationExchange)
.with(broadcastKey);
}
示例7: prepareQueues
import org.springframework.amqp.core.DirectExchange; //导入依赖的package包/类
@Bean
public InitializingBean prepareQueues(AmqpAdmin amqpAdmin) {
return () -> {
Queue queue = new Queue(NOTIFICATIONS, true);
DirectExchange exchange = new DirectExchange(NOTIFICATIONS);
Binding binding = BindingBuilder.bind(queue).to(exchange).with(NOTIFICATIONS);
amqpAdmin.declareQueue(queue);
amqpAdmin.declareExchange(exchange);
amqpAdmin.declareBinding(binding);
};
}
示例8: prepareQueues
import org.springframework.amqp.core.DirectExchange; //导入依赖的package包/类
@Bean
public InitializingBean prepareQueues(AmqpAdmin amqpAdmin) {
return () -> {
Queue queue = new Queue(this.echoQueueAndExchangeName, true);
DirectExchange exchange = new DirectExchange(this.echoQueueAndExchangeName);
Binding binding = BindingBuilder.bind(queue).to(exchange)
.with(this.echoQueueAndExchangeName);
amqpAdmin.declareQueue(queue);
amqpAdmin.declareExchange(exchange);
amqpAdmin.declareBinding(binding);
};
}
示例9: exchange
import org.springframework.amqp.core.DirectExchange; //导入依赖的package包/类
@Bean
public DirectExchange exchange() {
return new DirectExchange("login.packt");
}
示例10: bindingAsync
import org.springframework.amqp.core.DirectExchange; //导入依赖的package包/类
@Bean
public Binding bindingAsync(DirectExchange exchange, Queue queue) {
return BindingBuilder.bind(queue).to(exchange).with("packt");
}
示例11: binding
import org.springframework.amqp.core.DirectExchange; //导入依赖的package包/类
@Bean
public Binding binding(DirectExchange exchange, Queue requestQueue) {
return BindingBuilder.bind(requestQueue).to(exchange).with("packt.async");
}
示例12: exchange
import org.springframework.amqp.core.DirectExchange; //导入依赖的package包/类
@Bean
public DirectExchange exchange() {
return new DirectExchange("login.packt");
}
示例13: directExchange
import org.springframework.amqp.core.DirectExchange; //导入依赖的package包/类
@Bean
DirectExchange directExchange() {
return new DirectExchange(exchangeName);
}
示例14: exchange
import org.springframework.amqp.core.DirectExchange; //导入依赖的package包/类
@Bean
public DirectExchange exchange() {
return new DirectExchange(AmqpConfig.O2O_EXCHANGE);
}
示例15: binding
import org.springframework.amqp.core.DirectExchange; //导入依赖的package包/类
@Bean(name = "logBinding")
public Binding binding(Queue logeQueue, DirectExchange exchange) {
return BindingBuilder.bind(logeQueue).to(exchange).with(O2O_LOG_ROUTINGKEY);
}