@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 DirectExchange hystrixStreamExchange() { DirectExchange exchange = new DirectExchange(Constants.HYSTRIX_STREAM_NAME); amqpAdmin.declareExchange(exchange); return exchange; }
private void setNotifyExchange() { DirectExchange notifyExchange = new DirectExchange(NOTIFY_EXCHANGE,true,false); amqpAdmin.declareExchange(notifyExchange); this.notifyExchange = notifyExchange; }
private void setDataExchange() { TopicExchange dataExchange = new TopicExchange(DATA_EXCHANGE,true,false); amqpAdmin.declareExchange(dataExchange); this.dataExchange = dataExchange; } }
@Autowired public void defineExchange(AmqpAdmin admin) { admin.declareExchange(eventsExchange()); }
@Bean public Exchange exchange(@Value("${axon.amqp.exchange}") String name) { Exchange exchange = ExchangeBuilder.fanoutExchange(name).build(); admin.declareExchange(exchange); return exchange; }
@Bean public Exchange exchange(@Value("${axon.amqp.exchange}") String name) { Exchange exchange = ExchangeBuilder.fanoutExchange(name).build(); admin.declareExchange(exchange); return exchange; }
@Bean public Exchange exchange(@Value("${axon.amqp.exchange}") String name) { Exchange exchange = ExchangeBuilder.fanoutExchange(name).build(); admin.declareExchange(exchange); return exchange; }
protected org.springframework.amqp.core.Exchange declareExchange() { org.springframework.amqp.core.Exchange exchange = this.endpoint.createAMQPExchange(); if (this.endpoint.isUsingDefaultExchange()) { LOG.info("Using default exchange; will not declare one for endpoint {}.", endpoint); } else { try { this.endpoint.amqpAdministration.declareExchange(exchange); LOG.info("Declared exchange {} for endpoint {}.", exchange.getName(), endpoint); } catch (AmqpIOException e) { LOG.warn(String.format("Could not declare exchange %s for endpoint %s; possible re-declaration of a different type?", exchange.getName(), endpoint.toString()), e); // Be lenient: Do not re-throw Exception because the exchange may already exist but just declared // with different attributes, so let's go ahead and declare the queue and binding anyway. } catch (AmqpConnectException e) { LOG.error(String.format("Consumer cannot connect to broker for endpoint %s", this.endpoint.toString()), e); throw e; } } return exchange; }
protected org.springframework.amqp.core.Exchange declareExchange() { org.springframework.amqp.core.Exchange exchange = this.endpoint.createAMQPExchange(); if (this.endpoint.isUsingDefaultExchange()) { LOG.info("Using default exchange; will not declare one for endpoint {}.", endpoint); } else { try { this.endpoint.amqpAdministration.declareExchange(exchange); LOG.info("Declared exchange {} for endpoint {}.", exchange.getName(), endpoint); } catch (AmqpIOException e) { LOG.warn(String.format("Could not declare exchange %s for endpoint %s; possible re-declaration of a different type?", exchange.getName(), endpoint.toString()), e); // Be lenient: Do not re-throw Exception because the exchange may already exist but just declared // with different attributes, so let's go ahead and declare the queue and binding anyway. } catch (AmqpConnectException e) { LOG.error(String.format("Consumer cannot connect to broker for endpoint %s", this.endpoint.toString()), e); throw e; } } return exchange; }
@Override public void doStart() throws Exception { super.doStart(); this.exchange = this.endpoint.createAMQPExchange(); if (this.endpoint.isUsingDefaultExchange()) { LOG.info("Using default exchange of type {}", this.exchange.getClass().getSimpleName()); } else { LOG.info("Declaring exchange {} of type {}", this.exchange.getName(), this.exchange.getClass().getSimpleName()); try { this.endpoint.amqpAdministration.declareExchange(this.exchange); } catch(AmqpIOException e) { //The actual reason for failed exceptions is often swallowed up by Camel or Spring, find it Throwable rootCause = SpringAMQPComponent.findRootCause(e); LOG.error("Could not initialize exchange!", rootCause); throw e; } catch (AmqpConnectException e) { LOG.error("Producer cannot connect to broker - stopping endpoint {}", this.endpoint.toString(), e); stop(); this.endpoint.stop(); return; } } //Initialize execution pool this.threadPool = this.endpoint.getCamelContext().getExecutorServiceManager().newDefaultThreadPool(this, "amqp-producer"); }
@Override public void doStart() throws Exception { super.doStart(); this.exchange = this.endpoint.createAMQPExchange(); if (this.endpoint.isUsingDefaultExchange()) { LOG.info("Using default exchange of type {}", this.exchange.getClass().getSimpleName()); } else { LOG.info("Declaring exchange {} of type {}", this.exchange.getName(), this.exchange.getClass().getSimpleName()); try { this.endpoint.amqpAdministration.declareExchange(this.exchange); } catch(AmqpIOException e) { //The actual reason for failed exceptions is often swallowed up by Camel or Spring, find it Throwable rootCause = SpringAMQPComponent.findRootCause(e); LOG.error("Could not initialize exchange!", rootCause); throw e; } catch (AmqpConnectException e) { LOG.error("Producer cannot connect to broker - stopping endpoint {}", this.endpoint.toString(), e); stop(); this.endpoint.stop(); return; } } //Initialize execution pool this.threadPool = this.endpoint.getCamelContext().getExecutorServiceManager().newDefaultThreadPool(this, "amqp-producer"); }
@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); } } }
@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()); }