예제 #1
0
  /**
   * 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()));
  }
예제 #2
0
 private AMQQueue getNewQueue() throws AMQException {
   return AMQQueueFactory.createAMQQueueImpl(
       new AMQShortString("testQueue" + Math.random()),
       false,
       new AMQShortString("AMQueueAlertTest"),
       false,
       false,
       getVirtualHost(),
       null);
 }