@Override protected void extraServerConfig(Configuration serverConfig) { String match = "#"; Map<String, AddressSettings> asMap = serverConfig.getAddressesSettings(); asMap.get(match).setAutoCreateAddresses(true).setAutoCreateQueues(true); }
protected void configureAddressSettings(Map<String, AddressSettings> addressSettingsMap) { addressSettingsMap.put("#", new AddressSettings().setAutoCreateQueues(false).setAutoCreateAddresses(false).setDeadLetterAddress(new SimpleString("ActiveMQ.DLQ")).setAutoCreateAddresses(true)); }
@Test public void testAutoDestinationCreationOnProducerSend() throws JMSException { AddressSettings addressSetting = new AddressSettings(); addressSetting.setAutoCreateQueues(true); addressSetting.setAutoCreateAddresses(true); String address = "foo"; server.getAddressSettingsRepository().addMatch(address, addressSetting); connection.start(); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); TextMessage message = session.createTextMessage("bar"); Queue queue = new ActiveMQQueue(address); MessageProducer producer = session.createProducer(null); producer.send(queue, message); MessageConsumer consumer = session.createConsumer(queue); TextMessage message1 = (TextMessage) consumer.receive(1000); assertTrue(message1.getText().equals(message.getText())); }
@Test public void testCreateQueueWhileTopicWithSameNameExists() throws Exception { AddressSettings addressSettings = new AddressSettings(); addressSettings.setAutoCreateQueues(false); addressSettings.setAutoCreateAddresses(false); getJmsServer().getAddressSettingsRepository().addMatch("#", addressSettings); Connection conn = getConnectionFactory().createConnection(); Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); try { sess.createQueue("TestTopic"); ProxyAssertSupport.fail("should throw JMSException"); } catch (JMSException e) { // OK } conn.close(); }
@Override protected void configureAddressSettings(Map<String, AddressSettings> addressSettingsMap) { addressSettingsMap.put("#", new AddressSettings().setAutoCreateQueues(false).setAutoCreateAddresses(false).setDeadLetterAddress(new SimpleString("ActiveMQ.DLQ")).setAutoCreateAddresses(true)); addressSettingsMap.put(lmDropAddress.toString(), new AddressSettings() .setMaxSizeBytes(15 * 1024 * 1024) .setAddressFullMessagePolicy(AddressFullMessagePolicy.DROP) .setMessageCounterHistoryDayLimit(10) .setRedeliveryDelay(0) .setMaxDeliveryAttempts(0)); }
@Override protected void configureAddressSettings(Map<String, AddressSettings> addressSettingsMap) { addressSettingsMap.put("#", new AddressSettings().setAutoCreateQueues(false).setAutoCreateAddresses(false). setDeadLetterAddress(new SimpleString("ActiveMQ.DLQ")).setAddressFullMessagePolicy(AddressFullMessagePolicy.FAIL).setMaxSizeBytes(10000)); }
@Test public void testCreateNonExistentTopic() throws Exception { getJmsServer().getAddressSettingsRepository().addMatch("#", new AddressSettings().setAutoCreateQueues(false)); getJmsServer().getAddressSettingsRepository().addMatch("#", new AddressSettings().setAutoCreateAddresses(false)); Connection conn = getConnectionFactory().createConnection(); Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); try { sess.createTopic("TopicThatDoesNotExist"); ProxyAssertSupport.fail("should throw JMSException"); } catch (JMSException e) { // OK } conn.close(); }
@Test public void testCreateTopicWhileQueueWithSameNameExists() throws Exception { getJmsServer().getAddressSettingsRepository().addMatch("#", new AddressSettings().setAutoCreateQueues(false)); getJmsServer().getAddressSettingsRepository().addMatch("#", new AddressSettings().setAutoCreateAddresses(false)); Connection conn = getConnectionFactory().createConnection(); Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); try { sess.createTopic("TestQueue"); ProxyAssertSupport.fail("should throw JMSException"); } catch (JMSException e) { // OK } conn.close(); }
@Test public void testCreateProducerOnInexistentDestination() throws Exception { getJmsServer().getAddressSettingsRepository().addMatch("#", new AddressSettings().setAutoCreateQueues(false)); getJmsServer().getAddressSettingsRepository().addMatch("#", new AddressSettings().setAutoCreateAddresses(false)); Connection pconn = createConnection(); try { Session ps = pconn.createSession(false, Session.AUTO_ACKNOWLEDGE); try { ps.createProducer(ActiveMQJMSClient.createTopic("NoSuchTopic")); ProxyAssertSupport.fail("should throw exception"); } catch (InvalidDestinationException e) { // OK } } finally { pconn.close(); } }
@Test public void testAddressDoesNotExist() throws Exception { ClientSession sendSession = cf.createSession(false, true, true); server.getAddressSettingsRepository().addMatch(addressA.toString(), new AddressSettings().setAutoCreateAddresses(false)); Set<RoutingType> routingTypes = new HashSet<>(); routingTypes.add(RoutingType.ANYCAST); try { sendSession.createQueue(addressA, RoutingType.MULTICAST, queueA); fail("Creating a queue here should fail since the queue's address doesn't exist and auto-create-addresses = false."); } catch (Exception e) { assertTrue(e instanceof ActiveMQException); ActiveMQException ae = (ActiveMQException) e; assertEquals(ActiveMQExceptionType.ADDRESS_DOES_NOT_EXIST, ae.getType()); } sendSession.close(); } }
protected void configureAddressPolicy(ActiveMQServer server) { // Address configuration AddressSettings addressSettings = new AddressSettings(); addressSettings.setAddressFullMessagePolicy(AddressFullMessagePolicy.PAGE); addressSettings.setAutoCreateQueues(isAutoCreateQueues()); addressSettings.setAutoCreateAddresses(isAutoCreateAddresses()); addressSettings.setDeadLetterAddress(SimpleString.toSimpleString(getDeadLetterAddress())); addressSettings.setExpiryAddress(SimpleString.toSimpleString(getDeadLetterAddress())); server.getConfiguration().getAddressesSettings().put("#", addressSettings); Set<TransportConfiguration> acceptors = server.getConfiguration().getAcceptorConfigurations(); for (TransportConfiguration tc : acceptors) { if (tc.getName().equals("netty-acceptor")) { tc.getExtraParams().put("anycastPrefix", "anycast://"); tc.getExtraParams().put("multicastPrefix", "multicast://"); } } }
@Test public void testMulticastOperationsOnAnycastAddress() throws Exception { server.getAddressSettingsRepository().addMatch("#", new AddressSettings().setAutoCreateAddresses(false).setAutoCreateQueues(false)); testRoutingSemantics(RoutingType.MULTICAST.toString(), getQueuePrefix() + getQueueName()); }
@Test public void testAnycastOperationsOnMulticastAddress() throws Exception { server.getAddressSettingsRepository().addMatch("#", new AddressSettings().setAutoCreateAddresses(false).setAutoCreateQueues(false)); testRoutingSemantics(RoutingType.ANYCAST.toString(), getTopicPrefix() + getTopicName()); }
@Override @Before public void setUp() throws Exception { super.setUp(); server = createServer(true, true); Configuration serverConfig = server.getConfiguration(); serverConfig.getAddressesSettings().put("#", new AddressSettings().setAutoCreateQueues(true).setAutoCreateAddresses(true).setDeadLetterAddress(new SimpleString("ActiveMQ.DLQ"))); serverConfig.setSecurityEnabled(false); server.start(); coreQueue = new SimpleString(queueName); server.createQueue(coreQueue, RoutingType.ANYCAST, coreQueue, null, false, false); qpidfactory = new JmsConnectionFactory("amqp://localhost:61616"); }
public void configureBroker() throws Exception { // TODO Add SSL super.setUp(); server = createServerForMQTT(); addCoreConnector(); addMQTTConnector(); AddressSettings addressSettings = new AddressSettings(); addressSettings.setMaxSizeBytes(999999999); addressSettings.setAutoCreateQueues(true); addressSettings.setAutoCreateAddresses(true); configureBrokerSecurity(server); server.getAddressSettingsRepository().addMatch("#", addressSettings); }
@Override @Before public void setUp() throws Exception { super.setUp(); server = createServer(true, true); server.start(); server.waitForActivation(10, TimeUnit.SECONDS); Configuration serverConfig = server.getConfiguration(); serverConfig.getAddressesSettings().put("#", new AddressSettings().setAutoCreateQueues(false) .setAutoCreateAddresses(false) .setDeadLetterAddress(new SimpleString("ActiveMQ.DLQ"))); serverConfig.setSecurityEnabled(false); coreQueue = new SimpleString(queueName); server.createQueue(coreQueue, RoutingType.ANYCAST, coreQueue, null, false, false); }
@Override @Before public void setUp() throws Exception { super.setUp(); server = createServer(true, true); server.start(); server.waitForActivation(10, TimeUnit.SECONDS); Configuration serverConfig = server.getConfiguration(); serverConfig.getAddressesSettings().put("#", new AddressSettings().setAutoCreateQueues(false) .setAutoCreateAddresses(false) .setDeadLetterAddress(new SimpleString("ActiveMQ.DLQ"))); serverConfig.setSecurityEnabled(false); coreQueue = new SimpleString(queueName); server.createQueue(coreQueue, RoutingType.ANYCAST, coreQueue, null, false, false); }
@Override @Before public void setUp() throws Exception { super.setUp(); server = createServer(true, true); server.start(); server.waitForActivation(10, TimeUnit.SECONDS); Configuration serverConfig = server.getConfiguration(); serverConfig.getAddressesSettings().put("#", new AddressSettings().setAutoCreateQueues(false).setAutoCreateAddresses(false).setDeadLetterAddress(new SimpleString("ActiveMQ.DLQ"))); serverConfig.setSecurityEnabled(false); coreQueue = new SimpleString(queueName); server.createQueue(coreQueue, RoutingType.ANYCAST, coreQueue, null, false, false); qpidfactory = new JmsConnectionFactory("amqp://localhost:61616"); }
@Test public void testAddressQueryNonDefaultsOnStaticAddress() throws Exception { SimpleString addressName = SimpleString.toSimpleString(UUID.randomUUID().toString()); server.getAddressSettingsRepository().addMatch(addressName.toString(), new AddressSettings().setAutoCreateAddresses(false).setDefaultMaxConsumers(1).setDefaultPurgeOnNoConsumers(true)); server.addAddressInfo(new AddressInfo(addressName).addRoutingType(RoutingType.ANYCAST)); AddressQueryResult addressQueryResult = server.addressQuery(addressName); assertTrue(addressQueryResult.isExists()); assertTrue(addressQueryResult.getRoutingTypes().contains(RoutingType.ANYCAST)); assertFalse(addressQueryResult.getRoutingTypes().contains(RoutingType.MULTICAST)); assertEquals(addressName, addressQueryResult.getName()); assertFalse(addressQueryResult.isAutoCreateAddresses()); assertEquals(1, addressQueryResult.getDefaultMaxConsumers()); assertFalse(addressQueryResult.isAutoCreated()); assertTrue(addressQueryResult.isDefaultPurgeOnNoConsumers()); }
@Test(timeout = 60000) public void testConsumeWhenNoAddressCreatedNoAutoCreate() throws Exception { AddressSettings settings = new AddressSettings(); settings.setAutoCreateAddresses(false); server.getAddressSettingsRepository().addMatch(address.toString(), settings); AmqpClient client = createAmqpClient(); AmqpConnection connection = addConnection(client.connect()); AmqpSession session = connection.createSession(); try { session.createReceiver(address.toString()); fail("should throw exception"); } catch (Exception e) { //ignore } connection.close(); }