Package gov.usgs.earthquake.aws
Class SnsPublisher
java.lang.Object
gov.usgs.util.DefaultConfigurable
gov.usgs.earthquake.aws.SnsPublisher
- All Implemented Interfaces:
EventPublisher
,Configurable
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSnsPublisher
(software.amazon.awssdk.regions.Region region, String topicArn, software.amazon.awssdk.services.sns.SnsClient snsClient) Configurable SNS publisher. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Process configuration settings.void
publishMessage
(String message) Publishes a message to the configured SNS topic.void
shutdown()
Closes the SNS client.Methods inherited from class gov.usgs.util.DefaultConfigurable
getName, setName, startup
-
Field Details
-
LOGGER
Logger to use for this class -
REGION_PROPERTY
- See Also:
-
TOPIC_ARN_PROPERTY
- See Also:
-
-
Constructor Details
-
SnsPublisher
public SnsPublisher(software.amazon.awssdk.regions.Region region, String topicArn, software.amazon.awssdk.services.sns.SnsClient snsClient) Configurable SNS publisher.- Parameters:
region
- AWS region where the SNS topic is.topicArn
- The ARN of the target SNS topic.
-
-
Method Details
-
configure
Description copied from class:DefaultConfigurable
Process configuration settings. Called before startup().- Specified by:
configure
in interfaceConfigurable
- Overrides:
configure
in classDefaultConfigurable
- Parameters:
config
- the Config object with settings.- Throws:
Exception
- if configuration exceptions occur.
-
publishMessage
Publishes a message to the configured SNS topic. Alerts on failure by printing an error message.- Specified by:
publishMessage
in interfaceEventPublisher
- Parameters:
message
- The message to publish.
-
shutdown
public void shutdown()Closes the SNS client.- Specified by:
shutdown
in interfaceConfigurable
- Overrides:
shutdown
in classDefaultConfigurable
-