Class DefaultAmazonSQSManager
- java.lang.Object
-
- org.opennms.core.ipc.common.aws.sqs.DefaultAmazonSQSManager
-
- All Implemented Interfaces:
AmazonSQSManager
public class DefaultAmazonSQSManager extends java.lang.Object implements AmazonSQSManager
-
-
Constructor Summary
Constructors Constructor Description DefaultAmazonSQSManager(AmazonSQSConfig sqsConfig)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getRpcReplyQueueNameAndCreateIfNecessary(java.lang.String moduleId, java.lang.String location)
Retrieve the queue name to use for RPC replies from a specific RPC Module and location.java.lang.String
getRpcRequestQueueNameAndCreateIfNecessary(java.lang.String moduleId, java.lang.String location)
Retrieve the queue name to use for RPC request targetting a specific RPC Module and location.protected java.lang.String
getSinkQueueName(java.lang.String moduleId)
java.lang.String
getSinkQueueUrlAndCreateIfNecessary(java.lang.String moduleId)
Retrieve the queue URL for the given Sink Module and create the queue if it does not already exist.com.amazonaws.services.sqs.AmazonSQS
getSQSClient()
Retrieve the underlying SQS client.com.amazon.sqs.javamessaging.SQSConnectionFactory
getSQSConnectionFactory()
Retrieve a connection factory that wraps the SQS client as a JMS provider.java.lang.String
sendMessage(java.lang.String queueUrl, java.lang.String body)
Send message.
-
-
-
Constructor Detail
-
DefaultAmazonSQSManager
public DefaultAmazonSQSManager(AmazonSQSConfig sqsConfig)
-
-
Method Detail
-
getSinkQueueUrlAndCreateIfNecessary
public java.lang.String getSinkQueueUrlAndCreateIfNecessary(java.lang.String moduleId) throws java.lang.InterruptedException
Description copied from interface:AmazonSQSManager
Retrieve the queue URL for the given Sink Module and create the queue if it does not already exist.This is a blocking operation. If AWS is unreachable, the method will keep retrying indefinitely until the queue is created and the queue URL is determined, or the thread is interrupted.
This function may cache the queue URL, avoiding unecesssary API calls.
- Specified by:
getSinkQueueUrlAndCreateIfNecessary
in interfaceAmazonSQSManager
- Parameters:
moduleId
- the ID of the Sink Module- Returns:
- the queue URL
- Throws:
java.lang.InterruptedException
-
getRpcRequestQueueNameAndCreateIfNecessary
public java.lang.String getRpcRequestQueueNameAndCreateIfNecessary(java.lang.String moduleId, java.lang.String location) throws AmazonSQSQueueException
Description copied from interface:AmazonSQSManager
Retrieve the queue name to use for RPC request targetting a specific RPC Module and location. Also create the queue if it does not already exist.This function may cache the queue URL, avoiding unecesssary API calls.
- Specified by:
getRpcRequestQueueNameAndCreateIfNecessary
in interfaceAmazonSQSManager
- Parameters:
moduleId
- the ID of the RPC Modulelocation
- the targetted location of the request- Returns:
- the queue name
- Throws:
AmazonSQSQueueException
- if some error occured creating the queue or determining the URL
-
getRpcReplyQueueNameAndCreateIfNecessary
public java.lang.String getRpcReplyQueueNameAndCreateIfNecessary(java.lang.String moduleId, java.lang.String location) throws AmazonSQSQueueException
Description copied from interface:AmazonSQSManager
Retrieve the queue name to use for RPC replies from a specific RPC Module and location. Also create the queue if it does not already exist.This function may cache the queue URL, avoiding unecesssary API calls.
- Specified by:
getRpcReplyQueueNameAndCreateIfNecessary
in interfaceAmazonSQSManager
- Parameters:
moduleId
- the ID of the RPC Modulelocation
- the source location of the reply- Returns:
- the queue name
- Throws:
AmazonSQSQueueException
- if some error occured creating the queue or determining the URL
-
getSQSClient
public com.amazonaws.services.sqs.AmazonSQS getSQSClient()
Description copied from interface:AmazonSQSManager
Retrieve the underlying SQS client.- Specified by:
getSQSClient
in interfaceAmazonSQSManager
- Returns:
- the sqs client
-
getSQSConnectionFactory
public com.amazon.sqs.javamessaging.SQSConnectionFactory getSQSConnectionFactory()
Description copied from interface:AmazonSQSManager
Retrieve a connection factory that wraps the SQS client as a JMS provider.- Specified by:
getSQSConnectionFactory
in interfaceAmazonSQSManager
- Returns:
- the JMS connection factory
-
sendMessage
public java.lang.String sendMessage(java.lang.String queueUrl, java.lang.String body) throws java.lang.InterruptedException
Description copied from interface:AmazonSQSManager
Send message.This is a blocking operation. If AWS is unreachable, the method will keep retrying indefinitely until the message is delivered or the thread is interrupted.
- Specified by:
sendMessage
in interfaceAmazonSQSManager
- Parameters:
queueUrl
- the queue URLbody
- the message body- Returns:
- the message ID
- Throws:
java.lang.InterruptedException
-
getSinkQueueName
protected java.lang.String getSinkQueueName(java.lang.String moduleId)
-
-