Class AmazonSQSMessagingClientWrapper

java.lang.Object
com.amazon.sqs.javamessaging.AmazonSQSMessagingClientWrapper

public class AmazonSQSMessagingClientWrapper extends Object
This is a JMS Wrapper of AmazonSQSClient. This class changes all AmazonServiceException and AmazonClientException into JMSException/JMSSecurityException.
  • Constructor Summary

    Constructors
    Constructor
    Description
    AmazonSQSMessagingClientWrapper(com.amazonaws.services.sqs.AmazonSQS amazonSQSClient)
     
    AmazonSQSMessagingClientWrapper(com.amazonaws.services.sqs.AmazonSQS amazonSQSClient, com.amazonaws.auth.AWSCredentialsProvider credentialsProvider)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    changeMessageVisibility(com.amazonaws.services.sqs.model.ChangeMessageVisibilityRequest changeMessageVisibilityRequest)
    Calls changeMessageVisibility and wraps AmazonClientException.
    com.amazonaws.services.sqs.model.ChangeMessageVisibilityBatchResult
    changeMessageVisibilityBatch(com.amazonaws.services.sqs.model.ChangeMessageVisibilityBatchRequest changeMessageVisibilityBatchRequest)
    Calls changeMessageVisibilityBatch and wraps AmazonClientException.
    com.amazonaws.services.sqs.model.CreateQueueResult
    createQueue(com.amazonaws.services.sqs.model.CreateQueueRequest createQueueRequest)
    Calls createQueue to create the queue with the provided queue attributes if any, and wraps AmazonClientException
    com.amazonaws.services.sqs.model.CreateQueueResult
    createQueue(String queueName)
    Calls createQueue to create the queue with the default queue attributes, and wraps AmazonClientException
    void
    deleteMessage(com.amazonaws.services.sqs.model.DeleteMessageRequest deleteMessageRequest)
    Calls deleteMessage and wraps AmazonClientException.
    com.amazonaws.services.sqs.model.DeleteMessageBatchResult
    deleteMessageBatch(com.amazonaws.services.sqs.model.DeleteMessageBatchRequest deleteMessageBatchRequest)
    Calls deleteMessageBatch and wraps AmazonClientException.
    com.amazonaws.services.sqs.AmazonSQS
    If one uses any other AWS SDK operations other than explicitly listed here, the exceptions thrown by those operations will not be wrapped as JMSException.
    com.amazonaws.services.sqs.model.GetQueueUrlResult
    getQueueUrl(com.amazonaws.services.sqs.model.GetQueueUrlRequest getQueueUrlRequest)
    Calls getQueueUrl and wraps AmazonClientException
    com.amazonaws.services.sqs.model.GetQueueUrlResult
    getQueueUrl(String queueName)
    Gets the queueUrl of a queue given a queue name.
    com.amazonaws.services.sqs.model.GetQueueUrlResult
    getQueueUrl(String queueName, String queueOwnerAccountId)
    Gets the queueUrl of a queue given a queue name owned by the provided accountId.
    boolean
    queueExists(String queueName)
    Check if the requested queue exists.
    boolean
    queueExists(String queueName, String queueOwnerAccountId)
    Check if the requested queue exists.
    com.amazonaws.services.sqs.model.ReceiveMessageResult
    receiveMessage(com.amazonaws.services.sqs.model.ReceiveMessageRequest receiveMessageRequest)
    Calls receiveMessage and wraps AmazonClientException.
    com.amazonaws.services.sqs.model.SendMessageResult
    sendMessage(com.amazonaws.services.sqs.model.SendMessageRequest sendMessageRequest)
    Calls sendMessage and wraps AmazonClientException.
    void
    setEndpoint(String endpoint)
    Deprecated.
    void
    setRegion(com.amazonaws.regions.Region region)
    Deprecated.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • AmazonSQSMessagingClientWrapper

      public AmazonSQSMessagingClientWrapper(com.amazonaws.services.sqs.AmazonSQS amazonSQSClient) throws jakarta.jms.JMSException
      Parameters:
      amazonSQSClient - The AWS SDK Client for SQS.
      Throws:
      jakarta.jms.JMSException - if the client is null
    • AmazonSQSMessagingClientWrapper

      public AmazonSQSMessagingClientWrapper(com.amazonaws.services.sqs.AmazonSQS amazonSQSClient, com.amazonaws.auth.AWSCredentialsProvider credentialsProvider) throws jakarta.jms.JMSException
      Parameters:
      amazonSQSClient - The AWS SDK Client for SQS.
      Throws:
      jakarta.jms.JMSException - if the client is null
  • Method Details

    • getAmazonSQSClient

      public com.amazonaws.services.sqs.AmazonSQS getAmazonSQSClient()
      If one uses any other AWS SDK operations other than explicitly listed here, the exceptions thrown by those operations will not be wrapped as JMSException.
      Returns:
      amazonSQSClient
    • setEndpoint

      @Deprecated public void setEndpoint(String endpoint) throws jakarta.jms.JMSException
      Deprecated.
      Sets SQS endpoint and wraps IllegalArgumentException. Deprecated. Instead of manipulating settings of existing AmazonSQS client, provide correct configuration when creating it through SQSConnectionFactory constructors.
      Parameters:
      endpoint - The endpoint (ex: "sqs.us-east-1.amazonaws.com") of the region specific AWS endpoint this client will communicate with.
      Throws:
      jakarta.jms.JMSException - jmsException
    • setRegion

      @Deprecated public void setRegion(com.amazonaws.regions.Region region) throws jakarta.jms.JMSException
      Deprecated.
      Sets SQS region and wraps IllegalArgumentException. Deprecated. Instead of manipulating settings of existing AmazonSQS client, provide correct configuration when creating it through SQSConnectionFactory constructors.
      Parameters:
      region - The region this client will communicate with. See Region.getRegion(com.amazonaws.regions.Regions) for accessing a given region.
      Throws:
      jakarta.jms.JMSException - jmsException
    • deleteMessage

      public void deleteMessage(com.amazonaws.services.sqs.model.DeleteMessageRequest deleteMessageRequest) throws jakarta.jms.JMSException
      Calls deleteMessage and wraps AmazonClientException. This is used to acknowledge single messages, so that they can be deleted from SQS queue.
      Parameters:
      deleteMessageRequest - Container for the necessary parameters to execute the deleteMessage service method on AmazonSQS.
      Throws:
      jakarta.jms.JMSException - jmsException
    • deleteMessageBatch

      public com.amazonaws.services.sqs.model.DeleteMessageBatchResult deleteMessageBatch(com.amazonaws.services.sqs.model.DeleteMessageBatchRequest deleteMessageBatchRequest) throws jakarta.jms.JMSException
      Calls deleteMessageBatch and wraps AmazonClientException. This is used to acknowledge multiple messages on client_acknowledge mode, so that they can be deleted from SQS queue.
      Parameters:
      deleteMessageBatchRequest - Container for the necessary parameters to execute the deleteMessageBatch service method on AmazonSQS. This is the batch version of deleteMessage. Max batch size is 10.
      Returns:
      The response from the deleteMessageBatch service method, as returned by AmazonSQS
      Throws:
      jakarta.jms.JMSException - jmsException
    • sendMessage

      public com.amazonaws.services.sqs.model.SendMessageResult sendMessage(com.amazonaws.services.sqs.model.SendMessageRequest sendMessageRequest) throws jakarta.jms.JMSException
      Calls sendMessage and wraps AmazonClientException.
      Parameters:
      sendMessageRequest - Container for the necessary parameters to execute the sendMessage service method on AmazonSQS.
      Returns:
      The response from the sendMessage service method, as returned by AmazonSQS
      Throws:
      jakarta.jms.JMSException - jmsException
    • queueExists

      public boolean queueExists(String queueName) throws jakarta.jms.JMSException
      Check if the requested queue exists. This function calls GetQueueUrl for the given queue name, returning true on success, false if it gets QueueDoesNotExistException.
      Parameters:
      queueName - the queue to check
      Returns:
      true if the queue exists, false if it doesn't.
      Throws:
      jakarta.jms.JMSException - jmsException
    • queueExists

      public boolean queueExists(String queueName, String queueOwnerAccountId) throws jakarta.jms.JMSException
      Check if the requested queue exists. This function calls GetQueueUrl for the given queue name with the given owner accountId, returning true on success, false if it gets QueueDoesNotExistException.
      Parameters:
      queueName - the queue to check
      queueOwnerAccountId - The AWS accountId of the account that created the queue
      Returns:
      true if the queue exists, false if it doesn't.
      Throws:
      jakarta.jms.JMSException - jmsException
    • getQueueUrl

      public com.amazonaws.services.sqs.model.GetQueueUrlResult getQueueUrl(String queueName) throws jakarta.jms.JMSException
      Gets the queueUrl of a queue given a queue name.
      Parameters:
      queueName - name of the queue
      Returns:
      The response from the GetQueueUrl service method, as returned by AmazonSQS, which will include queue`s URL
      Throws:
      jakarta.jms.JMSException - jmsException
    • getQueueUrl

      public com.amazonaws.services.sqs.model.GetQueueUrlResult getQueueUrl(String queueName, String queueOwnerAccountId) throws jakarta.jms.JMSException
      Gets the queueUrl of a queue given a queue name owned by the provided accountId.
      Parameters:
      queueName - name of the queue
      queueOwnerAccountId - The AWS accountId of the account that created the queue
      Returns:
      The response from the GetQueueUrl service method, as returned by AmazonSQS, which will include queue`s URL
      Throws:
      jakarta.jms.JMSException - jmsException
    • getQueueUrl

      public com.amazonaws.services.sqs.model.GetQueueUrlResult getQueueUrl(com.amazonaws.services.sqs.model.GetQueueUrlRequest getQueueUrlRequest) throws jakarta.jms.JMSException
      Calls getQueueUrl and wraps AmazonClientException
      Parameters:
      getQueueUrlRequest - Container for the necessary parameters to execute the getQueueUrl service method on AmazonSQS.
      Returns:
      The response from the GetQueueUrl service method, as returned by AmazonSQS, which will include queue`s URL
      Throws:
      jakarta.jms.JMSException - jmsException
    • createQueue

      public com.amazonaws.services.sqs.model.CreateQueueResult createQueue(String queueName) throws jakarta.jms.JMSException
      Calls createQueue to create the queue with the default queue attributes, and wraps AmazonClientException
      Parameters:
      queueName - name of the queue
      Returns:
      The response from the createQueue service method, as returned by AmazonSQS. This call creates a new queue, or returns the URL of an existing one.
      Throws:
      jakarta.jms.JMSException - jmsException
    • createQueue

      public com.amazonaws.services.sqs.model.CreateQueueResult createQueue(com.amazonaws.services.sqs.model.CreateQueueRequest createQueueRequest) throws jakarta.jms.JMSException
      Calls createQueue to create the queue with the provided queue attributes if any, and wraps AmazonClientException
      Parameters:
      createQueueRequest - Container for the necessary parameters to execute the createQueue service method on AmazonSQS.
      Returns:
      The response from the createQueue service method, as returned by AmazonSQS. This call creates a new queue, or returns the URL of an existing one.
      Throws:
      jakarta.jms.JMSException - jmsException
    • receiveMessage

      public com.amazonaws.services.sqs.model.ReceiveMessageResult receiveMessage(com.amazonaws.services.sqs.model.ReceiveMessageRequest receiveMessageRequest) throws jakarta.jms.JMSException
      Calls receiveMessage and wraps AmazonClientException. Used by SQSMessageConsumerPrefetch to receive up to minimum of (numberOfMessagesToPrefetch,10) messages from SQS queue into consumer prefetch buffers.
      Parameters:
      receiveMessageRequest - Container for the necessary parameters to execute the receiveMessage service method on AmazonSQS.
      Returns:
      The response from the ReceiveMessage service method, as returned by AmazonSQS.
      Throws:
      jakarta.jms.JMSException - jmsException
    • changeMessageVisibility

      public void changeMessageVisibility(com.amazonaws.services.sqs.model.ChangeMessageVisibilityRequest changeMessageVisibilityRequest) throws jakarta.jms.JMSException
      Calls changeMessageVisibility and wraps AmazonClientException. This is used to for negative acknowledge of a single message, so that messages can be received again without any delay.
      Parameters:
      changeMessageVisibilityRequest - Container for the necessary parameters to execute the changeMessageVisibility service method on AmazonSQS.
      Throws:
      jakarta.jms.JMSException - jmsException
    • changeMessageVisibilityBatch

      public com.amazonaws.services.sqs.model.ChangeMessageVisibilityBatchResult changeMessageVisibilityBatch(com.amazonaws.services.sqs.model.ChangeMessageVisibilityBatchRequest changeMessageVisibilityBatchRequest) throws jakarta.jms.JMSException
      Calls changeMessageVisibilityBatch and wraps AmazonClientException. This is used to for negative acknowledge of messages in batch, so that messages can be received again without any delay.
      Parameters:
      changeMessageVisibilityBatchRequest - Container for the necessary parameters to execute the changeMessageVisibilityBatch service method on AmazonSQS.
      Returns:
      The response from the changeMessageVisibilityBatch service method, as returned by AmazonSQS.
      Throws:
      jakarta.jms.JMSException - jmsException