/** * Tests if the Message Size alert gets thrown when message of higher than threshold limit is sent * * @throws Exception */ public void testMessageSizeAlert() throws Exception { setSession(new InternalTestProtocolSession(getVirtualHost())); AMQChannel channel = new AMQChannel(getSession(), 2, getMessageStore()); getSession().addChannel(channel); setQueue( AMQQueueFactory.createAMQQueueImpl( new AMQShortString("testQueue2"), false, new AMQShortString("AMQueueAlertTest"), false, false, getVirtualHost(), null)); _queueMBean = (AMQQueueMBean) getQueue().getManagedObject(); _queueMBean.setMaximumMessageCount(MAX_MESSAGE_COUNT); _queueMBean.setMaximumMessageSize(MAX_MESSAGE_SIZE); sendMessages(channel, 1, MAX_MESSAGE_SIZE * 2); assertTrue(_queueMBean.getMessageCount() == 1); Notification lastNotification = _queueMBean.getLastNotification(); assertNotNull(lastNotification); String notificationMsg = lastNotification.getMessage(); assertTrue(notificationMsg.startsWith(NotificationCheck.MESSAGE_SIZE_ALERT.name())); }
public void testGeneralProperties() throws Exception { long maxQueueDepth = 1000; // in bytes _queueMBean.setMaximumMessageCount(50000l); _queueMBean.setMaximumMessageSize(2000l); _queueMBean.setMaximumQueueDepth(maxQueueDepth); assertEquals( "Max MessageCount not set", 50000, _queueMBean.getMaximumMessageCount().longValue()); assertEquals("Max MessageSize not set", 2000, _queueMBean.getMaximumMessageSize().longValue()); assertEquals( "Max QueueDepth not set", maxQueueDepth, _queueMBean.getMaximumQueueDepth().longValue()); assertEquals("Queue Name does not match", new AMQShortString(getName()), _queueMBean.getName()); assertFalse("AutoDelete should not be set.", _queueMBean.isAutoDelete()); assertFalse("Queue should not be durable.", _queueMBean.isDurable()); // set+get exclusivity using the mbean, and also verify it is actually updated in the queue _queueMBean.setExclusive(true); assertTrue("Exclusive property should be true.", _queueMBean.isExclusive()); assertTrue("Exclusive property should be true.", getQueue().isExclusive()); _queueMBean.setExclusive(false); assertFalse("Exclusive property should be false.", _queueMBean.isExclusive()); assertFalse("Exclusive property should be false.", getQueue().isExclusive()); }