コード例 #1
0
ファイル: InboxQueue.java プロジェクト: baratine/baratine
  /** Init calls the @OnInit methods. */
  private void init(StubAmp stub) {
    // BuildMessageAmp buildMessage = new BuildMessageAmp(this);

    OnInitMessage onInitMsg = new OnInitMessage(this);

    _queue.offer(onInitMsg);
    _queue.wake();
  }
コード例 #2
0
ファイル: InboxQueue.java プロジェクト: baratine/baratine
  private void start(StubAmp stub) {
    if (!_lifecycle.toStarting()) {
      return;
    }

    // OutboxAmpBase buildContext = new OutboxAmpBase();

    // BuildMessageAmp buildMessage = new BuildMessageAmp(this);
    // MessageAmp oldMessage = ContextMessageAmp.getAndSet(buildMessage);

    // Outbox<MessageAmp> oldContext = OutboxThreadLocal.getCurrent();

    try {
      // OutboxThreadLocal.setCurrent(buildContext);

      MessageAmp onActiveMsg = new OnActiveMessage(this, isSingle());

      JournalAmp journal = stub.journal();

      // buildContext.setMessage(onActiveMsg);

      if (journal != null) {
        if (log.isLoggable(Level.FINER)) {
          log.finer(
              L.l(
                  "journal replay {0} ({1})",
                  serviceRef().address(), serviceRef().api().getType()));
        }

        onActiveMsg = new OnActiveReplayMessage(this, stub, isSingle());

        ActiveResult activeResult = new ActiveResult(onActiveMsg);

        ReplayMessage replayMsg = new ReplayMessage(this, _queue, activeResult);

        // buildContext.setMessage(replayMsg);

        _queue.offer(replayMsg);
        _queue.wake();
      } else {
        // _worker.onActive();
        // _queue.offer(onActiveMsg);
        _lifecycle.toActive();
        // _queue.wake();
      }
    } finally {
      // OutboxThreadLocal.setCurrent(oldContext);
      // ContextMessageAmp.set(oldMessage);
    }
  }
コード例 #3
0
ファイル: InboxQueue.java プロジェクト: baratine/baratine
  @Override
  public final void offerAndWake(MessageAmp message, long callerTimeout) {
    if (isClosed()) { // _lifecycle.isAfterStopping()) {
      message.fail(
          new ServiceExceptionClosed(
              L.l("Closed {0}, stub {1} for message {2}", serviceRef(), _stubMain, message)));

      return;
    }

    QueueDeliver<MessageAmp> queue = _queue;

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

    if (!queue.offer(message, timeout, TimeUnit.MILLISECONDS)) {
      // ThreadDump.create().dumpThreads();
      _fullHandler.onQueueFull(serviceRef(), queue.size(), timeout, TimeUnit.MILLISECONDS, message);
    }

    queue.wake();
  }