How to use the rhea-promise.SenderEvents.accepted function in rhea-promise

To help you get started, we’ve selected a few rhea-promise examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Azure / azure-sdk-for-js / sdk / servicebus / service-bus / src / core / messageSender.ts View on Github external
const removeListeners = (): void => {
            clearTimeout(waitTimer);
            // When `removeListeners` is called on timeout, the sender might be closed and cleared
            // So, check if it exists, before removing listeners from it.
            if (this._sender) {
              this._sender.removeListener(SenderEvents.rejected, onRejected);
              this._sender.removeListener(SenderEvents.accepted, onAccepted);
              this._sender.removeListener(SenderEvents.released, onReleased);
              this._sender.removeListener(SenderEvents.modified, onModified);
            }
          };
github Azure / azure-sdk-for-js / sdk / servicebus / service-bus / src / core / messageSender.ts View on Github external
const removeListeners = (): void => {
            clearTimeout(waitTimer);
            // When `removeListeners` is called on timeout, the sender might be closed and cleared
            // So, check if it exists, before removing listeners from it.
            if (this._sender) {
              this._sender.removeListener(SenderEvents.rejected, onRejected);
              this._sender.removeListener(SenderEvents.accepted, onAccepted);
              this._sender.removeListener(SenderEvents.released, onReleased);
              this._sender.removeListener(SenderEvents.modified, onModified);
            }
          };
github Azure / azure-sdk-for-js / sdk / servicebus / service-bus / src / core / messageSender.ts View on Github external
const actionAfterTimeout = () => {
            removeListeners();
            const desc: string =
              `[${this._context.namespace.connectionId}] Sender "${this.name}" ` +
              `with address "${this.address}", was not able to send the message right now, due ` +
              `to operation timeout.`;
            log.error(desc);
            const e: AmqpError = {
              condition: ErrorNameConditionMapper.ServiceUnavailableError,
              description: desc
            };
            return reject(translate(e));
          };

          this._sender!.on(SenderEvents.accepted, onAccepted);
          this._sender!.on(SenderEvents.rejected, onRejected);
          this._sender!.on(SenderEvents.modified, onModified);
          this._sender!.on(SenderEvents.released, onReleased);
          waitTimer = setTimeout(
            actionAfterTimeout,
            Constants.defaultOperationTimeoutInSeconds * 1000
          );
          try {
            const delivery = this._sender!.send(
              encodedMessage,
              undefined,
              sendBatch ? 0x80013700 : 0
            );
            log.sender(
              "[%s] Sender '%s', sent message with delivery id: %d",
              this._context.namespace.connectionId,