T - the type of object that is expected by the update(java.lang.String, T) method.
This should match the type that is output by the
payload convertor in use for the
service.public interface SinkHandler<T> extends ServiceHandler
A sink handler receives updates from the framework via its update method. A sink handler will only receive updates when the service is
in an ACTIVE state.
A sink handler will not receive updates until the start method has been called. It will also not receive updates if the
pause method has been called and updates will
not resume until the resume method is called.
An object that implements this interface must be returned when the
GatewayApplication.addSink method is
called. A different object must be returned for each different service. The
object must implement the update method to publish any
update(s) received from the framework to the back end sink.
The handler may also optionally return service
specific properties via its getSinkServiceProperties() method. If it
does not then defaults will be assumed.
| Modifier and Type | Interface and Description |
|---|---|
static interface |
SinkHandler.SinkServiceProperties
The service properties that apply to the sink service.
|
ServiceHandler.PauseReason, ServiceHandler.ResumeReason| Modifier and Type | Method and Description |
|---|---|
default SinkHandler.SinkServiceProperties |
getSinkServiceProperties()
This is used to set topic-specific properties for topics consumed by this
service.
|
CompletableFuture<?> |
update(String path,
T value)
Called by the framework to publish a new value received from Diffusion to
the sink.
|
pause, resume, start, stopdefault SinkHandler.SinkServiceProperties getSinkServiceProperties() throws InvalidConfigurationException
Properties can be built using a
builder which can be created using
DiffusionGatewayFramework.newSinkServicePropertiesBuilder().
The default implementation returns null, which means that all defaults
are assumed for service properties. See the methods of
SinkHandler.SinkServiceProperties.Builder for details about defaults.
InvalidConfigurationException - possibly thrown by
SinkHandler.SinkServiceProperties.BuilderCompletableFuture<?> update(String path, T value)
The payload convertor defined by the
service properties will have been applied
to the Diffusion value received from the topic to produce the sink
specific value.
path - the path of the Diffusion topic that the value has been been
received fromvalue - the value to publish to the sinkIf the update completes successfully, the CompletableFuture result should be null. The result type is any rather than Void to provide forward compatibility with future iterations of this API that may provide a non-null result with a more specific result type.
If the future completes exceptionally or the future fails to
complete within the timeout specified in the configuration, the
framework will pause the service. If
the method throws an exception, it will be logged but the service
will not be paused.
Copyright © 2023 DiffusionData Limited. All rights reserved.