org.springframework.amqp.core.Binding.getExchange()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(9.3k)|赞(0)|评价(0)|浏览(107)

本文整理了Java中org.springframework.amqp.core.Binding.getExchange()方法的一些代码示例,展示了Binding.getExchange()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Binding.getExchange()方法的具体详情如下:
包路径:org.springframework.amqp.core.Binding
类名称:Binding
方法名:getExchange

Binding.getExchange介绍

暂无

代码示例

代码示例来源:origin: com.dell.cpsd/common-rabbitmq

  1. /**
  2. * Add a binding
  3. *
  4. */
  5. public RabbitContextBuilder add(Binding binding)
  6. {
  7. bindings.put(Arrays.toString(new String[] {binding.getExchange(), binding.getExchange(), binding.getRoutingKey()}), binding);
  8. return this;
  9. }

代码示例来源:origin: com.dell.cpsd.common.messaging/common-rabbitmq

  1. /**
  2. * Add a binding
  3. *
  4. */
  5. public RabbitContextBuilder add(Binding binding)
  6. {
  7. bindings.put(Arrays.toString(new String[] {binding.getExchange(), binding.getExchange(), binding.getRoutingKey()}), binding);
  8. return this;
  9. }

代码示例来源:origin: spring-projects/spring-amqp

  1. private boolean isImplicitQueueBinding(Binding binding) {
  2. return isDefaultExchange(binding.getExchange()) && binding.getDestination().equals(binding.getRoutingKey());
  3. }

代码示例来源:origin: org.springframework.amqp/spring-rabbit

  1. private boolean isImplicitQueueBinding(Binding binding) {
  2. return isDefaultExchange(binding.getExchange()) && binding.getDestination().equals(binding.getRoutingKey());
  3. }

代码示例来源:origin: com.dell.cpsd/common-rabbitmq

  1. MessageExchangeDto exchange = exchangeMap.get(b.getExchange());
  2. if (exchange == null)
  3. exchange = new MessageExchangeDto(b.getExchange(), MessageDirectionType.CONSUME);
  4. exchangeMap.put(b.getExchange(), exchange);
  5. List<BindingDataDto> exchangeBinding = exchangeToBindingMap.get(b.getExchange());
  6. if (exchangeBinding == null)
  7. exchangeToBindingMap.put(b.getExchange(), exchangeBinding);

代码示例来源:origin: com.dell.cpsd.common.messaging/common-rabbitmq

  1. MessageExchangeDto exchange = exchangeMap.get(b.getExchange());
  2. if (exchange == null)
  3. exchange = new MessageExchangeDto(b.getExchange(), MessageDirectionType.CONSUME);
  4. exchangeMap.put(b.getExchange(), exchange);
  5. List<BindingDataDto> exchangeBinding = exchangeToBindingMap.get(b.getExchange());
  6. if (exchangeBinding == null)
  7. exchangeToBindingMap.put(b.getExchange(), exchangeBinding);

代码示例来源:origin: org.springframework.amqp/spring-rabbit

  1. private void declareBindings(final Channel channel, final Binding... bindings) throws IOException {
  2. for (Binding binding : bindings) {
  3. if (this.logger.isDebugEnabled()) {
  4. this.logger.debug("Binding destination [" + binding.getDestination() + " (" + binding.getDestinationType()
  5. + ")] to exchange [" + binding.getExchange() + "] with routing key [" + binding.getRoutingKey()
  6. + "]");
  7. }
  8. try {
  9. if (binding.isDestinationQueue()) {
  10. if (!isDeclaringImplicitQueueBinding(binding)) {
  11. channel.queueBind(binding.getDestination(), binding.getExchange(), binding.getRoutingKey(),
  12. binding.getArguments());
  13. }
  14. }
  15. else {
  16. channel.exchangeBind(binding.getDestination(), binding.getExchange(), binding.getRoutingKey(),
  17. binding.getArguments());
  18. }
  19. }
  20. catch (IOException e) {
  21. logOrRethrowDeclarationException(binding, "binding", e);
  22. }
  23. }
  24. }

