@Override public void addAddressSettings(final String address, final AddressSettings addressSettings) { server.getAddressSettingsRepository().addMatch(address, addressSettings); }
@Override protected void addConfiguration(ActiveMQServer server) { server.getAddressSettingsRepository().addMatch(INITIAL_QUEUE_NAME, new AddressSettings().setExpiryAddress(FINAL_QUEUE_SS)); }
@Test public void testCreateNonExistentQueue() throws Exception { AddressSettings addressSettings = new AddressSettings(); addressSettings.setAutoCreateQueues(false); getJmsServer().getAddressSettingsRepository().addMatch("#", addressSettings); Connection conn = getConnectionFactory().createConnection(); Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); try { sess.createQueue("QueueThatDoesNotExist"); ProxyAssertSupport.fail(); } catch (JMSException e) { } conn.close(); }
@Test public void testGetExpiryAddress() throws Exception { SimpleString address = RandomUtil.randomSimpleString(); SimpleString queue = RandomUtil.randomSimpleString(); final SimpleString expiryAddress = RandomUtil.randomSimpleString(); session.createQueue(address, RoutingType.MULTICAST, queue, null, durable); QueueControl queueControl = createManagementControl(address, queue); Assert.assertNull(queueControl.getExpiryAddress()); server.getAddressSettingsRepository().addMatch(address.toString(), new AddressSettings() { private static final long serialVersionUID = 6745306517827764680L; @Override public SimpleString getExpiryAddress() { return expiryAddress; } }); Assert.assertEquals(expiryAddress.toString(), queueControl.getExpiryAddress()); session.deleteQueue(queue); }
@Test public void testMemoryLeakOnAddressSettingForTemporaryQueue() throws Exception { for (int i = 0; i < 1000; i++) { SimpleString queue = RandomUtil.randomSimpleString(); SimpleString address = RandomUtil.randomSimpleString(); session.createTemporaryQueue(address, queue); session.close(); session = sf.createSession(); } session.close(); sf.close(); System.out.println("size = " + server.getAddressSettingsRepository().getCacheSize()); assertTrue(server.getAddressSettingsRepository().getCacheSize() < 10); }
@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 testGetDeadLetterAddress() throws Exception { SimpleString address = RandomUtil.randomSimpleString(); SimpleString queue = RandomUtil.randomSimpleString(); final SimpleString deadLetterAddress = RandomUtil.randomSimpleString(); session.createQueue(address, RoutingType.MULTICAST, queue, null, durable); QueueControl queueControl = createManagementControl(address, queue); Assert.assertNull(queueControl.getDeadLetterAddress()); server.getAddressSettingsRepository().addMatch(address.toString(), new AddressSettings() { private static final long serialVersionUID = -4919035864731465338L; @Override public SimpleString getDeadLetterAddress() { return deadLetterAddress; } }); Assert.assertEquals(deadLetterAddress.toString(), queueControl.getDeadLetterAddress()); session.deleteQueue(queue); }
protected void setRedistributionDelay(final long delay) { AddressSettings as = new AddressSettings().setRedistributionDelay(delay); getServer(0).getAddressSettingsRepository().addMatch("queues.*", as); getServer(1).getAddressSettingsRepository().addMatch("queues.*", as); getServer(2).getAddressSettingsRepository().addMatch("queues.*", as); }
private void addSettings() { for (Map.Entry<String, AddressSettings> setting : addressSettings.entrySet()) { server.getAddressSettingsRepository().addMatch(setting.getKey(), setting.getValue()); } }
@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(); }
protected void setRedistributionDelay(final long delay) { AddressSettings as = new AddressSettings().setRedistributionDelay(delay); getServer(0).getAddressSettingsRepository().addMatch("queues.*", as); getServer(1).getAddressSettingsRepository().addMatch("queues.*", as); }
@Override protected void configureAddressPolicy(ActiveMQServer server) { // For BLOCK tests AddressSettings addressSettings = server.getAddressSettingsRepository().getMatch("#"); addressSettings.setAddressFullMessagePolicy(AddressFullMessagePolicy.FAIL); addressSettings.setMaxSizeBytes(1000); // addressSettings.setMaxSizeBytesRejectThreshold(MAX_SIZE_BYTES_REJECT_THRESHOLD); server.getAddressSettingsRepository().addMatch("#", addressSettings); }
@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(); }
protected void setRedistributionDelay(final long delay) { AddressSettings as = new AddressSettings().setRedistributionDelay(delay); getServer(0).getAddressSettingsRepository().addMatch("queues.*", as); getServer(1).getAddressSettingsRepository().addMatch("queues.*", as); }
@Override protected void performRuntime(final OperationContext context, final ModelNode operation, final ModelNode model) throws OperationFailedException { final ActiveMQServer server = getActiveMQServer(context, operation); if(server != null) { final PathAddress address = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR)); final AddressSettings settings = createSettings(context, model); server.getAddressSettingsRepository().addMatch(address.getLastElement().getValue(), settings); } }
@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())); }
protected void setRedistributionDelay(final long delay) { AddressSettings as = new AddressSettings().setRedistributionDelay(delay); getServer(0).getAddressSettingsRepository().addMatch("queues.*", as); getServer(1).getAddressSettingsRepository().addMatch("queues.*", as); }
@Override protected void performRuntime(final OperationContext context, final ModelNode operation, final ModelNode model) throws OperationFailedException { final ActiveMQServer server = getActiveMQServer(context, operation); if(server != null) { final PathAddress address = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR)); final AddressSettings settings = createSettings(context, model); server.getAddressSettingsRepository().addMatch(address.getLastElement().getValue(), settings); } }
@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(); } }
@Override protected void addConfiguration(ActiveMQServer server) { server.getConfiguration().setPersistenceEnabled(false); server.getAddressSettingsRepository().addMatch(NORMAL_QUEUE_NAME, new AddressSettings()); }