Class ServiceBusEmgReceiver

java.lang.Object
com.eqixiac.equinix.messaging.transport.servicebus.ServiceBusEmgReceiver
All Implemented Interfaces:
EmgReceiver, AutoCloseable

public final class ServiceBusEmgReceiver extends Object implements EmgReceiver
EmgReceiver backed by the Azure Service Bus ServiceBusReceiverClient, the transport of the Equinix Messaging Gateway (AMQP 1.0; production namespace equinixemg.servicebus.windows.net per the AsyncAPI spec). Receives in ServiceBusReceiveMode.PEEK_LOCK with auto-complete disabled, so settlement is always explicit.

Requires com.azure:azure-messaging-servicebus on the classpath; the SDK declares it <optional>, so add it to your own build to use this class.

The connection string is a secret: it is passed straight to the Azure builder, never stored in a field, never included in exception messages, logs or toString().

  • Method Details

    • forQueue

      public static ServiceBusEmgReceiver forQueue(String connectionString, String queueName)
      Connects to an EMG queue with the connection string and queue name from your EMG subscription (Customer Portal > Developer Settings > Messaging Gateway > subscription > Configuration > Copy YAML). No network I/O happens until the first receive.
      Parameters:
      connectionString - the Service Bus connection string (secret)
      queueName - the queue name, e.g. prod_<id>_queue
      Returns:
      the receiver
      Throws:
      IllegalArgumentException - if the connection string is rejected (the value is not echoed)
    • forSubscription

      public static ServiceBusEmgReceiver forSubscription(String connectionString, String topicName, String subscriptionName)
      Connects to a topic subscription, for subscriptions provisioned as topic + subscription rather than a queue.
      Parameters:
      connectionString - the Service Bus connection string (secret)
      topicName - the topic name
      subscriptionName - the subscription name
      Returns:
      the receiver
      Throws:
      IllegalArgumentException - if the connection string is rejected (the value is not echoed)
    • wrap

      public static ServiceBusEmgReceiver wrap(com.azure.messaging.servicebus.ServiceBusReceiverClient client)
      Wraps a receiver client you built yourself, e.g. with an AzureSasCredential SAS token or a custom retry policy. It must use ServiceBusReceiveMode.PEEK_LOCK with disableAutoComplete(); the returned receiver takes ownership and closes it.
      Parameters:
      client - the receiver client
      Returns:
      the receiver
    • receive

      public List<EmgDelivery> receive(int maxMessages, Duration maxWait)
      Description copied from interface: EmgReceiver
      Receives up to maxMessages, waiting at most maxWait for the first one.
      Specified by:
      receive in interface EmgReceiver
      Parameters:
      maxMessages - upper bound on the batch size, at least 1
      maxWait - how long to wait before returning a possibly empty batch
      Returns:
      the locked deliveries, possibly empty, never null
    • close

      public void close()
      Description copied from interface: EmgReceiver
      Closes the underlying connection. Unsettled locks are released by the broker.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface EmgReceiver
    • toString

      public String toString()
      Overrides:
      toString in class Object