代码示例来源:origin: spring-projects/spring-amqp

  1. private void declareBindings(final Channel channel, final Binding... bindings) throws IOException {
  2. for (Binding binding : bindings) {
  3. if (this.logger.isDebugEnabled()) {
  4. this.logger.debug("Binding destination [" + binding.getDestination() + " (" + binding.getDestinationType()
  5. + ")] to exchange [" + binding.getExchange() + "] with routing key [" + binding.getRoutingKey()
  6. + "]");
  7. }
  8. try {
  9. if (binding.isDestinationQueue()) {
  10. if (!isDeclaringImplicitQueueBinding(binding)) {
  11. channel.queueBind(binding.getDestination(), binding.getExchange(), binding.getRoutingKey(),
  12. binding.getArguments());
  13. }
  14. }
  15. else {
  16. channel.exchangeBind(binding.getDestination(), binding.getExchange(), binding.getRoutingKey(),
  17. binding.getArguments());
  18. }
  19. }
  20. catch (IOException e) {
  21. logOrRethrowDeclarationException(binding, "binding", e);
  22. }
  23. }
  24. }

代码示例来源:origin: spring-projects/spring-amqp

  1. @Test
  2. public void testBindings() throws Exception {
  3. Map<String, Binding> bindings = beanFactory.getBeansOfType(Binding.class);
  4. // 4 for each exchange type
  5. assertEquals(13, bindings.size());
  6. for (Map.Entry<String, Binding> bindingEntry : bindings.entrySet()) {
  7. Binding binding = bindingEntry.getValue();
  8. if ("headers-test".equals(binding.getExchange()) && "bucket".equals(binding.getDestination())) {
  9. Map<String, Object> arguments = binding.getArguments();
  10. assertEquals(3, arguments.size());
  11. break;
  12. }
  13. }
  14. }

代码示例来源:origin: org.springframework.amqp/spring-rabbit

  1. @Override
  2. @ManagedOperation(description =
  3. "Remove a binding from the broker (this operation is not available remotely)")
  4. public void removeBinding(final Binding binding) {
  5. this.rabbitTemplate.execute(channel -> {
  6. if (binding.isDestinationQueue()) {
  7. if (isRemovingImplicitQueueBinding(binding)) {
  8. return null;
  9. }
  10. channel.queueUnbind(binding.getDestination(), binding.getExchange(), binding.getRoutingKey(),
  11. binding.getArguments());
  12. }
  13. else {
  14. channel.exchangeUnbind(binding.getDestination(), binding.getExchange(), binding.getRoutingKey(),
  15. binding.getArguments());
  16. }
  17. return null;
  18. });
  19. }

代码示例来源:origin: spring-projects/spring-amqp

  1. @Override
  2. @ManagedOperation(description =
  3. "Remove a binding from the broker (this operation is not available remotely)")
  4. public void removeBinding(final Binding binding) {
  5. this.rabbitTemplate.execute(channel -> {
  6. if (binding.isDestinationQueue()) {
  7. if (isRemovingImplicitQueueBinding(binding)) {
  8. return null;
  9. }
  10. channel.queueUnbind(binding.getDestination(), binding.getExchange(), binding.getRoutingKey(),
  11. binding.getArguments());
  12. }
  13. else {
  14. channel.exchangeUnbind(binding.getDestination(), binding.getExchange(), binding.getRoutingKey(),
  15. binding.getArguments());
  16. }
  17. return null;
  18. });
  19. }

代码示例来源:origin: spring-projects/spring-amqp

  1. @Test
  2. public void customBinding() {
  3. class CustomExchange extends AbstractExchange {
  4. CustomExchange(String name) {
  5. super(name);
  6. }
  7. @Override
  8. public String getType() {
  9. return "x-custom";
  10. }
  11. }
  12. Object argumentObject = new Object();
  13. CustomExchange customExchange = new CustomExchange("c");
  14. String routingKey = "r";
  15. Binding binding = BindingBuilder.//
  16. bind(queue).//
  17. to(customExchange).//
  18. with(routingKey).//
  19. and(Collections.<String, Object>singletonMap("k", argumentObject));
  20. assertNotNull(binding);
  21. assertEquals(argumentObject, binding.getArguments().get("k"));
  22. assertEquals(customExchange.getName(), binding.getExchange());
  23. assertEquals(Binding.DestinationType.QUEUE, binding.getDestinationType());
  24. assertEquals(queue.getName(), binding.getDestination());
  25. assertEquals(routingKey, binding.getRoutingKey());
  26. }

