Esempio n. 1
0
  @Override
  public boolean offerResult(MessageAmp message) {
    if (_lifecycle.isAfterStopping()) {
      message.fail(
          new ServiceExceptionClosed(
              L.l("closed {0} for message {1} and inbox {2}", serviceRef(), message, this)));

      return true;
    }

    QueueDeliver<MessageAmp> queue = _queue;

    boolean value = queue.offer(message, 0, TimeUnit.MILLISECONDS);
    // boolean value = queue.offer(message, 10, TimeUnit.MILLISECONDS, 0);

    // XXX: offer shouldn't automatically wake
    // queue.wake();

    if (!value) {
      InboxQueueReplyOverflow overflowQueue;

      synchronized (this) {
        overflowQueue = _replyOverflowQueue;

        if (overflowQueue == null) {
          _replyOverflowQueue = overflowQueue = new InboxQueueReplyOverflow(queue);
        }
      }

      return overflowQueue.offer(message);
    }

    return value;

    // offerAndWake(message);

    // return true;
  }
Esempio n. 2
0
  @Override
  public boolean offer(MessageAmp message, long callerTimeout) {
    if (_lifecycle.isAfterStopping()) {
      message.fail(
          new ServiceExceptionClosed(L.l("closed {0} for message {1}", serviceRef(), message)));

      return true;
    }

    QueueDeliver<MessageAmp> queue = _queue;

    long timeout = Math.min(_sendTimeout, callerTimeout);

    boolean result = queue.offer(message, timeout, TimeUnit.MILLISECONDS);

    if (!result) {
      _fullHandler.onQueueFull(serviceRef(), queue.size(), timeout, TimeUnit.MILLISECONDS, message);

      return false;
    }

    return result;
  }