Class SchemaResolverProperties
- java.lang.Object
-
- com.solace.serdes.common.resolver.config.BaseProperties
-
- com.solace.serdes.common.resolver.config.SchemaResolverProperties
-
public class SchemaResolverProperties extends BaseProperties
A class for configuring Schema Resolver properties. This class is used bySchemaResolver
- See Also:
SchemaResolver
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SchemaResolverProperties.IfArtifactExists
Enumeration for controlling the behavior when registering an artifact that might already exist in the schema registry.
-
Field Summary
Fields Modifier and Type Field Description static String
ARTIFACT_RESOLVER_STRATEGY
Property key for specifying a class that implementsArtifactReferenceResolverStrategy
static String
AUTH_PASSWORD
The Password of the Auth Service.static String
AUTH_USERNAME
The Username of the Auth Service.static String
AUTO_REGISTER_ARTIFACT
Controls whether schemas should be automatically registered when they don't exist in the registry during serialization.static String
AUTO_REGISTER_ARTIFACT_IF_EXISTS
Controls the behavior when auto-registering an artifact that might already exist in the registry.static String
CACHE_LATEST
Controls the caching behavior of schema lookups that use 'latest' or no version.static String
CACHE_TTL_MS
Specifies the time-to-live (TTL) for cached schema artifacts in milliseconds.static String
EXPLICIT_ARTIFACT_ARTIFACT_ID
Optional property that explicitly sets the artifactId used for querying an artifact in the registry.static String
EXPLICIT_ARTIFACT_GROUP_ID
Optional property that explicitly sets the groupId used for querying an artifact in the registry.static String
EXPLICIT_ARTIFACT_VERSION
Optional property that explicitly sets the version used for querying an artifact in the registry.static String
FIND_LATEST_ARTIFACT
Optional boolean flag that determines whether serializer classes should attempt to locate the most recent artifact in the registry for the given groupId and artifactId combination.static String
REGISTRY_URL
The URL of the Schema Registry.static String
REQUEST_ATTEMPT_BACKOFF_MS
Specifies the backoff time in milliseconds between retry attempts when communicating with the schema registry.static String
REQUEST_ATTEMPTS
Specifies the number of attempts to make when communicating with the schema registry before giving up.static String
SCHEMA_LOCATION
Specifies the classpath resource path to the schema to be used for validation.static String
STRATEGY_TOPIC_PROFILE
Optional property that specifies aSolaceTopicProfile
object used by theSolaceTopicIdStrategy
to map topics to artifact references.static String
TRUST_STORE_PASSWORD
Property key for specifying the password of the trust store.static String
TRUST_STORE_PATH
Property key for specifying the path to the trust store file.static String
USE_CACHED_ON_ERROR
Controls whether to use cached schemas when schema registry lookup errors occur.static String
VALIDATE_CERTIFICATE
Property key for enabling or disabling certificate validation.
-
Constructor Summary
Constructors Constructor Description SchemaResolverProperties()
Constructs a new SchemaResolverProperties instance with default properties.SchemaResolverProperties(Map<String,?> map)
Constructs a new SchemaResolverProperties instance with default properties then applies properties from the passed in map.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
findLatestArtifact()
Retrieves theFIND_LATEST_ARTIFACT
boolean flag that determines whether serializer classes should attempt to locate the most recent artifact in the registry for the given groupId and artifactId combination.Class<?>
getArtifactReferenceResolverStrategyClass()
Retrieves an instance of an ArtifactReferenceResolverStrategy.String
getAuthPassword()
Retrieves the password for authentication with the Auth Service.String
getAuthUsername()
Retrieves the username for authentication with the Auth Service.boolean
getAutoRegisterArtifact()
Retrieves the auto-register artifact setting specified by theAUTO_REGISTER_ARTIFACT
configuration.SchemaResolverProperties.IfArtifactExists
getAutoRegisterArtifactIfExists()
Retrieves the behavior to use when auto-registering artifacts that might already exist.boolean
getCacheLatest()
Retrieves the cache latest property specified by theCACHE_LATEST
configuration.Duration
getCacheTTL()
Retrieves the cache time-to-live (TTL) duration specified by theCACHE_TTL_MS
configuration in milliseconds.String
getExplicitArtifactArtifactId()
Retrieves theEXPLICIT_ARTIFACT_ARTIFACT_ID
which is used to explicitly set the artifactId for querying an artifact in the registry.String
getExplicitArtifactGroupId()
Retrieves theEXPLICIT_ARTIFACT_GROUP_ID
which is used to explicitly set the groupId for querying an artifact in the registry.String
getExplicitArtifactVersion()
Retrieves theEXPLICIT_ARTIFACT_VERSION
which is used to explicitly set the version for querying an artifact in the registry.String
getRegistryUrl()
Retrieves the URL of the Solace Schema Registry.Duration
getRequestAttemptBackoff()
Retrieves the backoff time in milliseconds between retry attempts when communicating with the schema registry.long
getRequestAttempts()
Retrieves the number of attempts to make when communicating with the schema registry before giving up.String
getSchemaLocation()
Gets the configured classpath resource path to the schema.SolaceTopicProfile
getStrategyTopicProfile()
Retrieves theSolaceTopicProfile
object specified by theSTRATEGY_TOPIC_PROFILE
configuration.String
getTrustStorePassword()
Gets the password for the trust store.String
getTrustStorePath()
Gets the path to the trust store file.boolean
getUseCachedOnError()
Retrieves the use cached on error property specified by theUSE_CACHED_ON_ERROR
configuration.boolean
getValidateCertificate()
Gets the certificate validation setting.-
Methods inherited from class com.solace.serdes.common.resolver.config.BaseProperties
getConfig
-
-
-
-
Field Detail
-
REGISTRY_URL
public static final String REGISTRY_URL
The URL of the Schema Registry.- See Also:
- Constant Field Values
-
AUTH_USERNAME
public static final String AUTH_USERNAME
The Username of the Auth Service.- See Also:
- Constant Field Values
-
AUTH_PASSWORD
public static final String AUTH_PASSWORD
The Password of the Auth Service.- See Also:
- Constant Field Values
-
FIND_LATEST_ARTIFACT
public static final String FIND_LATEST_ARTIFACT
Optional boolean flag that determines whether serializer classes should attempt to locate the most recent artifact in the registry for the given groupId and artifactId combination. GroupId and artifactId are configured viaArtifactReferenceResolverStrategy
.- See Also:
- Constant Field Values
-
EXPLICIT_ARTIFACT_VERSION
public static final String EXPLICIT_ARTIFACT_VERSION
Optional property that explicitly sets the version used for querying an artifact in the registry. This property is only applicable for serializers. Overrides the version returned by theArtifactReferenceResolverStrategy
Note: If this property and the
FIND_LATEST_ARTIFACT
are set to true, this property takes precedence.- See Also:
- Constant Field Values
-
EXPLICIT_ARTIFACT_ARTIFACT_ID
public static final String EXPLICIT_ARTIFACT_ARTIFACT_ID
Optional property that explicitly sets the artifactId used for querying an artifact in the registry. This property is only applicable for serializers. Overrides the artifactId returned by theArtifactReferenceResolverStrategy
- See Also:
- Constant Field Values
-
EXPLICIT_ARTIFACT_GROUP_ID
public static final String EXPLICIT_ARTIFACT_GROUP_ID
Optional property that explicitly sets the groupId used for querying an artifact in the registry. This property is only applicable for serializers. Overrides the groupId returned by theArtifactReferenceResolverStrategy
- See Also:
- Constant Field Values
-
STRATEGY_TOPIC_PROFILE
public static final String STRATEGY_TOPIC_PROFILE
Optional property that specifies aSolaceTopicProfile
object used by theSolaceTopicIdStrategy
to map topics to artifact references. This property is used to configure the topic to artifact mapping.The value should be a
SolaceTopicProfile
object that defines the mapping rules between Solace topics and artifact references in the Schema Registry.When this property is null or unset, the
SolaceTopicIdStrategy
will have the same behaviour asDestinationIdStrategy
.- See Also:
- Constant Field Values
-
TRUST_STORE_PATH
public static final String TRUST_STORE_PATH
Property key for specifying the path to the trust store file.This property is used to set the path to the trust store file that contains trusted CA certificates. It's used when connecting to a schema registry over HTTPS and the server's certificate is not in the default trust store defined by the JDK.
The value should be a
String
representing the file path to the trust store or null when not in use.Example usage:
properties.put(TRUST_STORE_PATH, "/path/to/truststore.jks");
- See Also:
- Constant Field Values
-
TRUST_STORE_PASSWORD
public static final String TRUST_STORE_PASSWORD
Property key for specifying the password of the trust store.This property is used when
TRUST_STORE_PATH
is provided. It provides the password required to access the trust store. WhenTRUST_STORE_PATH
is not set, this property will have no effect.The value should be a
String
representing the password of the trust store or null when not in use.Example usage:
properties.put(TRUST_STORE_PASSWORD, "truststore_password");
- See Also:
- Constant Field Values
-
VALIDATE_CERTIFICATE
public static final String VALIDATE_CERTIFICATE
Property key for enabling or disabling certificate validation.This property determines whether the client should validate the server's SSL certificate when connecting to the schema registry over HTTPS.
By Default this property is set to
true
.The value should be a
Boolean
or aString
that can be parsed as a boolean. If set totrue
, certificate validation will be performed. If set tofalse
, certificate validation will be skipped (not recommended for production use).Example usage:
// Using a Boolean properties.put(VALIDATE_CERTIFICATE, true); // Using a String properties.put(VALIDATE_CERTIFICATE, "true");
- See Also:
- Constant Field Values
-
ARTIFACT_RESOLVER_STRATEGY
public static final String ARTIFACT_RESOLVER_STRATEGY
Property key for specifying a class that implementsArtifactReferenceResolverStrategy
This property allows the user to specify either an existing ArtifactReferenceResolverStrategy or provide a custom implementation. The ArtifactReferenceResolverStrategy is responsible for determining the specific ArtifactReference for a given data record, enabling the system to locate or register the correct schema in the registry.
The value associated with this key should be one of:
- A
String
representing the fully qualified class name of a class implementing the ArtifactReferenceResolverStrategy interface - A
Class
object of a class implementing the ArtifactReferenceResolverStrategy interface
The specified class must have a public no-argument constructor.
Example usage (both examples have equivalent functionality):
// Using a class name properties.put(ARTIFACT_RESOLVER_STRATEGY, "com.example.CustomArtifactReferenceResolverStrategy"); // Using a Class object properties.put(ARTIFACT_RESOLVER_STRATEGY, CustomArtifactReferenceResolverStrategy.class);
This property is used exclusively by
SchemaResolver.resolveSchema(Record)
- A
-
CACHE_TTL_MS
public static final String CACHE_TTL_MS
Specifies the time-to-live (TTL) for cached schema artifacts in milliseconds. This property determines how long a schema remains valid in the cache before it needs to be fetched again from the registry on the next relevant look up. Special value: 0: Disables caching. Schemas will be fetched from the registry on every request. The following types are supported for configuration:- Long or Number: millisecond value
properties.put(CACHE_TTL_MS, 5000L);
- String: Millisecond value as a String
properties.put(CACHE_TTL_MS, "5000");
- Duration: Java Duration object with any temporal unit
properties.put(CACHE_TTL_MS, Duration.ofMillis(5000));
properties.put(CACHE_TTL_MS, Duration.ofSeconds(5));
properties.put(CACHE_TTL_MS, Duration.ofMinutes(1));
Note: Duration values must be non-negative and must not exceed the maximum value that can be represented in milliseconds (Duration.ofMillis(Long.MAX_VALUE)
). Exceeding these limits will result in anIllegalArgumentException
during configuration.
- See Also:
- Constant Field Values
- Long or Number: millisecond value
-
CACHE_LATEST
public static final String CACHE_LATEST
Controls the caching behavior of schema lookups that use 'latest' or no version. When enabled, these lookups will create an additional cache entry to allow subsequent latest/no-version lookups to use the cache. When disabled, only the resolved version is cached, requiring subsequent latest/no-version lookups to be fetched from the registry.Values:
- true: Creates additional cache entry for latest/no-version lookups
- false: Only caches the resolved version
NOTE:
- This property does not effect the schema lookup result when an explicit version is specified.
- This property only affects caching behavior for serialization but does not apply to schema references. When using this property, schema references do not interact with the cache and are resolved by lookups to the registry.
Default value: true
- See Also:
- Constant Field Values
-
USE_CACHED_ON_ERROR
public static final String USE_CACHED_ON_ERROR
Controls whether to use cached schemas when schema registry lookup errors occur. When enabled, schema resolution will use cached schemas instead of throwing exceptions afterREQUEST_ATTEMPTS
are exhausted. This is useful in environments where using a potentially stale schema is preferable to service interruptions.Values:
- true: Uses cached schemas when schema registry lookup errors occur
- false: Throws exception when schema registry lookup errors occur
NOTE:
- In normal conditions, the cache will still be used first.
- This property only takes effect when an attempt to retrieve an expired schema from the registry causes an error.
Default value: false
- See Also:
REQUEST_ATTEMPTS
, Constant Field Values
-
REQUEST_ATTEMPTS
public static final String REQUEST_ATTEMPTS
Specifies the number of attempts to make when communicating with the schema registry before giving up. Valid values are positive long values (1 -Long.MAX_VALUE
). When used withUSE_CACHED_ON_ERROR
this property specifies the number of attempts before falling back to the last cached value.A value must be specified as a positive long value. Values less than or equal to 0 will result in an exception during configuration. Null values are also not allowed.
Default value: 3
- See Also:
USE_CACHED_ON_ERROR
, Constant Field Values
-
REQUEST_ATTEMPT_BACKOFF_MS
public static final String REQUEST_ATTEMPT_BACKOFF_MS
Specifies the backoff time in milliseconds between retry attempts when communicating with the schema registry. Valid values are non-negative long values (0 - Max Long) or a Duration object.The following types are supported for configuration:
- Long or Number: millisecond value
properties.put(REQUEST_ATTEMPT_BACKOFF_MS, 500L);
- String: Millisecond value as a String
properties.put(REQUEST_ATTEMPT_BACKOFF_MS, "500");
- Duration: Java Duration object with any temporal unit
properties.put(REQUEST_ATTEMPT_BACKOFF_MS, Duration.ofMillis(500));
properties.put(REQUEST_ATTEMPT_BACKOFF_MS, Duration.ofSeconds(0.5));
Note: Duration values must be non-negative and must not exceed the maximum value that can be represented in milliseconds (Duration.ofMillis(Long.MAX_VALUE)
). Exceeding these limits will result in an exception during configuration.
Default value: 500 (milliseconds)
- See Also:
- Constant Field Values
- Long or Number: millisecond value
-
AUTO_REGISTER_ARTIFACT
public static final String AUTO_REGISTER_ARTIFACT
Controls whether schemas should be automatically registered when they don't exist in the registry during serialization. When enabled, the serializer will attempt to register new schemas in the registry when they are not found. When disabled, serialization will fail with an exception if the schema is not found.Values:
- true: Automatically register schemas when not found
- false: Throw an exception when schemas are not found
Default value: false
- See Also:
- Constant Field Values
-
SCHEMA_LOCATION
public static final String SCHEMA_LOCATION
Specifies the classpath resource path to the schema to be used for validation. This should be a path that can be resolved from the classpath usingThread.currentThread().getContextClassLoader().getResource(schemaLocation)
. For example: "com/example/schemas/myschema.json". The default is null.- See Also:
- Constant Field Values
-
AUTO_REGISTER_ARTIFACT_IF_EXISTS
public static final String AUTO_REGISTER_ARTIFACT_IF_EXISTS
Controls the behavior when auto-registering an artifact that might already exist in the registry. This property determines how the system handles artifact registration when a similar artifact already exists in the registry.Possible values:
- FAIL: Fails the registration if the artifact already exists
- CREATE_VERSION: Creates a new version of the existing artifact
- FIND_OR_CREATE_VERSION: Uses the existing artifact if it exists, otherwise creates a new version
This property is used in conjunction with
AUTO_REGISTER_ARTIFACT
when automatically registering schemas to the registry during serialization.Default value: FIND_OR_CREATE_VERSION
- See Also:
AUTO_REGISTER_ARTIFACT
, Constant Field Values
-
-
Method Detail
-
getRegistryUrl
public String getRegistryUrl()
Retrieves the URL of the Solace Schema Registry.- Returns:
- The Schema Registry URL as a String.
-
getAuthUsername
public String getAuthUsername()
Retrieves the username for authentication with the Auth Service.- Returns:
- The Auth Service username as a String.
-
getAuthPassword
public String getAuthPassword()
Retrieves the password for authentication with the Auth Service.- Returns:
- The Auth Service password as a String.
-
findLatestArtifact
public boolean findLatestArtifact()
Retrieves theFIND_LATEST_ARTIFACT
boolean flag that determines whether serializer classes should attempt to locate the most recent artifact in the registry for the given groupId and artifactId combination.- Returns:
- The boolean value of the
FIND_LATEST_ARTIFACT
boolean flag.
-
getExplicitArtifactVersion
public String getExplicitArtifactVersion()
Retrieves theEXPLICIT_ARTIFACT_VERSION
which is used to explicitly set the version for querying an artifact in the registry.- Returns:
- The explicitly set artifact version as a String, or null if not set.
-
getExplicitArtifactArtifactId
public String getExplicitArtifactArtifactId()
Retrieves theEXPLICIT_ARTIFACT_ARTIFACT_ID
which is used to explicitly set the artifactId for querying an artifact in the registry.- Returns:
- The explicitly set artifactId as a String, or null if not set.
-
getExplicitArtifactGroupId
public String getExplicitArtifactGroupId()
Retrieves theEXPLICIT_ARTIFACT_GROUP_ID
which is used to explicitly set the groupId for querying an artifact in the registry.- Returns:
- The explicitly set groupId as a String, or null if not set.
-
getTrustStorePath
public String getTrustStorePath()
Gets the path to the trust store file.This method retrieves the value associated with the
TRUST_STORE_PATH
key in the configuration.- Returns:
- A String representing the path to the trust store file, or null if not set.
- Throws:
IllegalStateException
- if the value associated withTRUST_STORE_PATH
is not a String.
-
getTrustStorePassword
public String getTrustStorePassword()
Gets the password for the trust store.This method retrieves the value associated with the
TRUST_STORE_PASSWORD
key in the configuration.- Returns:
- A String representing the password for the trust store, or null if not set.
- Throws:
IllegalStateException
- if the value associated withTRUST_STORE_PASSWORD
is not a String.
-
getValidateCertificate
public boolean getValidateCertificate()
Gets the certificate validation setting.This method retrieves the value associated with the
VALIDATE_CERTIFICATE
key in the configuration.- Returns:
- A boolean indicating whether certificate validation is enabled. Returns true if validation is enabled, false otherwise.
- Throws:
IllegalStateException
- if the value associated withVALIDATE_CERTIFICATE
is not a boolean or a String that can be parsed as a boolean.
-
getArtifactReferenceResolverStrategyClass
public Class<?> getArtifactReferenceResolverStrategyClass()
Retrieves an instance of an ArtifactReferenceResolverStrategy.The
ARTIFACT_RESOLVER_STRATEGY
key in the configuration can be:- A
String
representing the fully qualified class name of a class implementing the ArtifactReferenceResolverStrategy interface - A
Class
object of a class implementing the ArtifactReferenceResolverStrategy interface
- Returns:
- An ArtifactReferenceResolverStrategy instance.
- Throws:
IllegalStateException
- if:- No ArtifactReferenceResolverStrategy is found for the
ARTIFACT_RESOLVER_STRATEGY
key - The class specified by the
ARTIFACT_RESOLVER_STRATEGY
key is not found - The object specified by the
ARTIFACT_RESOLVER_STRATEGY
key is neither a String, nor Class
- No ArtifactReferenceResolverStrategy is found for the
- See Also:
ArtifactReferenceResolverStrategy
- A
-
getStrategyTopicProfile
public SolaceTopicProfile getStrategyTopicProfile()
Retrieves theSolaceTopicProfile
object specified by theSTRATEGY_TOPIC_PROFILE
configuration.This method attempts to retrieve the
SolaceTopicProfile
object from the configuration that was set using theSTRATEGY_TOPIC_PROFILE
key. TheSolaceTopicProfile
is used by theSolaceTopicIdStrategy
to map topics to artifact references.- Returns:
- The
SolaceTopicProfile
object if it was set in the configuration, or null if it wasn't set. - Throws:
IllegalStateException
- if the value associated withSTRATEGY_TOPIC_PROFILE
is neither null nor an instance ofSolaceTopicProfile
.
-
getCacheTTL
public Duration getCacheTTL()
Retrieves the cache time-to-live (TTL) duration specified by theCACHE_TTL_MS
configuration in milliseconds.This method attempts to retrieve and convert the cache TTL value from the configuration that was set using the
CACHE_TTL_MS
key. The TTL duration determines how long a schema remains valid in the cache before it needs to be fetched again from the registry. A value of zero indicates that caching is disabled.- Returns:
- A
Duration
representing the cache TTL in milliseconds. - Throws:
IllegalStateException
- if the value associated withCACHE_TTL_MS
is null, negative, or cannot be parsed as a valid duration (accepts Number, String, or Duration values).
-
getCacheLatest
public boolean getCacheLatest()
Retrieves the cache latest property specified by theCACHE_LATEST
configuration.This method attempts to retrieve the cache latest property from the configuration that was set using the
CACHE_LATEST
key. The cache latest property controls the caching behavior of schema lookups that use 'latest' or no version.- Returns:
- A boolean indicating whether the cache latest property is enabled. Returns true if enabled, false otherwise.
- Throws:
IllegalStateException
- if the value associated withCACHE_LATEST
cannot be parsed as a valid boolean.
-
getUseCachedOnError
public boolean getUseCachedOnError()
Retrieves the use cached on error property specified by theUSE_CACHED_ON_ERROR
configuration.This method attempts to retrieve the use cached on error property from the configuration that was set using the
USE_CACHED_ON_ERROR
key. The use cached on error property controls whether to use cached schemas when registry connection errors occur.- Returns:
- A boolean indicating whether the use cached on error property is enabled. Returns true if enabled, false otherwise.
- Throws:
IllegalStateException
- if the value associated withUSE_CACHED_ON_ERROR
cannot be parsed as a valid boolean.
-
getRequestAttempts
public long getRequestAttempts()
Retrieves the number of attempts to make when communicating with the schema registry before giving up.This method retrieves the value associated with the
REQUEST_ATTEMPTS
key in the configuration.- Returns:
- A long value representing the number of attempts to make.
- Throws:
IllegalStateException
- if the value associated withREQUEST_ATTEMPTS
is null, not positive, or cannot be parsed as a valid long.
-
getRequestAttemptBackoff
public Duration getRequestAttemptBackoff()
Retrieves the backoff time in milliseconds between retry attempts when communicating with the schema registry.This method attempts to retrieve and convert the backoff time value from the configuration that was set using the
REQUEST_ATTEMPT_BACKOFF_MS
key. The backoff time determines the wait time between retry attempts when communicating with the schema registry.- Returns:
- A
Duration
representing the backoff time in milliseconds. - Throws:
IllegalStateException
- if the value associated withREQUEST_ATTEMPT_BACKOFF_MS
is null, negative, or cannot be parsed as a valid duration (accepts Number, String, or Duration values).
-
getAutoRegisterArtifact
public boolean getAutoRegisterArtifact()
Retrieves the auto-register artifact setting specified by theAUTO_REGISTER_ARTIFACT
configuration.This method retrieves the value associated with the
AUTO_REGISTER_ARTIFACT
key in the configuration. This property controls whether schemas should be automatically registered when they don't exist in the registry during serialization.- Returns:
- A boolean indicating whether automatic schema registration is enabled. Returns true if enabled, false otherwise.
- Throws:
IllegalStateException
- if the value associated withAUTO_REGISTER_ARTIFACT
cannot be parsed as a valid boolean.
-
getAutoRegisterArtifactIfExists
public SchemaResolverProperties.IfArtifactExists getAutoRegisterArtifactIfExists()
Retrieves the behavior to use when auto-registering artifacts that might already exist.This method retrieves the value associated with the
AUTO_REGISTER_ARTIFACT_IF_EXISTS
key in the configuration. This property controls how the system handles artifact registration when a similar artifact already exists in the registry.- Returns:
- The
SchemaResolverProperties.IfArtifactExists
strategy to use when an artifact already exists. - Throws:
IllegalStateException
- if the value cannot be parsed as a valid IfArtifactExists value.
-
getSchemaLocation
public String getSchemaLocation()
Gets the configured classpath resource path to the schema. This path can be used to load the schema resource from the classpath.- Returns:
- the classpath resource path to the schema, or null if not configured
-
-