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

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

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

Binding.getArguments介绍

暂无

代码示例

代码示例来源: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: 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: 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. @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: 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. @Test
  2. public void testDirectExchange() throws Exception {
  3. DirectExchange exchange = beanFactory.getBean("direct", DirectExchange.class);
  4. assertNotNull(exchange);
  5. assertEquals("direct", exchange.getName());
  6. assertTrue(exchange.isDurable());
  7. assertFalse(exchange.isAutoDelete());
  8. assertFalse(exchange.shouldDeclare());
  9. assertEquals(2, exchange.getDeclaringAdmins().size());
  10. Binding binding =
  11. beanFactory.getBean("org.springframework.amqp.rabbit.config.BindingFactoryBean#0", Binding.class);
  12. assertFalse(binding.shouldDeclare());
  13. assertEquals(2, binding.getDeclaringAdmins().size());
  14. Map<String, Object> arguments = binding.getArguments();
  15. assertNotNull(arguments);
  16. assertEquals(1, arguments.size());
  17. assertTrue(arguments.containsKey("x-match"));
  18. assertEquals("any", arguments.get("x-match"));
  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. }

相关文章