@PostConstruct public void init() { DirectExchange exchange = new DirectExchange(PAY_NOTIFY_EXCHANGE_NAME); exchange.setDelayed(true); Queue queue = new Queue(PAY_NOTIFY_QUEUE_NAME); Binding binding = BindingBuilder.bind(queue).to(exchange).withQueueName(); amqpAdmin.declareExchange(exchange); amqpAdmin.declareQueue(queue); amqpAdmin.declareBinding(binding); }
@Override protected void doDeclares() { AmqpAdmin admin = getAdmin(); if (admin != null) { if (admin.getQueueProperties(this.queue.getName()) == null) { admin.declareQueue(this.queue); } if (this.exchange != null) { admin.declareExchange(this.exchange); } if (this.binding != null) { admin.declareBinding(this.binding); } } }
@Bean public Queue hystrixStreamQueue() { Map<String, Object> args = new HashMap<>(); args.put("x-message-ttl", 60000); //TODO: configure TTL Queue queue = new Queue(Constants.HYSTRIX_STREAM_NAME, false, false, false, args); amqpAdmin.declareQueue(queue); amqpAdmin.declareBinding(BindingBuilder.bind(queue).to(hystrixStreamExchange()).with("")); return queue; }
@Bean public Binding binding(Exchange exchange, Queue queue) { Binding binding = BindingBuilder.bind(queue).to(exchange).with("*").noargs(); admin.declareBinding(binding); return binding; }
@Bean public Binding binding(Exchange exchange, Queue queue) { Binding binding = BindingBuilder.bind(queue).to(exchange).with("*").noargs(); admin.declareBinding(binding); return binding; } }
@Bean public Binding binding(Exchange exchange, Queue queue) { Binding binding = BindingBuilder.bind(queue).to(exchange).with("*").noargs(); admin.declareBinding(binding); return binding; }
/** * {@inheritDoc} */ @Override public void add(CapabilityData capabilityData) throws CapabilityRegistryException { ProviderEndpoint providerEndpoint = capabilityData.getCapability().getProviderEndpoint(); Binding binding = createBinding(providerEndpoint); amqpAdmin.declareBinding(binding); }
@Override protected void doDeclares() { AmqpAdmin admin = getAdmin(); if (admin != null) { if (admin.getQueueProperties(this.queue.getName()) == null) { admin.declareQueue(this.queue); } if (this.exchange != null) { admin.declareExchange(this.exchange); } if (this.binding != null) { admin.declareBinding(this.binding); } } }
private void sendNoftify(String queueName, Object msg) { Queue queue = new Queue(queueName, true, false, true); amqpAdmin.declareQueue(queue); Binding binding = BindingBuilder.bind(queue).to(notifyExchange).withQueueName(); amqpAdmin.declareBinding(binding); amqpTemplate.convertAndSend(notifyExchange.getName(),queueName, msg); }
protected Binding declareBinding(org.springframework.amqp.core.Exchange exchange, Queue queue) { Binding binding = null; //Is this a header exchange? Bind the key/value pair(s) if(exchange instanceof HeadersExchange) { if(this.endpoint.routingKey == null) throw new IllegalStateException("Specified a header exchange without a key/value match"); if(this.endpoint.routingKey.contains("|") && this.endpoint.routingKey.contains("&")) throw new IllegalArgumentException("You cannot mix AND and OR expressions within a header binding"); Map<String, Object> keyValues = parseKeyValues(this.endpoint.routingKey); BindingBuilder.HeadersExchangeMapConfigurer mapConfig = BindingBuilder.bind(queue).to((HeadersExchange) exchange); if(this.endpoint.routingKey.contains("|")) binding = mapConfig.whereAny(keyValues).match(); else binding = mapConfig.whereAll(keyValues).match(); //Is this a fanout exchange? Just bind the queue and exchange directly } else if(exchange instanceof FanoutExchange) { binding = BindingBuilder.bind(queue).to((FanoutExchange) exchange); //Perform routing key binding for direct or topic exchanges } else { binding = BindingBuilder.bind(queue).to(exchange).with(this.endpoint.routingKey).noargs(); } if (this.endpoint.isUsingDefaultExchange()) { LOG.info("Using default exchange for endpoint {}. Default exchange is implicitly bound to every queue, with a routing key equal to the queue name.", endpoint); } else if (binding != null) { LOG.info("Declaring binding {} for endpoint {}.", binding.getRoutingKey(), endpoint); this.endpoint.getAmqpAdministration().declareBinding(binding); } return binding; } }
protected Binding declareBinding(org.springframework.amqp.core.Exchange exchange, Queue queue) { Binding binding = null; //Is this a header exchange? Bind the key/value pair(s) if(exchange instanceof HeadersExchange) { if(this.endpoint.routingKey == null) throw new IllegalStateException("Specified a header exchange without a key/value match"); if(this.endpoint.routingKey.contains("|") && this.endpoint.routingKey.contains("&")) throw new IllegalArgumentException("You cannot mix AND and OR expressions within a header binding"); Map<String, Object> keyValues = parseKeyValues(this.endpoint.routingKey); BindingBuilder.HeadersExchangeMapConfigurer mapConfig = BindingBuilder.bind(queue).to((HeadersExchange) exchange); if(this.endpoint.routingKey.contains("|")) binding = mapConfig.whereAny(keyValues).match(); else binding = mapConfig.whereAll(keyValues).match(); //Is this a fanout exchange? Just bind the queue and exchange directly } else if(exchange instanceof FanoutExchange) { binding = BindingBuilder.bind(queue).to((FanoutExchange) exchange); //Perform routing key binding for direct or topic exchanges } else { binding = BindingBuilder.bind(queue).to(exchange).with(this.endpoint.routingKey).noargs(); } if (this.endpoint.isUsingDefaultExchange()) { LOG.info("Using default exchange for endpoint {}. Default exchange is implicitly bound to every queue, with a routing key equal to the queue name.", endpoint); } else if (binding != null) { LOG.info("Declaring binding {} for endpoint {}.", binding.getRoutingKey(), endpoint); this.endpoint.getAmqpAdministration().declareBinding(binding); } return binding; } }
@Autowired public void defineExchange(AmqpAdmin admin) { Queue tradesQueue = QueueBuilder.durable("trades").build(); Exchange tradingExchange = ExchangeBuilder.topicExchange("trading-engine-events").build(); admin.declareExchange(tradingExchange); admin.declareQueue(tradesQueue); admin.declareBinding(BindingBuilder.bind(tradesQueue) .to(tradingExchange) .with("#") .noargs()); }
private void sendData(String queueName, Object msg) { Queue queue = new Queue(queueName, true, false, true); amqpAdmin.declareQueue(queue); Binding binding = BindingBuilder.bind(queue).to(dataExchange).with(queueName); amqpAdmin.declareBinding(binding); amqpTemplate.convertAndSend(dataExchange.getName(),queueName, msg); }