public static interface SinkHandler.SinkServiceProperties.Builder
A new instance of such a builder can be created using
DiffusionGatewayFramework.newSinkServicePropertiesBuilder()
.
Modifier and Type | Method and Description |
---|---|
SinkHandler.SinkServiceProperties.Builder |
autoSubscribe(boolean autoSubscribe)
Specifies a boolean flag to specify whether the framework
should subscribe to the configured topic selector when a
service is started.
|
SinkHandler.SinkServiceProperties |
build()
Creates a
SinkHandler.SinkServiceProperties instance with the current
settings of this builder. |
SinkHandler.SinkServiceProperties.Builder |
payloadConverter(PayloadConverter<?,?> converter)
Specifies a payload converter to use for the service.
|
SinkHandler.SinkServiceProperties.Builder |
payloadConverter(String name)
Specifies the name of a payload converter to use for this
service.
|
SinkHandler.SinkServiceProperties.Builder |
payloadConverter(String name,
Map<String,Object> parameters)
Specifies the name of a payload converter and parameters the
converter requires to be initialized.
|
SinkHandler.SinkServiceProperties.Builder autoSubscribe(boolean autoSubscribe)
Defaults to true, meaning topics are subscribed to as soon as the service is started.
If this is set to false, the adapter writer is responsible for
subscribing to Diffusion topics using Subscriber.subscribe()
or Subscriber.subscribe(String)
methods as required.
The Subscriber
instance is passed in the
GatewayApplication.addSink(ServiceDefinition, Subscriber, StateHandler)
.
autoSubscribe
- the boolean flag to specify whether the framework
should subscribe to the configured topic
selector when a service is started.SinkHandler.SinkServiceProperties.Builder payloadConverter(String name) throws InvalidConfigurationException
The framework will use a converter with the supplied name and add to the list of converters for this service.
This method can be used instead of payloadConverter(String, Map)
or
payloadConverter(PayloadConverter)
to let the
framework instantiate the converter with the supplied name, if it
does not require any parameters.
This can be called multiple times to assign multiple converters for the service.
One of the converters defined in PayloadConverter
can be explicitly specified if required.
name
- the converter name.InvalidConfigurationException
- if name is null or empty or a
payload
converter
with the given name could not be found.ApplicationInitializationException
- if the converter
with the supplied name is not allowed to be used for the
applicationfor details on how supplied converters will be
validated and how converters will be executed
SinkHandler.SinkServiceProperties.Builder payloadConverter(String name, Map<String,Object> parameters) throws InvalidConfigurationException
The framework will instantiate a converter with the supplied details and add to the list of converters for this service.
This method can be used instead of payloadConverter(String)
or
payloadConverter(PayloadConverter)
to let the
framework use the converter with the supplied name and
parameters.
This can be called multiple times to assign multiple converters for the service.
name
- the converter name.parameters
- the parameters required to instantiate the
converter.InvalidConfigurationException
- if name is null or a
payload
converter
with the given name could not be foundApplicationInitializationException
- if the converter
with the supplied name is not allowed to be used for the
application or the payload converter instantiation failsfor details on how supplied converters will be
validated and how converters will be executed
SinkHandler.SinkServiceProperties.Builder payloadConverter(PayloadConverter<?,?> converter) throws InvalidConfigurationException
This method can be used instead of
payloadConverter(String)
or payloadConverter(String, Map)
in cases where an
instantiated converter needs to be supplied.
This can be called multiple times to assign multiple converters for the service.
converter
- the converter.InvalidConfigurationException
- if converter is nullApplicationInitializationException
- if the converter
with the supplied name is not allowed to be used for the
applicationfor details on how supplied converters will be
validated and how converters will be executed
SinkHandler.SinkServiceProperties build() throws InvalidConfigurationException
SinkHandler.SinkServiceProperties
instance with the current
settings of this builder.
If no payload converter has been specified, the framework uses default payload converters according to the topic type for received update.
If a single converter has been assigned for this service, its input type should correspond to the Diffusion topic type or the input type should be `Object` which accepts any input data. This also applies to the first converter in the collection, if multiple converters have been assigned for the service.
If multiple converters are specified, they
will be called in order. This order will be determined by the order the
converters are added in the builder using
payloadConverter(String)
or
payloadConverter(String, Map)
or
payloadConverter(PayloadConverter)
. Thus,
the input and output types of the converters in the chain should
match their predecessor and follower. This means that the
input type of the second converter in the chain should be the
same as, or a superclass or superinterface of, the output type
of the previous converter, and so on.
For example, consider following to create a SinkServiceProperties:
newSinkServicePropertiesBuilder() .payloadConverter(converter1) .payloadConverter("converter2",parameters) .payloadConverter("converter3") .build();With the above code snippet, a list of converters will be created containing 'converter1', "converter2", and "converter3" in order. The input type of 'converter1' should be 'Object' or compatible with any Diffusion topic type, and its output type should match the input type of 'converter2'. Similarly, the input type of 'converter2' should match the output type of 'converter1', and the output type should match the input type of 'converter3', and so on.
InvalidConfigurationException
- if the input type of the
first payload converter is not specific to a Diffusion topic
type or is 'Object' that accepts any input values.Copyright © 2024 DiffusionData Limited. All rights reserved.