Ejemplo n.º 1
0
  public final boolean hasInterest(QueueEntry entry) {
    // check that the message hasn't been rejected
    if (entry.isRejectedBy(this)) {

      return false;
    }

    if (entry.getMessage().getClass() == _messageClass) {
      if (_noLocal) {
        Object connectionRef = entry.getMessage().getConnectionReference();
        if (connectionRef != null && connectionRef == _sessionReference) {
          return false;
        }
      }
    } else {
      // no interest in messages we can't convert
      if (_messageClass != null
          && MessageConverterRegistry.getConverter(entry.getMessage().getClass(), _messageClass)
              == null) {
        return false;
      }
    }

    if (_filters == null) {
      return true;
    } else {
      MessageReference ref = entry.newMessageReference();
      if (ref != null) {
        try {

          Filterable msg = entry.asFilterable();
          try {
            return _filters.allAllow(msg);
          } catch (SelectorParsingException e) {
            LOGGER.info(
                this
                    + " could not evaluate filter ["
                    + _filters
                    + "]  against message "
                    + msg
                    + ". Error was : "
                    + e.getMessage());
            return false;
          }
        } finally {
          ref.release();
        }
      } else {
        return false;
      }
    }
  }
Ejemplo n.º 2
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());
  }
Ejemplo n.º 3
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());
  }