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 TypeMethodDescriptionvoidProcess configuration settings.voidpublishMessage(String message) Publishes a message to the configured SNS topic.voidshutdown()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:DefaultConfigurableProcess configuration settings. Called before startup().- Specified by:
configurein interfaceConfigurable- Overrides:
configurein 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:
publishMessagein interfaceEventPublisher- Parameters:
message- The message to publish.
-
shutdown
public void shutdown()Closes the SNS client.- Specified by:
shutdownin interfaceConfigurable- Overrides:
shutdownin classDefaultConfigurable
-