Exemplo n.º 1
0
  @Override
  void doDispatch() throws IOException {
    if (this.pullSession == null) return;
    if (this.pullSession.getSession() == null) return;
    if (this.pullSession.getPullMsg() == null) return;

    String msgId = this.pullSession.getPullMsg().getMsgId();

    if (this.msgQ.containsKey(msgId)) {
      Message msg = this.msgQ.get(msgId);
      if (!msgId.equals(msg.getMsgId())) {
        return;
      }
      this.msgQ.remove(msgId);
      try {
        prepareMessageStatus(msg);
        this.pullSession.getSession().write(msg);

        if (this.pullSession.window.get() > 0) {
          this.pullSession.window.decrementAndGet();
        }

      } catch (IOException ex) {
        log.error(ex.getMessage(), ex);
      }

      if (this.pullSession.window.get() != -1 && this.pullSession.window.get() <= 0) {
        this.pullSession.setSession(null);
      }
    }
  }
Exemplo n.º 2
0
 public void produce(Message msg, Session sess) throws IOException {
   String msgId = msg.getMsgId();
   if (msg.isAck()) {
     ReplyHelper.reply200(msgId, sess);
   }
   msgQ.put(msgId, msg);
   this.dispatch();
 }