List of usage examples for org.springframework.amqp.core Exchange getType
String getType();
From source file:org.springframework.amqp.rabbit.core.RabbitAdmin.java
private void declareExchanges(final Channel channel, final Exchange... exchanges) throws IOException { for (final Exchange exchange : exchanges) { if (logger.isDebugEnabled()) { logger.debug("declaring Exchange '" + exchange.getName() + "'"); }// w w w . ja va 2 s. c om if (!isDeclaringDefaultExchange(exchange)) { channel.exchangeDeclare(exchange.getName(), exchange.getType(), exchange.isDurable(), exchange.isAutoDelete(), exchange.getArguments()); } } }
From source file:org.springframework.cloud.stream.binder.rabbit.provisioning.RabbitExchangeQueueProvisioner.java
private Binding partitionedBinding(String destination, Exchange exchange, Queue queue, RabbitCommonProperties extendedProperties, int index) { String bindingKey = extendedProperties.getBindingRoutingKey(); if (bindingKey == null) { bindingKey = destination;//from w ww . j a v a 2 s .c om } bindingKey += "-" + index; if (exchange instanceof TopicExchange) { Binding binding = BindingBuilder.bind(queue).to((TopicExchange) exchange).with(bindingKey); declareBinding(queue.getName(), binding); return binding; } else if (exchange instanceof DirectExchange) { Binding binding = BindingBuilder.bind(queue).to((DirectExchange) exchange).with(bindingKey); declareBinding(queue.getName(), binding); return binding; } else if (exchange instanceof FanoutExchange) { throw new ProvisioningException("A fanout exchange is not appropriate for partitioned apps"); } else { throw new ProvisioningException("Cannot bind to a " + exchange.getType() + " exchange"); } }
From source file:org.springframework.cloud.stream.binder.rabbit.provisioning.RabbitExchangeQueueProvisioner.java
private Binding notPartitionedBinding(Exchange exchange, Queue queue, RabbitCommonProperties extendedProperties) { String routingKey = extendedProperties.getBindingRoutingKey(); if (routingKey == null) { routingKey = "#"; }//from w w w.j a v a2 s .co m if (exchange instanceof TopicExchange) { Binding binding = BindingBuilder.bind(queue).to((TopicExchange) exchange).with(routingKey); declareBinding(queue.getName(), binding); return binding; } else if (exchange instanceof DirectExchange) { Binding binding = BindingBuilder.bind(queue).to((DirectExchange) exchange).with(routingKey); declareBinding(queue.getName(), binding); return binding; } else if (exchange instanceof FanoutExchange) { Binding binding = BindingBuilder.bind(queue).to((FanoutExchange) exchange); declareBinding(queue.getName(), binding); return binding; } else { throw new ProvisioningException("Cannot bind to a " + exchange.getType() + " exchange"); } }