示例#1
0
  public void testMessageRemains() throws AMQException {

    MessagePublishInfo info =
        new MessagePublishInfo() {

          public AMQShortString getExchange() {
            return null;
          }

          public void setExchange(AMQShortString exchange) {
            // To change body of implemented methods use File | Settings | File Templates.
          }

          public boolean isImmediate() {
            return false;
          }

          public boolean isMandatory() {
            return false;
          }

          public AMQShortString getRoutingKey() {
            return null;
          }
        };

    final ContentHeaderBody chb = createPersistentContentHeader();

    MessageMetaData mmd = new MessageMetaData(info, chb, 0);
    StoredMessage storedMessage = _store.addMessage(mmd);

    AMQMessage message = new AMQMessage(storedMessage);

    MessageReference ref = message.newReference();
    // we call routing complete to set up the handle
    //   message.routingComplete(_store, _storeContext, new MessageHandleFactory());

    assertEquals(1, _store.getMessageCount());
    MessageReference ref2 = message.newReference();
    ref.release();
    assertEquals(1, _store.getMessageCount());
  }
示例#2
0
  /**
   * Check that when the reference count is decremented the message removes itself from the store
   */
  public void testMessageGetsRemoved() throws AMQException {
    ContentHeaderBody chb = createPersistentContentHeader();

    MessagePublishInfo info =
        new MessagePublishInfo() {

          public AMQShortString getExchange() {
            return null;
          }

          public void setExchange(AMQShortString exchange) {
            // To change body of implemented methods use File | Settings | File Templates.
          }

          public boolean isImmediate() {
            return false;
          }

          public boolean isMandatory() {
            return false;
          }

          public AMQShortString getRoutingKey() {
            return null;
          }
        };

    MessageMetaData mmd = new MessageMetaData(info, chb, 0);
    StoredMessage storedMessage = _store.addMessage(mmd);

    AMQMessage message = new AMQMessage(storedMessage);

    MessageReference ref = message.newReference();

    assertEquals(1, _store.getMessageCount());

    ref.release();

    assertEquals(0, _store.getMessageCount());
  }