org.apache.activemq.broker.Broker.isExpired()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(7.3k)|赞(0)|评价(0)|浏览(159)

本文整理了Java中org.apache.activemq.broker.Broker.isExpired()方法的一些代码示例,展示了Broker.isExpired()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Broker.isExpired()方法的具体详情如下:
包路径:org.apache.activemq.broker.Broker
类名称:Broker
方法名:isExpired

Broker.isExpired介绍

[英]Determine if a message has expired -allows default behaviour to be overriden - as the timestamp set by the producer can be out of sync with the broker
[中]确定消息是否已过期-允许覆盖默认行为-因为生产者设置的时间戳可能与代理不同步

代码示例

代码示例来源:origin: apache/activemq

@Override
public boolean isExpired(MessageReference messageReference) {
  return getNext().isExpired(messageReference);
}

代码示例来源:origin: apache/activemq

protected void doBrowseList(List<Message> browseList, int max, PendingList list, ReentrantReadWriteLock lock, ConnectionContext connectionContext, String name) throws Exception {
  List<MessageReference> toExpire = new ArrayList<MessageReference>();
  lock.readLock().lock();
  try {
    addAll(list.values(), browseList, max, toExpire);
  } finally {
    lock.readLock().unlock();
  }
  for (MessageReference ref : toExpire) {
    if (broker.isExpired(ref)) {
      LOG.debug("expiring from {}: {}", name, ref);
      messageExpired(connectionContext, ref);
    } else {
      lock.writeLock().lock();
      try {
        list.remove(ref);
      } finally {
        lock.writeLock().unlock();
      }
      ref.decrementReferenceCount();
    }
  }
}

代码示例来源:origin: apache/activemq

@Override
public boolean recoverMessage(Message message) {
  recoveredAccumulator++;
  if ((recoveredAccumulator % 10000) == 0) {
    LOG.info("cursor for {} has recovered {} messages. {}% complete", new Object[]{ getActiveMQDestination().getQualifiedName(), recoveredAccumulator, new Integer((int) (recoveredAccumulator * 100 / totalMessageCount))});
  }
  // Message could have expired while it was being
  // loaded..
  message.setRegionDestination(Queue.this);
  if (message.isExpired() && broker.isExpired(message)) {
    toExpire.add(message);
    return true;
  }
  if (hasSpace()) {
    messagesLock.writeLock().lock();
    try {
      try {
        messages.addMessageLast(message);
      } catch (Exception e) {
        LOG.error("Failed to add message to cursor", e);
      }
    } finally {
      messagesLock.writeLock().unlock();
    }
    destinationStatistics.getMessages().increment();
    return true;
  }
  return false;
}

代码示例来源:origin: apache/activemq

private void discardExpiredMessage(MessageReference reference) {
  LOG.debug("Discarding expired message {}", reference);
  if (reference.isExpired() && broker.isExpired(reference)) {
    ConnectionContext context = new ConnectionContext();
    context.setBroker(broker);
    ((Destination)reference.getRegionDestination()).messageExpired(context, null, new IndirectMessageReference(reference.getMessage()));
  }
}

代码示例来源:origin: apache/activemq

@Override
public void afterCommit() throws Exception {
  // It could take while before we receive the commit
  // operation.. by that time the message could have
  // expired..
  if (message.isExpired()) {
    if (broker.isExpired(message)) {
      getDestinationStatistics().getExpired().increment();
      broker.messageExpired(context, message, null);
    }
    message.decrementReferenceCount();
    return;
  }
  try {
    dispatch(context, message);
  } finally {
    message.decrementReferenceCount();
  }
}

代码示例来源:origin: apache/activemq

