Class ServiceBusEmgReceiver
java.lang.Object
com.eqixiac.equinix.messaging.transport.servicebus.ServiceBusEmgReceiver
- All Implemented Interfaces:
EmgReceiver, AutoCloseable
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 Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the underlying connection.static ServiceBusEmgReceiverConnects 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).static ServiceBusEmgReceiverforSubscription(String connectionString, String topicName, String subscriptionName) Connects to a topic subscription, for subscriptions provisioned as topic + subscription rather than a queue.Receives up tomaxMessages, waiting at mostmaxWaitfor the first one.toString()static ServiceBusEmgReceiverwrap(com.azure.messaging.servicebus.ServiceBusReceiverClient client) Wraps a receiver client you built yourself, e.g. with anAzureSasCredentialSAS token or a custom retry policy.
-
Method Details
-
forQueue
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 namesubscriptionName- 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 anAzureSasCredentialSAS token or a custom retry policy. It must useServiceBusReceiveMode.PEEK_LOCKwithdisableAutoComplete(); the returned receiver takes ownership and closes it.- Parameters:
client- the receiver client- Returns:
- the receiver
-
receive
Description copied from interface:EmgReceiverReceives up tomaxMessages, waiting at mostmaxWaitfor the first one.- Specified by:
receivein interfaceEmgReceiver- Parameters:
maxMessages- upper bound on the batch size, at least 1maxWait- 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:EmgReceiverCloses the underlying connection. Unsettled locks are released by the broker.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceEmgReceiver
-
toString
-