Package gov.usgs.earthquake.nats
Class NATSStreamingNotificationSender
java.lang.Object
gov.usgs.util.DefaultConfigurable
gov.usgs.earthquake.product.AbstractListener
gov.usgs.earthquake.distribution.DefaultNotificationListener
gov.usgs.earthquake.distribution.DefaultNotificationSender
gov.usgs.earthquake.nats.NATSStreamingNotificationSender
- All Implemented Interfaces:
NotificationIndexCleanup.Listener
,NotificationListener
,Configurable
Sends notifications directly to NATS streaming server using a NATS client
-
Field Summary
Fields inherited from class gov.usgs.earthquake.distribution.DefaultNotificationSender
DEFAULT_PRODUCT_STORAGE_MAX_AGE, PRODUCT_STORAGE_MAX_AGE_PROPERTY, PRODUCT_STORAGE_PROPERTY, productStorage, productStorageMaxAge, SERVER_HOST_PROPERTY, SERVER_PORT_PROPERTY, serverHost, serverPort
Fields inherited from class gov.usgs.earthquake.distribution.DefaultNotificationListener
CLEANUP_INTERVAL_PROPERTY, CONCURRENT_PRODUCTS_PROPERTY, DEFAULT_CLEANUP_INTERVAL, DEFAULT_CONCURRENT_PRODUCTS, DEFAULT_PROCESS_DUPLICATES, EXCLUDE_PATHS_PROPERTY, INCLUDE_PATHS_PROPERTY, INDEX_FILE_PROPERTY, NOTIFICATION_INDEX_PROPERTY, PROCESS_DUPLICATES
Fields inherited from class gov.usgs.earthquake.product.AbstractListener
ATTEMPT_COUNT_PROPERTY, DEFAULT_ATTEMPT_COUNT, DEFAULT_RETRY_DELAY, DEFAULT_TIMEOUT, EXCLUDE_SOURCES_PROPERTY, EXCLUDE_TYPES_PROPERTY, INCLUDE_ACTUALS_PROPERTY, INCLUDE_DEVELOPMENTS_PROPERTY, INCLUDE_INTERNALS_PROPERTY, INCLUDE_SCENARIOS_PROPERTY, INCLUDE_SOURCES_PROPERTY, INCLUDE_TESTS_PROPERTY, INCLUDE_TYPES_PROPERTY, MAX_TRIES_PROPERTY, RETRY_DELAY_PROPERTY, TIMEOUT_PROPERTY
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Configures based on configuration section.void
sendNotification
(Notification notification) Publishes notification to NATS streaming servervoid
setClient
(NATSClient client) void
setSubject
(String subject) void
shutdown()
Safely closes the NATSStreaming connection and superclassesvoid
startup()
Starts NATSStreaming connection and superclassesMethods inherited from class gov.usgs.earthquake.distribution.DefaultNotificationSender
getProductStorage, getProductStorageMaxAge, getServerHost, getServerPort, onAfterProcessNotification, onBeforeProcessNotification, onExpiredNotification, onProduct, setProductStorage, setProductStorageMaxAge, setServerHost, setServerPort
Methods inherited from class gov.usgs.earthquake.distribution.DefaultNotificationListener
cleanup, getCleanupInterval, getConcurrentProducts, getExcludePaths, getIncludePaths, getNotificationIndex, isProcessDuplicates, onBeforeProcessProduct, onNotification, setCleanupInterval, setConcurrentProducts, setNotificationIndex, setProcessDuplicates
Methods inherited from class gov.usgs.earthquake.product.AbstractListener
accept, getExcludeSources, getExcludeTypes, getIncludeSources, getIncludeTypes, getMaxTries, getRetryDelay, getTimeout, isIncludeActuals, isIncludeDevelopments, isIncludeInternals, isIncludeScenarios, isIncludeTests, setIncludeActuals, setIncludeDevelopments, setIncludeInternals, setIncludeScenarios, setIncludeTests, setMaxTries, setRetryDelay, setTimeout
Methods inherited from class gov.usgs.util.DefaultConfigurable
getName, setName
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface gov.usgs.util.Configurable
getName, setName
Methods inherited from interface gov.usgs.earthquake.distribution.NotificationListener
getMaxTries, getTimeout
-
Constructor Details
-
NATSStreamingNotificationSender
public NATSStreamingNotificationSender()
-
-
Method Details
-
configure
Description copied from class:DefaultNotificationSender
Configures based on configuration section.- Specified by:
configure
in interfaceConfigurable
- Overrides:
configure
in classDefaultNotificationSender
- Parameters:
config
- The config- Throws:
Exception
- if something goes wrong
-
sendNotification
Publishes notification to NATS streaming server- Overrides:
sendNotification
in classDefaultNotificationSender
- Parameters:
notification
- The notification to send- Throws:
Exception
- if something goes wrong with publish
-
startup
Starts NATSStreaming connection and superclasses- Specified by:
startup
in interfaceConfigurable
- Overrides:
startup
in classDefaultNotificationSender
- Throws:
Exception
- if there's an issue with superclasses, generating a client ID, or connecting to server
-
shutdown
Safely closes the NATSStreaming connection and superclasses- Specified by:
shutdown
in interfaceConfigurable
- Overrides:
shutdown
in classDefaultNotificationSender
- Throws:
Exception
- if superclasses throw exceptions
-
getClient
- Returns:
- NATSClient
-
setClient
- Parameters:
client
- NATSClient to set
-
getSubject
- Returns:
- subject
-
setSubject
- Parameters:
subject
- to set
-