if (broker.isExpired(ref)) {
  messageExpired(createConnectionContext(), ref);
} else {

代码示例来源:origin: apache/activemq

/**
 * Discard any expired messages from the matched list. Called from a
 * synchronized block.
 *
 * @throws IOException
 */
protected void removeExpiredMessages() throws IOException {
  try {
    matched.reset();
    while (matched.hasNext()) {
      MessageReference node = matched.next();
      node.decrementReferenceCount();
      if (node.isExpired()) {
        matched.remove();
        node.decrementReferenceCount();
        if (broker.isExpired(node)) {
          ((Destination) node.getRegionDestination()).getDestinationStatistics().getExpired().increment();
          broker.messageExpired(getContext(), node, this);
        }
        break;
      }
    }
  } finally {
    matched.release();
  }
}

代码示例来源:origin: apache/activemq

if (broker.isExpired(node)) {
  regionDestination.messageExpired(context, this, node);

代码示例来源:origin: apache/activemq

if (broker.isExpired(node)) {
  ((Destination)node.getRegionDestination()).messageExpired(context, this, node);

代码示例来源:origin: pierre/meteo

public boolean isExpired(MessageReference messageReference) {
  return next.isExpired(messageReference);
}

代码示例来源:origin: org.apache.activemq/activemq-broker

@Override
public boolean isExpired(MessageReference messageReference) {
  return getNext().isExpired(messageReference);
}

代码示例来源:origin: org.apache.activemq/activemq-all

@Override
public boolean isExpired(MessageReference messageReference) {
  return getNext().isExpired(messageReference);
}

代码示例来源:origin: org.apache.activemq/activemq-osgi

@Override
public boolean isExpired(MessageReference messageReference) {
  return getNext().isExpired(messageReference);
}

代码示例来源:origin: pierre/meteo

public boolean isExpired(MessageReference messageReference) {
  return getNext().isExpired(messageReference);
}

代码示例来源:origin: pierre/meteo

/**
 * In the queue case, mark the node as dropped and then a gc cycle will
 * remove it from the queue.
 * 
 * @throws IOException
 */
protected void acknowledge(final ConnectionContext context, final MessageAck ack, final MessageReference n) throws IOException {
  final Destination q = n.getRegionDestination();
  final QueueMessageReference node = (QueueMessageReference)n;
  final Queue queue = (Queue)q;
  
  if (n.isExpired()) {
    // sync with message expiry processing
    if (!broker.isExpired(n)) {
      LOG.warn("ignoring ack " + ack + ", for already expired message: " + n);
      return;
    }
  }
  queue.removeMessage(context, this, node, ack);
}

代码示例来源:origin: org.apache.activemq/activemq-broker

private void discardExpiredMessage(MessageReference reference) {
  LOG.debug("Discarding expired message {}", reference);
  if (reference.isExpired() && broker.isExpired(reference)) {
    ConnectionContext context = new ConnectionContext();
    context.setBroker(broker);
    ((Destination)reference.getRegionDestination()).messageExpired(context, null, new IndirectMessageReference(reference.getMessage()));
  }
}

代码示例来源:origin: org.apache.activemq/activemq-all

private void discardExpiredMessage(MessageReference reference) {
  LOG.debug("Discarding expired message {}", reference);
  if (reference.isExpired() && broker.isExpired(reference)) {
    ConnectionContext context = new ConnectionContext();
    context.setBroker(broker);
    ((Destination)reference.getRegionDestination()).messageExpired(context, null, new IndirectMessageReference(reference.getMessage()));
  }
}

代码示例来源:origin: org.apache.activemq/activemq-osgi

private void discardExpiredMessage(MessageReference reference) {
  LOG.debug("Discarding expired message {}", reference);
  if (reference.isExpired() && broker.isExpired(reference)) {
    ConnectionContext context = new ConnectionContext();
    context.setBroker(broker);
    ((Destination)reference.getRegionDestination()).messageExpired(context, null, new IndirectMessageReference(reference.getMessage()));
  }
}

代码示例来源:origin: pierre/meteo

@Override
  public void afterCommit() throws Exception {
    // It could take while before we receive the commit
    // operration.. by that time the message could have
    // expired..
    if (broker.isExpired(message)) {
      getDestinationStatistics().getExpired().increment();
      broker.messageExpired(context, message, null);
      message.decrementReferenceCount();
      return;
    }
    try {
      dispatch(context, message);
    } finally {
      message.decrementReferenceCount();
    }
  }
});

代码示例来源:origin: org.apache.activemq/activemq-broker

@Override
public void afterCommit() throws Exception {
  // It could take while before we receive the commit
  // operation.. by that time the message could have
  // expired..
  if (message.isExpired()) {
    if (broker.isExpired(message)) {
      getDestinationStatistics().getExpired().increment();
      broker.messageExpired(context, message, null);
    }
    message.decrementReferenceCount();
    return;
  }
  try {
    dispatch(context, message);
  } finally {
    message.decrementReferenceCount();
  }
}

相关文章

微信公众号

最新文章

更多

Broker类方法