internal void manualAck(StanMsg m) { if (m == null) { return; } rwLock.EnterReadLock(); string localAckSubject = ackInbox; bool localManualAck = options.manualAcks; Connection sc = this.sc; rwLock.ExitReadLock(); if (localManualAck == false) { throw new StanManualAckException(); } if (sc == null) { throw new StanBadSubscriptionException(); } byte[] b = ProtocolSerializer.createAck(m.proto); sc.NATSConnection.Publish(localAckSubject, b); }
internal void processMsg(MsgProto mp) { rwLock.EnterReadLock(); EventHandler <StanMsgHandlerArgs> cb = handler; bool isManualAck = options.manualAcks; string localAckSubject = ackInbox; IStanConnection subsSc = sc; IConnection localNc = null; if (subsSc != null) { localNc = sc.NATSConnection; } rwLock.ExitReadLock(); if (cb != null && subsSc != null) { StanMsgHandlerArgs args = new StanMsgHandlerArgs(new StanMsg(mp, this)); cb(this, args); } if (!isManualAck && localNc != null) { byte[] b = ProtocolSerializer.createAck(mp); try { localNc.Publish(localAckSubject, b); } catch (Exception) { /* * Ignore - subscriber could have closed the connection * or there's been a connection error. The server will * resend the unacknowledged messages. */ } } }