代码示例来源:origin: spring-projects/spring-amqp

  1. @Test
  2. public void fanoutBinding() {
  3. FanoutExchange fanoutExchange = new FanoutExchange("f");
  4. Binding binding = BindingBuilder.bind(queue).to(fanoutExchange);
  5. assertNotNull(binding);
  6. assertEquals(fanoutExchange.getName(), binding.getExchange());
  7. assertEquals("", binding.getRoutingKey());
  8. assertEquals(Binding.DestinationType.QUEUE, binding.getDestinationType());
  9. assertEquals(queue.getName(), binding.getDestination());
  10. }

代码示例来源:origin: spring-projects/spring-amqp

  1. @Test
  2. public void directBinding() {
  3. DirectExchange directExchange = new DirectExchange("d");
  4. String routingKey = "r";
  5. Binding binding = BindingBuilder.bind(queue).to(directExchange).with(routingKey);
  6. assertNotNull(binding);
  7. assertEquals(directExchange.getName(), binding.getExchange());
  8. assertEquals(Binding.DestinationType.QUEUE, binding.getDestinationType());
  9. assertEquals(queue.getName(), binding.getDestination());
  10. assertEquals(routingKey, binding.getRoutingKey());
  11. }

代码示例来源:origin: spring-projects/spring-amqp

  1. @Test
  2. public void topicBinding() {
  3. TopicExchange topicExchange = new TopicExchange("t");
  4. String routingKey = "r";
  5. Binding binding = BindingBuilder.bind(queue).to(topicExchange).with(routingKey);
  6. assertNotNull(binding);
  7. assertEquals(topicExchange.getName(), binding.getExchange());
  8. assertEquals(Binding.DestinationType.QUEUE, binding.getDestinationType());
  9. assertEquals(queue.getName(), binding.getDestination());
  10. assertEquals(routingKey, binding.getRoutingKey());
  11. }

代码示例来源:origin: spring-projects/spring-amqp

  1. @Test
  2. public void exchangeBinding() {
  3. DirectExchange directExchange = new DirectExchange("d");
  4. FanoutExchange fanoutExchange = new FanoutExchange("f");
  5. Binding binding = BindingBuilder.bind(directExchange).to(fanoutExchange);
  6. assertNotNull(binding);
  7. assertEquals(fanoutExchange.getName(), binding.getExchange());
  8. assertEquals(Binding.DestinationType.EXCHANGE, binding.getDestinationType());
  9. assertEquals(directExchange.getName(), binding.getDestination());
  10. assertEquals("", binding.getRoutingKey());
  11. }

代码示例来源:origin: spring-projects/spring-amqp

  1. @Test
  2. public void directBindingWithQueueName() {
  3. DirectExchange directExchange = new DirectExchange("d");
  4. Binding binding = BindingBuilder.bind(queue).to(directExchange).withQueueName();
  5. assertNotNull(binding);
  6. assertEquals(directExchange.getName(), binding.getExchange());
  7. assertEquals(Binding.DestinationType.QUEUE, binding.getDestinationType());
  8. assertEquals(queue.getName(), binding.getDestination());
  9. assertEquals(queue.getName(), binding.getRoutingKey());
  10. }

代码示例来源:origin: spring-projects/spring-amqp

  1. @Test
  2. public void headerBinding() {
  3. HeadersExchange headersExchange = new HeadersExchange("h");
  4. String headerKey = "headerKey";
  5. Binding binding = BindingBuilder.bind(queue).to(headersExchange).where(headerKey).exists();
  6. assertNotNull(binding);
  7. assertEquals(headersExchange.getName(), binding.getExchange());
  8. assertEquals(Binding.DestinationType.QUEUE, binding.getDestinationType());
  9. assertEquals(queue.getName(), binding.getDestination());
  10. assertEquals("", binding.getRoutingKey());
  11. }

相关文章