@Override
    public void onNext(ByteBuffer buffer) {
      super.onNext(buffer);

      if (this.responseChannel == null) {
        this.responseChannel = exchange.getResponseChannel();
      }

      this.writing.incrementAndGet();
      try {
        int c;
        do {
          c = this.responseChannel.write(buffer);
        } while (buffer.hasRemaining() && c > 0);

        if (buffer.hasRemaining()) {
          this.writing.incrementAndGet();
          enqueue(buffer);
          this.responseChannel.getWriteSetter().set(this);
          this.responseChannel.resumeWrites();
        } else {
          this.subscription.request(1);
        }

      } catch (IOException ex) {
        onError(ex);
      } finally {
        this.writing.decrementAndGet();
        if (this.closing.get()) {
          closeIfDone();
        }
      }
    }
示例#2
0
 @Override
 public void onNext(T t) {
   super.onNext(t);
   BackpressureUtils.getAndSub(REQUESTED, FallbackAction.this, 1L);
   doFallbackNext(t);
 }