Class Service
- Direct Known Subclasses:
Dispatcher,Parser,Protocol,Reactor,Writer
EventBus
for inter-component communication / services and a Logger for logging.
Subclasses can use the event bus to send or receive messages and the logger for
diagnostic output. This class also provides a default stop() method that can
be overridden to implement custom shutdown logic.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringTopic suffix for the producer→sink address-discovery protocol.protected EventBusThe event bus used for communication between components.protected static final DateTimeFormatterShared timestamp formatter (seeTimer.formatter) available to all services for consistent serialization and parsing of timestamps.protected final LoggerLogger instance for this service, initialized with the class name. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringaddressRegistry(String group) Returns the address-discovery topic for the given producergroup.protected voidannounceAddress(String group, String address) Announces thataddressis an output channel of the producergroup, so that sinks subscribed toaddressRegistry(String)can discover and bind it.voidstop()Stops the service.
-
Field Details
-
ADDRESS_REGISTRY_SUFFIX
Topic suffix for the producer→sink address-discovery protocol.A producing service announces each of its output channel names on the topic
"<group>" + ADDRESS_REGISTRY_SUFFIX(seeannounceAddress(String, String)). Sinks such as dispatchers and writers subscribe to that same topic (usingaddressRegistry(String)) to dynamically discover and bind the channels a producer emits. Thegroupis typically a device name or a logical producer id.- See Also:
-
eventBus
The event bus used for communication between components. -
logger
Logger instance for this service, initialized with the class name. -
formatter
Shared timestamp formatter (seeTimer.formatter) available to all services for consistent serialization and parsing of timestamps.
-
-
Constructor Details
-
Service
Creates a new service instance with the specified event bus.- Parameters:
eventBus- the event bus used for communication
-
-
Method Details
-
addressRegistry
Returns the address-discovery topic for the given producergroup.- Parameters:
group- device name or logical producer id- Returns:
- the topic sinks subscribe to in order to discover
group's output channels
-
announceAddress
Announces thataddressis an output channel of the producergroup, so that sinks subscribed toaddressRegistry(String)can discover and bind it.- Parameters:
group- device name or logical producer id this service emits underaddress- the output channel name being announced
-
stop
public void stop()Stops the service.By default, this method logs a message indicating that no stop logic is implemented. Subclasses should override this method to provide custom shutdown behavior when necessary.
-
