@Bean(ZipkinAutoConfiguration.SENDER_BEAN_NAME) Sender rabbitSender(CachingConnectionFactory connectionFactory, RabbitProperties config) { return RabbitMQSender.newBuilder() .connectionFactory(connectionFactory.getRabbitConnectionFactory()) .queue(this.queue).addresses(config.determineAddresses()).build(); }
@Override public void onInit() throws Exception { super.onInit(); if (this.clustered) { String[] addresses = StringUtils.commaDelimitedListToStringArray(this.rabbitProperties.getAddresses()); Assert.state(addresses.length == this.adminAddresses.length && addresses.length == this.nodes.length, "'addresses', 'adminAddresses', and 'nodes' properties must have equal length"); this.connectionFactory = new LocalizedQueueConnectionFactory(this.connectionFactory, addresses, this.adminAddresses, this.nodes, this.rabbitProperties.getVirtualHost(), this.rabbitProperties.getUsername(), this.rabbitProperties.getPassword(), this.rabbitProperties.getSsl().isEnabled(), this.rabbitProperties.getSsl().getKeyStore(), this.rabbitProperties.getSsl().getTrustStore(), this.rabbitProperties.getSsl().getKeyStorePassword(), this.rabbitProperties.getSsl().getTrustStorePassword()); this.destroyConnectionFactory = true; } }
static void configureCachingConnectionFactory(CachingConnectionFactory connectionFactory, ConfigurableApplicationContext applicationContext, RabbitProperties rabbitProperties) throws Exception { if (StringUtils.hasText(rabbitProperties.getAddresses())) { connectionFactory.setAddresses(rabbitProperties.determineAddresses()); } connectionFactory.setPublisherConfirms(rabbitProperties.isPublisherConfirms()); connectionFactory.setPublisherReturns(rabbitProperties.isPublisherReturns()); if (rabbitProperties.getCache().getChannel().getSize() != null) { connectionFactory.setChannelCacheSize(rabbitProperties.getCache().getChannel().getSize()); } if (rabbitProperties.getCache().getConnection().getMode() != null) { connectionFactory.setCacheMode(rabbitProperties.getCache().getConnection().getMode()); } if (rabbitProperties.getCache().getConnection().getSize() != null) { connectionFactory.setConnectionCacheSize( rabbitProperties.getCache().getConnection().getSize()); } if (rabbitProperties.getCache().getChannel().getCheckoutTimeout() != null) { connectionFactory.setChannelCheckoutTimeout( rabbitProperties.getCache().getChannel().getCheckoutTimeout().toMillis()); } connectionFactory.setApplicationContext(applicationContext); applicationContext.addApplicationListener(connectionFactory); connectionFactory.afterPropertiesSet(); }
public RabbitMqSetupService(final RabbitProperties properties) { hostname = properties.getHost(); username = properties.getUsername(); if (StringUtils.isEmpty(username)) { username = DEFAULT_USER; } password = properties.getPassword(); if (StringUtils.isEmpty(password)) { password = DEFAULT_PASSWORD; } }
@Bean Client rabbitManagementTemplate () throws Exception { String username = rabbitProperties.determineUsername(); String password = rabbitProperties.determinePassword(); String host = rabbitProperties.determineHost(); String url = String.format("http://%s:%s@%s:15672/api/",username!=null?username:DEFAULT_USER,username!=null?password:DEFAULT_PASS,host!=null?host:DEFAULT_HOST); return new Client(url); }
@Override public void onInit() throws Exception { super.onInit(); if (this.clustered) { String[] addresses = StringUtils.commaDelimitedListToStringArray(this.rabbitProperties.getAddresses()); Assert.state(addresses.length == this.adminAddresses.length && addresses.length == this.nodes.length, "'addresses', 'adminAddresses', and 'nodes' properties must have equal length"); this.connectionFactory = new LocalizedQueueConnectionFactory(this.connectionFactory, addresses, this.adminAddresses, this.nodes, this.rabbitProperties.getVirtualHost(), this.rabbitProperties.getUsername(), this.rabbitProperties.getPassword(), this.rabbitProperties.getSsl().isEnabled(), this.rabbitProperties.getSsl().getKeyStore(), this.rabbitProperties.getSsl().getTrustStore(), this.rabbitProperties.getSsl().getKeyStorePassword(), this.rabbitProperties.getSsl().getTrustStorePassword()); this.destroyConnectionFactory = true; } }
static void configureCachingConnectionFactory(CachingConnectionFactory connectionFactory, ConfigurableApplicationContext applicationContext, RabbitProperties rabbitProperties) throws Exception { if (StringUtils.hasText(rabbitProperties.getAddresses())) { connectionFactory.setAddresses(rabbitProperties.determineAddresses()); } connectionFactory.setPublisherConfirms(rabbitProperties.isPublisherConfirms()); connectionFactory.setPublisherReturns(rabbitProperties.isPublisherReturns()); if (rabbitProperties.getCache().getChannel().getSize() != null) { connectionFactory.setChannelCacheSize(rabbitProperties.getCache().getChannel().getSize()); } if (rabbitProperties.getCache().getConnection().getMode() != null) { connectionFactory.setCacheMode(rabbitProperties.getCache().getConnection().getMode()); } if (rabbitProperties.getCache().getConnection().getSize() != null) { connectionFactory.setConnectionCacheSize( rabbitProperties.getCache().getConnection().getSize()); } if (rabbitProperties.getCache().getChannel().getCheckoutTimeout() != null) { connectionFactory.setChannelCheckoutTimeout( rabbitProperties.getCache().getChannel().getCheckoutTimeout().toMillis()); } connectionFactory.setApplicationContext(applicationContext); applicationContext.addApplicationListener(connectionFactory); connectionFactory.afterPropertiesSet(); }
public RabbitMqSetupService(RabbitProperties properties) { hostname = properties.getHost(); username = properties.getUsername(); if (StringUtils.isEmpty(username)) { username = DEFAULT_USER; } password = properties.getPassword(); if (StringUtils.isEmpty(password)) { password = DEFAULT_PASSWORD; } }
@Bean Sender rabbitSender(CachingConnectionFactory connectionFactory, RabbitProperties config) { return RabbitMQSender.newBuilder() .connectionFactory(connectionFactory.getRabbitConnectionFactory()) .queue(this.queue) .addresses(config.determineAddresses()) .build(); } }
@Bean(ZipkinAutoConfiguration.SENDER_BEAN_NAME) Sender rabbitSender(CachingConnectionFactory connectionFactory, RabbitProperties config) { return RabbitMQSender.newBuilder() .connectionFactory(connectionFactory.getRabbitConnectionFactory()) .queue(this.queue).addresses(config.determineAddresses()).build(); }