@Before public void setup() { this.defaultConnectionFactory = new CachingConnectionFactory("localhost"); String[] addresses = new String[] { "localhost:9999", "localhost:5672" }; String[] adminUris = new String[] { "http://localhost:15672", "http://localhost:15672" }; String[] nodes = new String[] { "foo@bar", "rabbit@localhost" }; String vhost = "/"; String username = "guest"; String password = "guest"; this.lqcf = new LocalizedQueueConnectionFactory(defaultConnectionFactory, addresses, adminUris, nodes, vhost, username, password, false, null); }
@Test public void test2Queues() throws Exception { try { String rabbit1 = "localhost:1235"; String rabbit2 = "localhost:1236"; String[] addresses = new String[]{rabbit1, rabbit2}; String[] adminUris = new String[]{"http://localhost:11235", "http://localhost:11236"}; String[] nodes = new String[]{"rabbit@foo", "rabbit@bar"}; String vhost = "/"; String username = "guest"; String password = "guest"; LocalizedQueueConnectionFactory lqcf = new LocalizedQueueConnectionFactory(mockCF("localhost:1234", null), addresses, adminUris, nodes, vhost, username, password, false, null); lqcf.getTargetConnectionFactory("[foo, bar]"); } catch (IllegalArgumentException e) { assertThat(e.getMessage(), containsString("Cannot use LocalizedQueueConnectionFactory with more than one queue: [foo, bar]")); } }
@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; } }
@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; } }
mockCFs.put(rabbit1, mockCF(rabbit1, latch1)); mockCFs.put(rabbit2, mockCF(rabbit2, latch2)); LocalizedQueueConnectionFactory lqcf = new LocalizedQueueConnectionFactory(defaultConnectionFactory, addresses, adminUris, nodes, vhost, username, password, false, null) {