当前位置: 首页>>代码示例>>Java>>正文


Java DirectExchange类代码示例

本文整理汇总了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);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream-binder-rabbit,代码行数:28,代码来源:RabbitBinderTests.java

示例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);
}
 
开发者ID:dvoraka,项目名称:av-service,代码行数:8,代码来源:AmqpReplicationClientConfig.java

示例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);
}
 
开发者ID:dvoraka,项目名称:av-service,代码行数:8,代码来源:AmqpReplicationClientConfig.java

示例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);
}
 
开发者ID:dvoraka,项目名称:av-service,代码行数:8,代码来源:AmqpTestReplicationClientConfig.java

示例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);
}
 
开发者ID:dvoraka,项目名称:av-service,代码行数:8,代码来源:EnvironmentConfiguratorConfig.java

示例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);

	};
}
 
开发者ID:livelessons-spring,项目名称:building-microservices,代码行数:13,代码来源:MessagingApplication.java

示例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);
	};
}
 
开发者ID:livelessons-spring,项目名称:building-microservices,代码行数:13,代码来源:AmqpIntegration.java

示例9: exchange

import org.springframework.amqp.core.DirectExchange; //导入依赖的package包/类
@Bean
public DirectExchange exchange() {
       return new DirectExchange("login.packt");
}
 
开发者ID:PacktPublishing,项目名称:Spring-5.0-Cookbook,代码行数:5,代码来源:RabbitMQConfig.java

示例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");
}
 
开发者ID:PacktPublishing,项目名称:Spring-5.0-Cookbook,代码行数:5,代码来源:RabbitMQConfig.java

示例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");
}
 
开发者ID:PacktPublishing,项目名称:Spring-5.0-Cookbook,代码行数:5,代码来源:RabbitMQConfigAsync.java

示例12: exchange

import org.springframework.amqp.core.DirectExchange; //导入依赖的package包/类
@Bean
public DirectExchange exchange() {
      return new DirectExchange("login.packt");
}
 
开发者ID:PacktPublishing,项目名称:Spring-5.0-Cookbook,代码行数:5,代码来源:RabbitMQConfig.java

示例13: directExchange

import org.springframework.amqp.core.DirectExchange; //导入依赖的package包/类
@Bean
DirectExchange directExchange() {
    return new DirectExchange(exchangeName);
}
 
开发者ID:Rustam-Kadyrov,项目名称:microservices-spring,代码行数:5,代码来源:RabbitMqConfiguration.java

示例14: exchange

import org.springframework.amqp.core.DirectExchange; //导入依赖的package包/类
@Bean
public DirectExchange exchange() {
    return new DirectExchange(AmqpConfig.O2O_EXCHANGE);
}
 
开发者ID:Evan1120,项目名称:springboot-sample,代码行数:5,代码来源:BaseConfig.java

示例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);
}
 
开发者ID:Evan1120,项目名称:springboot-sample,代码行数:5,代码来源:AppLogConfig.java


注:本文中的org.springframework.amqp.core.DirectExchange类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。