Class AliSubscription
- All Implemented Interfaces:
Provider,SdkService,AutoCloseable
Receives messages from an SMQ queue via batchPopMessage, acknowledges them via
batchDeleteMessage, and nacks them via changeMessageVisibility. Receipt
handles are modelled as AliSubscription.AliAckID. Registered under the ali provider id.
Of RetryConfig, only attemptTimeout is applied, as the SMQ client's connection
and socket timeouts. maxAttempts, mode, the delay fields, multiplier and
totalTimeout are ignored because the SMQ SDK cannot honor them; see SmqClientFactory.buildClientConfiguration(java.net.URI, com.salesforce.multicloudj.common.retries.RetryConfig).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classSMQ receipt-handle-backedAckID.static classBuilder forAliSubscription. -
Field Summary
FieldsFields inherited from class com.salesforce.multicloudj.pubsub.driver.AbstractSubscription
credentialsOverrider, endpoint, isShutdown, nackVisibilityTimeout, permanentError, providerId, proxyEndpoint, region, retryConfig, subscriptionName, unreportedAckErr -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuilder()Creates and returns a new Builder instance for this provider.booleancanNack()voidclose()Implements AutoCloseable interface for try-with-resources support.protected Batcher.Optionsprotected Batcher.OptionsCreates batcher options for this subscription.doReceiveBatch(int batchSize) Provider specific implementation must fetch at most batchSize messages from the remote service.protected voiddoSendAcks(List<AckID> ackIDs) protected voiddoSendNacks(List<AckInfo> nacks) Sends negative acknowledgments for a batch of messages.Retrieves the unique identifier for this service implementation.booleanisRetryable(Throwable error) Maps a provider-specificThrowableto a fully-builtSubstrateSdkExceptionthe caller can throw directly.Methods inherited from class com.salesforce.multicloudj.pubsub.driver.AbstractSubscription
getNackVisibilityTimeout, receive, sendAck, sendAcks, sendNack, sendNack, sendNacks, sendNacks
-
Field Details
-
PROVIDER_ID
- See Also:
-
-
Constructor Details
-
AliSubscription
public AliSubscription()
-
-
Method Details
-
getProviderId
Description copied from interface:SdkServiceRetrieves the unique identifier for this service implementation.- Specified by:
getProviderIdin interfaceSdkService- Overrides:
getProviderIdin classAbstractSubscription<AliSubscription>- Returns:
- A String representing the provider's ID such as aws.
-
doReceiveBatch
Description copied from class:AbstractSubscriptionProvider specific implementation must fetch at most batchSize messages from the remote service.- Specified by:
doReceiveBatchin classAbstractSubscription<AliSubscription>
-
doSendAcks
- Specified by:
doSendAcksin classAbstractSubscription<AliSubscription>
-
doSendNacks
Description copied from class:AbstractSubscriptionSends negative acknowledgments for a batch of messages. EachAckInfomay carry an optional per-message visibility timeout; whennull, implementations should fall back toAbstractSubscription.getNackVisibilityTimeout(). All entries passed here haveisAck() == false.- Specified by:
doSendNacksin classAbstractSubscription<AliSubscription>
-
createReceiveBatcherOptions
Description copied from class:AbstractSubscriptionCreates batcher options for this subscription. Provides defaults that cloud providers can override to provide provider-specific batching configuration that aligns with their service limits and performance characteristics.- Overrides:
createReceiveBatcherOptionsin classAbstractSubscription<AliSubscription>
-
createAckBatcherOptions
- Specified by:
createAckBatcherOptionsin classAbstractSubscription<AliSubscription>
-
canNack
public boolean canNack()- Specified by:
canNackin classAbstractSubscription<AliSubscription>
-
isRetryable
- Specified by:
isRetryablein classAbstractSubscription<AliSubscription>
-
getAttributes
- Specified by:
getAttributesin classAbstractSubscription<AliSubscription>
-
mapException
Description copied from interface:SdkServiceMaps a provider-specificThrowableto a fully-builtSubstrateSdkExceptionthe caller can throw directly. The returned exception carries both the typed mapping (e.g.ResourceNotFoundExceptionfor HTTP 404) and an authoritative retryable flag derived from the native cloud SDK signal (e.g. AWS throttling, GCPApiException.isRetryable(), status codes), or the type's default retryability when the SDK exposes no native signal.Callers throw the result; they do not inspect or transform it further:
try { ... } catch (Throwable t) { throw provider.mapException(t); }Implementation contract: implementations should compute a typed exception class (typically via their per-service
ErrorCodeMapping) and a retryable hint, then returnExceptionHandler.build(exceptionClass, t, retryableHint). Implementations do not need to short-circuit whentis already aSubstrateSdkException:ExceptionHandler.buildpreserves an already-mapped exception's concrete subtype and retryable flag.- Parameters:
t- the original throwable from the provider SDK- Returns:
- a built
SubstrateSdkExceptionready to throw
-
close
Description copied from class:AbstractSubscriptionImplements AutoCloseable interface for try-with-resources support.Shuts down the subscription and releases all resources.
This method should: - Flush any pending acknowledgments or nacks - Close network connections - Release any other provider-specific resources
After calling this method, the subscription should not accept new operations. It is safe to call this method multiple times.
- Specified by:
closein interfaceAutoCloseable- Overrides:
closein classAbstractSubscription<AliSubscription>- Throws:
Exception
-
builder
Description copied from interface:ProviderCreates and returns a new Builder instance for this provider.- Returns:
- A Builder instance for constructing this provider.
-