How to use the @azure/core-amqp.retry function in @azure/core-amqp

To help you get started, we’ve selected a few @azure/core-amqp 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 / eventhub / event-hubs / src / eventHubReceiver.ts View on Github external
// create RHEA receiver options
      const initOptions = this._createReceiverOptions(receiverOptions);

      // attempt to create the link
      const linkCreationConfig: RetryConfig = {
        connectionId: this._context.connectionId,
        connectionHost: this._context.config.host,
        operation: () => this.initialize(initOptions),
        operationType: RetryOperationType.receiverLink,
        retryOptions: {
          maxRetries: Constants.defaultMaxRetriesForConnection,
          retryDelayInMs: 15000
        }
      };

      await retry(linkCreationConfig);

      // if the receiver is in streaming mode we need to add credits again.
      if (this._isStreaming) {
        this._addCredit(Constants.defaultPrefetchCount);
      }
    } catch (err) {
      logger.verbose(
        "[%s] An error occurred while processing onDetached() of Receiver '%s' with address " +
          "'%s': %O",
        this._context.connectionId,
        this.name,
        this.address,
        err
      );
    }
  }
github Azure / azure-sdk-for-js / sdk / eventhub / event-hubs / src / eventHubSender.ts View on Github external
Constants.defaultOperationTimeoutInMs,
            true
          );
          // shall retry forever at an interval of 15 seconds if the error is a retryable error
          // else bail out when the error is not retryable or the oepration succeeds.
          const config: RetryConfig = {
            operation: () => this._init(options),
            connectionId: this._context.connectionId,
            operationType: RetryOperationType.senderLink,
            connectionHost: this._context.config.host,
            retryOptions: {
              maxRetries: Constants.defaultMaxRetriesForConnection,
              retryDelayInMs: 15000
            }
          };
          return retry(config);
        });
      }
github Azure / azure-sdk-for-js / sdk / eventhub / event-hubs / src / eventHubSender.ts View on Github external
const amqpError: AmqpError = {
            condition: ErrorNameConditionMapper.SenderBusyError,
            description: msg
          };
          reject(translate(amqpError));
        }
      });

    const config: RetryConfig = {
      operation: sendEventPromise,
      connectionId: this._context.connectionId,
      operationType: RetryOperationType.sendMessage,
      abortSignal: abortSignal,
      retryOptions: retryOptions
    };
    return retry(config);
  }
github Azure / azure-sdk-for-js / sdk / eventhub / event-hubs / src / managementClient.ts View on Github external
address,
              err
            );
            logErrorStackTrace(err);
            reject(err);
          }
        });

      const config: RetryConfig = {
        operation: sendOperationPromise,
        connectionId: this._context.connectionId,
        operationType: RetryOperationType.management,
        abortSignal: abortSignal,
        retryOptions: retryOptions
      };
      return (await retry(config)).body;
    } catch (err) {
      err = translate(err);
      logger.warning("An error occurred while making the request to $management endpoint: %O", err);
      logErrorStackTrace(err);
      throw err;
    }
  }
github Azure / azure-sdk-for-js / sdk / eventhub / event-hubs / src / receiver.ts View on Github external
if (abortSignal && !abortSignal.aborted) {
          abortSignal.addEventListener("abort", onAbort);
        }
      });
    };

    const retryOptions = this._retryOptions;
    const config: RetryConfig = {
      connectionHost: this._context.config.host,
      connectionId: this._context.connectionId,
      operation: retrieveEvents,
      operationType: RetryOperationType.receiveMessage,
      abortSignal: abortSignal,
      retryOptions: retryOptions
    };
    return retry(config);
  }