Esposter
    Preparing search index...

    Class MockServiceBusSender

    An in-memory mock of the Azure ServiceBusSender. It uses a Map to simulate a Service Bus queue and correctly implements the ServiceBusSender interface.

    const mockServiceBusSender = new MockServiceBusSender("hello world");
    await mockServiceBusSender.scheduleMessages({ body: "hello world" }, new Date());

    Implements

    • ServiceBusSender
    Index
    • Parameters

      • queueName: string

      Returns MockServiceBusSender

    entityPath: string

    Path of the entity for which the sender has been created.

    identifier: string

    A name used to identify the sender. This can be used to correlate logs and exceptions. If not specified or empty, a random unique one will be generated.

    isClosed: boolean = false

    Returns true if either the sender or the client that created it has been closed.

    • get queue(): ServiceBusMessage[]

      Returns ServiceBusMessage[]

    • Cancels multiple messages that were scheduled to appear on a ServiceBus Queue/Subscription.

      Returns Promise<void>

      Error if the underlying connection, client or sender is closed.

      ServiceBusError if the service returns an error while canceling scheduled messages.

    • Closes the underlying AMQP sender link. Once closed, the sender cannot be used for any further operations. Use the createSender function on the QueueClient or TopicClient to instantiate a new Sender

      Returns Promise<void>

    • Creates an instance of ServiceBusMessageBatch to which one can add messages until the maximum supported size is reached. The batch can be passed to the send method to send the messages to Azure Service Bus.

      Returns Promise<ServiceBusMessageBatch>

      ServiceBusError if an error is encountered while sending a message.

      Error if the underlying connection or sender has been closed.

    • Schedules given messages to appear on Service Bus Queue/Subscription at a later time.

      Parameters

      • messages: ServiceBusMessage | ServiceBusMessage[]

        Message or an array of messages that need to be scheduled.

      • scheduledEnqueueTimeUtc: Date

        The UTC time at which the messages should be enqueued.

      Returns Promise<never[]>

      The sequence numbers of messages that were scheduled. You will need the sequence number if you intend to cancel the scheduling of the messages. Save the Long type as-is in your application without converting to number. Since JavaScript only supports 53 bit numbers, converting the Long to number will cause loss in precision.

      Error if the underlying connection, client or sender is closed.

      ServiceBusError if the service returns an error while scheduling messages.

    • Sends the given messages after creating an AMQP Sender link if it doesn't already exist.

      • To send messages to a session and/or partition enabled Queue/Topic, set the sessionId and/or partitionKey properties respectively on the messages.
      • All messages passed to the same sendMessages() call should have the same sessionId (if using sessions) and the same partitionKey (if using partitions).

      Note:

      If you want to send messages of size greater than 1MB, please send individual messages instead of sending a batched message or an array of messages like below.

      await sender.sendMessages(message);

      This is because the batched messages are not capable of sending the larger messages yet. You'll hit the force detached error in this case otherwise. Read service-bus-premium-messaging#large-messages-support. More info at #23014.

      Parameters

      • messages: ServiceBusMessage | ServiceBusMessage[] | ServiceBusMessageBatch

        A single message or an array of messages or a batch of messages created via the createBatch() method to send.

      Returns Promise<void>

      ServiceBusError with the code MessageSizeExceeded if the provided messages do not fit in a single ServiceBusMessageBatch.

      Error if the underlying connection, client or sender is closed.

      ServiceBusError if the service returns an error while sending messages to the service.