本文整理了Java中org.springframework.amqp.core.Binding
类的一些代码示例,展示了Binding
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Binding
类的具体详情如下:
包路径:org.springframework.amqp.core.Binding
类名称:Binding
[英]Simple container collecting information to describe a binding. Takes String destination and exchange names as arguments to facilitate wiring using code based configuration. Can be used in conjunction with AmqpAdmin, or created via a BindingBuilder.
[中]收集信息以描述绑定的简单容器。将字符串目标和交换名称作为参数,以便于使用基于代码的配置进行连接。可与AmqpAdmin结合使用,或通过BindingBuilder创建。
代码示例来源:origin: org.springframework.amqp/spring-rabbit
private void declareBindings(final Channel channel, final Binding... bindings) throws IOException {
for (Binding binding : bindings) {
if (this.logger.isDebugEnabled()) {
this.logger.debug("Binding destination [" + binding.getDestination() + " (" + binding.getDestinationType()
+ ")] to exchange [" + binding.getExchange() + "] with routing key [" + binding.getRoutingKey()
+ "]");
}
try {
if (binding.isDestinationQueue()) {
if (!isDeclaringImplicitQueueBinding(binding)) {
channel.queueBind(binding.getDestination(), binding.getExchange(), binding.getRoutingKey(),
binding.getArguments());
}
}
else {
channel.exchangeBind(binding.getDestination(), binding.getExchange(), binding.getRoutingKey(),
binding.getArguments());
}
}
catch (IOException e) {
logOrRethrowDeclarationException(binding, "binding", e);
}
}
}
代码示例来源:origin: spring-projects/spring-amqp
public Binding and(Map<String, Object> map) {
return new Binding(this.configurer.destination.name, this.configurer.destination.type, this.configurer.exchange,
this.routingKey, map);
}
代码示例来源:origin: spring-projects/spring-amqp
@Override
public Binding getObject() {
String destination;
DestinationType destinationType;
if (this.destinationQueue != null) {
destination = this.destinationQueue.getName();
destinationType = DestinationType.QUEUE;
}
else {
destination = this.destinationExchange.getName();
destinationType = DestinationType.EXCHANGE;
}
Binding binding = new Binding(destination, destinationType, this.exchange, this.routingKey, this.arguments);
if (this.shouldDeclare != null) {
binding.setShouldDeclare(this.shouldDeclare);
}
if (this.ignoreDeclarationExceptions != null) {
binding.setIgnoreDeclarationExceptions(this.ignoreDeclarationExceptions);
}
if (this.adminsThatShouldDeclare != null) {
binding.setAdminsThatShouldDeclare((Object[]) this.adminsThatShouldDeclare);
}
return binding;
}
代码示例来源:origin: com.dell.cpsd/common-rabbitmq
/**
* Add a binding
*
*/
public RabbitContextBuilder add(Binding binding)
{
bindings.put(Arrays.toString(new String[] {binding.getExchange(), binding.getExchange(), binding.getRoutingKey()}), binding);
return this;
}
代码示例来源:origin: spring-projects/spring-amqp
private boolean isImplicitQueueBinding(Binding binding) {
return isDefaultExchange(binding.getExchange()) && binding.getDestination().equals(binding.getRoutingKey());
}
代码示例来源:origin: spring-projects/spring-amqp
@Test
public void testBindings() throws Exception {
Map<String, Binding> bindings = beanFactory.getBeansOfType(Binding.class);
// 4 for each exchange type
assertEquals(13, bindings.size());
for (Map.Entry<String, Binding> bindingEntry : bindings.entrySet()) {
Binding binding = bindingEntry.getValue();
if ("headers-test".equals(binding.getExchange()) && "bucket".equals(binding.getDestination())) {
Map<String, Object> arguments = binding.getArguments();
assertEquals(3, arguments.size());
break;
}
}
}
代码示例来源:origin: spring-projects/spring-amqp
@Bean
public Binding binding() throws IOException {
Binding binding = new Binding("foo", DestinationType.QUEUE, exchange().getName(), "foo", null);
binding.setAdminsThatShouldDeclare(admin1());
return binding;
}
}
代码示例来源:origin: com.dell.cpsd/hdp-capability-registry-client
/**
* The message consumer for the service control messages.
*
* @return The message consumer for the service responses.
*
* @since 1.0
*/
@Bean
IAmqpCapabilityRegistryControlConsumer capabilityRegistryControlConsumer()
{
final String replyTo = this.capabilityRegistryControlQueueBinding.getRoutingKey();
return new AmqpCapabilityRegistryControlConsumer(replyTo, this.capabilityRegistryControlProducer);
}
代码示例来源:origin: spring-projects/spring-amqp
exchange.setShouldDeclare(false);
context.getBeanFactory().registerSingleton("bar", exchange);
Binding binding = new Binding("foo", DestinationType.QUEUE, "bar", "foo", null);
binding.setShouldDeclare(false);
context.getBeanFactory().registerSingleton("baz", binding);
context.refresh();
代码示例来源:origin: spring-projects/spring-amqp
@Test
public void testDirectExchange() throws Exception {
DirectExchange exchange = beanFactory.getBean("direct", DirectExchange.class);
assertNotNull(exchange);
assertEquals("direct", exchange.getName());
assertTrue(exchange.isDurable());
assertFalse(exchange.isAutoDelete());
assertFalse(exchange.shouldDeclare());
assertEquals(2, exchange.getDeclaringAdmins().size());
Binding binding =
beanFactory.getBean("org.springframework.amqp.rabbit.config.BindingFactoryBean#0", Binding.class);
assertFalse(binding.shouldDeclare());
assertEquals(2, binding.getDeclaringAdmins().size());
Map<String, Object> arguments = binding.getArguments();
assertNotNull(arguments);
assertEquals(1, arguments.size());
assertTrue(arguments.containsKey("x-match"));
assertEquals("any", arguments.get("x-match"));
}
代码示例来源:origin: stackoverflow.com
binding.setAdminsThatShouldDeclare(rabbitAdmin);
代码示例来源:origin: org.springframework.amqp/spring-rabbit
private boolean isImplicitQueueBinding(Binding binding) {
return isDefaultExchange(binding.getExchange()) && binding.getDestination().equals(binding.getRoutingKey());
}
代码示例来源:origin: com.dell.cpsd.common.messaging/common-rabbitmq
/**
* Add a binding
*
*/
public RabbitContextBuilder add(Binding binding)
{
bindings.put(Arrays.toString(new String[] {binding.getExchange(), binding.getExchange(), binding.getRoutingKey()}), binding);
return this;
}
代码示例来源:origin: spring-projects/spring-amqp
exchange.setAdminsThatShouldDeclare(admin);
context.getBeanFactory().registerSingleton("bar", exchange);
Binding binding = new Binding("foo", DestinationType.QUEUE, "bar", "foo", null);
binding.setAdminsThatShouldDeclare(admin);
context.getBeanFactory().registerSingleton("baz", binding);
context.refresh();
代码示例来源:origin: com.dell.cpsd/hdp-capability-registry-client
/**
* The message consumer for the service responses.
*
* @return The message consumer for the service responses.
*
* @since 1.0
*/
@Bean("name=capabilityRegistryServiceConsumer")
IAmqpCapabilityRegistryServiceConsumer capabilityRegistryServiceConsumer()
{
final String replyTo = this.capabilityRegistryResponseQueueBinding.getRoutingKey();
return new AmqpCapabilityRegistryServiceConsumer(replyTo);
}
代码示例来源:origin: spring-projects/spring-amqp
private void declareBindings(final Channel channel, final Binding... bindings) throws IOException {
for (Binding binding : bindings) {
if (this.logger.isDebugEnabled()) {
this.logger.debug("Binding destination [" + binding.getDestination() + " (" + binding.getDestinationType()
+ ")] to exchange [" + binding.getExchange() + "] with routing key [" + binding.getRoutingKey()
+ "]");
}
try {
if (binding.isDestinationQueue()) {
if (!isDeclaringImplicitQueueBinding(binding)) {
channel.queueBind(binding.getDestination(), binding.getExchange(), binding.getRoutingKey(),
binding.getArguments());
}
}
else {
channel.exchangeBind(binding.getDestination(), binding.getExchange(), binding.getRoutingKey(),
binding.getArguments());
}
}
catch (IOException e) {
logOrRethrowDeclarationException(binding, "binding", e);
}
}
}
代码示例来源:origin: com.dell.cpsd.common.messaging/common-rabbitmq
bindings.stream().filter(b -> q.getName().equals(b.getDestination())).forEach(b ->
MessageExchangeDto exchange = exchangeMap.get(b.getExchange());
if (exchange == null)
exchange = new MessageExchangeDto(b.getExchange(), MessageDirectionType.CONSUME);
exchangeMap.put(b.getExchange(), exchange);
List<BindingDataDto> exchangeBinding = exchangeToBindingMap.get(b.getExchange());
if (exchangeBinding == null)
exchangeToBindingMap.put(b.getExchange(), exchangeBinding);
exchangeBinding.add(new BindingDataDto(b.getDestination(), b.getRoutingKey()));
});
});
代码示例来源:origin: spring-projects/spring-amqp
public Binding withQueueName() {
return new Binding(destination.name, destination.type, exchange, destination.name,
Collections.<String, Object>emptyMap());
}
}
代码示例来源:origin: org.springframework.amqp/spring-rabbit
@Override
public Binding getObject() {
String destination;
DestinationType destinationType;
if (this.destinationQueue != null) {
destination = this.destinationQueue.getName();
destinationType = DestinationType.QUEUE;
}
else {
destination = this.destinationExchange.getName();
destinationType = DestinationType.EXCHANGE;
}
Binding binding = new Binding(destination, destinationType, this.exchange, this.routingKey, this.arguments);
if (this.shouldDeclare != null) {
binding.setShouldDeclare(this.shouldDeclare);
}
if (this.ignoreDeclarationExceptions != null) {
binding.setIgnoreDeclarationExceptions(this.ignoreDeclarationExceptions);
}
if (this.adminsThatShouldDeclare != null) {
binding.setAdminsThatShouldDeclare((Object[]) this.adminsThatShouldDeclare);
}
return binding;
}
代码示例来源:origin: spring-projects/spring-amqp
exchange.setAdminsThatShouldDeclare(other);
context.getBeanFactory().registerSingleton("bar", exchange);
Binding binding = new Binding("foo", DestinationType.QUEUE, "bar", "foo", null);
binding.setAdminsThatShouldDeclare(other);
context.getBeanFactory().registerSingleton("baz", binding);
context.refresh();
内容来源于网络,如有侵权,请联系作者删除!