Class AmazonSQSMessagingClientWrapper


  • public class AmazonSQSMessagingClientWrapper
    extends Object
    This is a JMS Wrapper of SqsClient. This class changes all AwsServiceException and SdkException into JMSException/JMSSecurityException.
    • Constructor Summary

      Constructors 
      Constructor Description
      AmazonSQSMessagingClientWrapper​(software.amazon.awssdk.services.sqs.SqsClient amazonSQSClient)  
      AmazonSQSMessagingClientWrapper​(software.amazon.awssdk.services.sqs.SqsClient amazonSQSClient, software.amazon.awssdk.auth.credentials.AwsCredentialsProvider credentialsProvider)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void changeMessageVisibility​(software.amazon.awssdk.services.sqs.model.ChangeMessageVisibilityRequest changeMessageVisibilityRequest)
      Calls changeMessageVisibility and wraps SdkException.
      software.amazon.awssdk.services.sqs.model.ChangeMessageVisibilityBatchResponse changeMessageVisibilityBatch​(software.amazon.awssdk.services.sqs.model.ChangeMessageVisibilityBatchRequest changeMessageVisibilityBatchRequest)
      Calls changeMessageVisibilityBatch and wraps SdkException.
      software.amazon.awssdk.services.sqs.model.CreateQueueResponse createQueue​(String queueName)
      Calls createQueue to create the queue with the default queue attributes, and wraps SdkException
      software.amazon.awssdk.services.sqs.model.CreateQueueResponse createQueue​(software.amazon.awssdk.services.sqs.model.CreateQueueRequest createQueueRequest)
      Calls createQueue to create the queue with the provided queue attributes if any, and wraps SdkException
      void deleteMessage​(software.amazon.awssdk.services.sqs.model.DeleteMessageRequest deleteMessageRequest)
      Calls deleteMessage and wraps SdkException.
      software.amazon.awssdk.services.sqs.model.DeleteMessageBatchResponse deleteMessageBatch​(software.amazon.awssdk.services.sqs.model.DeleteMessageBatchRequest deleteMessageBatchRequest)
      Calls deleteMessageBatch and wraps SdkException.
      software.amazon.awssdk.services.sqs.SqsClient 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.
      software.amazon.awssdk.services.sqs.model.GetQueueUrlResponse getQueueUrl​(String queueName)
      Gets the queueUrl of a queue given a queue name.
      software.amazon.awssdk.services.sqs.model.GetQueueUrlResponse getQueueUrl​(String queueName, String queueOwnerAccountId)
      Gets the queueUrl of a queue given a queue name owned by the provided accountId.
      software.amazon.awssdk.services.sqs.model.GetQueueUrlResponse getQueueUrl​(software.amazon.awssdk.services.sqs.model.GetQueueUrlRequest getQueueUrlRequest)
      Calls getQueueUrl and wraps SdkException
      boolean queueExists​(String queueName)
      Check if the requested queue exists.
      boolean queueExists​(String queueName, String queueOwnerAccountId)
      Check if the requested queue exists.
      software.amazon.awssdk.services.sqs.model.ReceiveMessageResponse receiveMessage​(software.amazon.awssdk.services.sqs.model.ReceiveMessageRequest receiveMessageRequest)
      Calls receiveMessage and wraps SdkException.
      software.amazon.awssdk.services.sqs.model.SendMessageResponse sendMessage​(software.amazon.awssdk.services.sqs.model.SendMessageRequest sendMessageRequest)
      Calls sendMessage and wraps AmazonClientException.
    • Constructor Detail

      • AmazonSQSMessagingClientWrapper

        public AmazonSQSMessagingClientWrapper​(software.amazon.awssdk.services.sqs.SqsClient amazonSQSClient)
                                        throws javax.jms.JMSException
        Parameters:
        amazonSQSClient - The AWS SDK Client for SQS.
        Throws:
        javax.jms.JMSException - if the client is null
      • AmazonSQSMessagingClientWrapper

        public AmazonSQSMessagingClientWrapper​(software.amazon.awssdk.services.sqs.SqsClient amazonSQSClient,
                                               software.amazon.awssdk.auth.credentials.AwsCredentialsProvider credentialsProvider)
                                        throws javax.jms.JMSException
        Parameters:
        amazonSQSClient - The AWS SDK Client for SQS.
        Throws:
        javax.jms.JMSException - if the client is null
    • Method Detail

      • getAmazonSQSClient

        public software.amazon.awssdk.services.sqs.SqsClient 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
      • deleteMessage

        public void deleteMessage​(software.amazon.awssdk.services.sqs.model.DeleteMessageRequest deleteMessageRequest)
                           throws javax.jms.JMSException
        Calls deleteMessage and wraps SdkException. 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 SqsClient.
        Throws:
        javax.jms.JMSException
      • deleteMessageBatch

        public software.amazon.awssdk.services.sqs.model.DeleteMessageBatchResponse deleteMessageBatch​(software.amazon.awssdk.services.sqs.model.DeleteMessageBatchRequest deleteMessageBatchRequest)
                                                                                                throws javax.jms.JMSException
        Calls deleteMessageBatch and wraps SdkException. 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 SqsClient. This is the batch version of deleteMessage. Max batch size is 10.
        Returns:
        The response from the deleteMessageBatch service method, as returned by SqsClient
        Throws:
        javax.jms.JMSException
      • sendMessage

        public software.amazon.awssdk.services.sqs.model.SendMessageResponse sendMessage​(software.amazon.awssdk.services.sqs.model.SendMessageRequest sendMessageRequest)
                                                                                  throws javax.jms.JMSException
        Calls sendMessage and wraps AmazonClientException.
        Parameters:
        sendMessageRequest - Container for the necessary parameters to execute the sendMessage service method on SqsClient.
        Returns:
        The response from the sendMessage service method, as returned by SqsClient
        Throws:
        javax.jms.JMSException
      • queueExists

        public boolean queueExists​(String queueName)
                            throws javax.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:
        javax.jms.JMSException
      • queueExists

        public boolean queueExists​(String queueName,
                                   String queueOwnerAccountId)
                            throws javax.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:
        javax.jms.JMSException
      • getQueueUrl

        public software.amazon.awssdk.services.sqs.model.GetQueueUrlResponse getQueueUrl​(String queueName)
                                                                                  throws javax.jms.JMSException
        Gets the queueUrl of a queue given a queue name.
        Parameters:
        queueName -
        Returns:
        The response from the GetQueueUrl service method, as returned by SqsClient, which will include queue`s URL
        Throws:
        javax.jms.JMSException
      • getQueueUrl

        public software.amazon.awssdk.services.sqs.model.GetQueueUrlResponse getQueueUrl​(String queueName,
                                                                                         String queueOwnerAccountId)
                                                                                  throws javax.jms.JMSException
        Gets the queueUrl of a queue given a queue name owned by the provided accountId.
        Parameters:
        queueName -
        queueOwnerAccountId - The AWS accountId of the account that created the queue
        Returns:
        The response from the GetQueueUrl service method, as returned by SqsClient, which will include queue`s URL
        Throws:
        javax.jms.JMSException
      • getQueueUrl

        public software.amazon.awssdk.services.sqs.model.GetQueueUrlResponse getQueueUrl​(software.amazon.awssdk.services.sqs.model.GetQueueUrlRequest getQueueUrlRequest)
                                                                                  throws javax.jms.JMSException
        Calls getQueueUrl and wraps SdkException
        Parameters:
        getQueueUrlRequest - Container for the necessary parameters to execute the getQueueUrl service method on SqsClient.
        Returns:
        The response from the GetQueueUrl service method, as returned by SqsClient, which will include queue`s URL
        Throws:
        javax.jms.JMSException
      • createQueue

        public software.amazon.awssdk.services.sqs.model.CreateQueueResponse createQueue​(String queueName)
                                                                                  throws javax.jms.JMSException
        Calls createQueue to create the queue with the default queue attributes, and wraps SdkException
        Parameters:
        queueName -
        Returns:
        The response from the createQueue service method, as returned by SqsClient. This call creates a new queue, or returns the URL of an existing one.
        Throws:
        javax.jms.JMSException
      • createQueue

        public software.amazon.awssdk.services.sqs.model.CreateQueueResponse createQueue​(software.amazon.awssdk.services.sqs.model.CreateQueueRequest createQueueRequest)
                                                                                  throws javax.jms.JMSException
        Calls createQueue to create the queue with the provided queue attributes if any, and wraps SdkException
        Parameters:
        createQueueRequest - Container for the necessary parameters to execute the createQueue service method on SqsClient.
        Returns:
        The response from the createQueue service method, as returned by SqsClient. This call creates a new queue, or returns the URL of an existing one.
        Throws:
        javax.jms.JMSException
      • receiveMessage

        public software.amazon.awssdk.services.sqs.model.ReceiveMessageResponse receiveMessage​(software.amazon.awssdk.services.sqs.model.ReceiveMessageRequest receiveMessageRequest)
                                                                                        throws javax.jms.JMSException
        Calls receiveMessage and wraps SdkException. 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 SqsClient.
        Returns:
        The response from the ReceiveMessage service method, as returned by SqsClient.
        Throws:
        javax.jms.JMSException
      • changeMessageVisibility

        public void changeMessageVisibility​(software.amazon.awssdk.services.sqs.model.ChangeMessageVisibilityRequest changeMessageVisibilityRequest)
                                     throws javax.jms.JMSException
        Calls changeMessageVisibility and wraps SdkException. 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 SqsClient.
        Throws:
        javax.jms.JMSException
      • changeMessageVisibilityBatch

        public software.amazon.awssdk.services.sqs.model.ChangeMessageVisibilityBatchResponse changeMessageVisibilityBatch​(software.amazon.awssdk.services.sqs.model.ChangeMessageVisibilityBatchRequest changeMessageVisibilityBatchRequest)
                                                                                                                    throws javax.jms.JMSException
        Calls changeMessageVisibilityBatch and wraps SdkException. 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 SqsClient.
        Returns:
        The response from the changeMessageVisibilityBatch service method, as returned by SqsClient.
        Throws:
        javax.jms.JMSException