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 classSchemaResolverProperties.IfArtifactExistsEnumeration 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 StringARTIFACT_RESOLVER_STRATEGYProperty key for specifying a class that implementsArtifactReferenceResolverStrategystatic StringAUTH_PASSWORDThe Password of the Auth Service.static StringAUTH_USERNAMEThe Username of the Auth Service.static StringAUTO_REGISTER_ARTIFACTControls whether schemas should be automatically registered when they don't exist in the registry during serialization.static StringAUTO_REGISTER_ARTIFACT_IF_EXISTSControls the behavior when auto-registering an artifact that might already exist in the registry.static StringCACHE_LATESTControls the caching behavior of schema lookups that use 'latest' or no version.static StringCACHE_TTL_MSSpecifies the time-to-live (TTL) for cached schema artifacts in milliseconds.static StringEXPLICIT_ARTIFACT_ARTIFACT_IDOptional property that explicitly sets the artifactId used for querying an artifact in the registry.static StringEXPLICIT_ARTIFACT_GROUP_IDOptional property that explicitly sets the groupId used for querying an artifact in the registry.static StringEXPLICIT_ARTIFACT_VERSIONOptional property that explicitly sets the version used for querying an artifact in the registry.static StringFIND_LATEST_ARTIFACTOptional 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 StringREGISTRY_URLThe URL of the Schema Registry.static StringREQUEST_ATTEMPT_BACKOFF_MSSpecifies the backoff time in milliseconds between retry attempts when communicating with the schema registry.static StringREQUEST_ATTEMPTSSpecifies the number of attempts to make when communicating with the schema registry before giving up.static StringSCHEMA_LOCATIONSpecifies the classpath resource path to the schema to be used for validation.static StringSTRATEGY_TOPIC_PROFILEOptional property that specifies aSolaceTopicProfileobject used by theSolaceTopicIdStrategyto map topics to artifact references.static StringTRUST_STORE_PASSWORDProperty key for specifying the password of the trust store.static StringTRUST_STORE_PATHProperty key for specifying the path to the trust store file.static StringUSE_CACHED_ON_ERRORControls whether to use cached schemas when schema registry lookup errors occur.static StringVALIDATE_CERTIFICATEProperty 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 booleanfindLatestArtifact()Retrieves theFIND_LATEST_ARTIFACTboolean 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.StringgetAuthPassword()Retrieves the password for authentication with the Auth Service.StringgetAuthUsername()Retrieves the username for authentication with the Auth Service.booleangetAutoRegisterArtifact()Retrieves the auto-register artifact setting specified by theAUTO_REGISTER_ARTIFACTconfiguration.SchemaResolverProperties.IfArtifactExistsgetAutoRegisterArtifactIfExists()Retrieves the behavior to use when auto-registering artifacts that might already exist.booleangetCacheLatest()Retrieves the cache latest property specified by theCACHE_LATESTconfiguration.DurationgetCacheTTL()Retrieves the cache time-to-live (TTL) duration specified by theCACHE_TTL_MSconfiguration in milliseconds.StringgetExplicitArtifactArtifactId()Retrieves theEXPLICIT_ARTIFACT_ARTIFACT_IDwhich is used to explicitly set the artifactId for querying an artifact in the registry.StringgetExplicitArtifactGroupId()Retrieves theEXPLICIT_ARTIFACT_GROUP_IDwhich is used to explicitly set the groupId for querying an artifact in the registry.StringgetExplicitArtifactVersion()Retrieves theEXPLICIT_ARTIFACT_VERSIONwhich is used to explicitly set the version for querying an artifact in the registry.StringgetRegistryUrl()Retrieves the URL of the Solace Schema Registry.DurationgetRequestAttemptBackoff()Retrieves the backoff time in milliseconds between retry attempts when communicating with the schema registry.longgetRequestAttempts()Retrieves the number of attempts to make when communicating with the schema registry before giving up.StringgetSchemaLocation()Gets the configured classpath resource path to the schema.SolaceTopicProfilegetStrategyTopicProfile()Retrieves theSolaceTopicProfileobject specified by theSTRATEGY_TOPIC_PROFILEconfiguration.StringgetTrustStorePassword()Gets the password for the trust store.StringgetTrustStorePath()Gets the path to the trust store file.booleangetUseCachedOnError()Retrieves the use cached on error property specified by theUSE_CACHED_ON_ERRORconfiguration.booleangetValidateCertificate()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 theArtifactReferenceResolverStrategyNote: If this property and the
FIND_LATEST_ARTIFACTare 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 aSolaceTopicProfileobject used by theSolaceTopicIdStrategyto map topics to artifact references. This property is used to configure the topic to artifact mapping.The value should be a
SolaceTopicProfileobject that defines the mapping rules between Solace topics and artifact references in the Schema Registry.When this property is null or unset, the
SolaceTopicIdStrategywill 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
Stringrepresenting 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_PATHis provided. It provides the password required to access the trust store. WhenTRUST_STORE_PATHis not set, this property will have no effect.The value should be a
Stringrepresenting 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
Booleanor aStringthat 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 implementsArtifactReferenceResolverStrategyThis 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
Stringrepresenting the fully qualified class name of a class implementing the ArtifactReferenceResolverStrategy interface - A
Classobject 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 anIllegalArgumentExceptionduring 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_ATTEMPTSare 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_ERRORthis 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_ARTIFACTwhen 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_ARTIFACTboolean 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_ARTIFACTboolean flag.
-
getExplicitArtifactVersion
public String getExplicitArtifactVersion()
Retrieves theEXPLICIT_ARTIFACT_VERSIONwhich 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_IDwhich 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_IDwhich 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_PATHkey 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_PATHis not a String.
-
getTrustStorePassword
public String getTrustStorePassword()
Gets the password for the trust store.This method retrieves the value associated with the
TRUST_STORE_PASSWORDkey 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_PASSWORDis not a String.
-
getValidateCertificate
public boolean getValidateCertificate()
Gets the certificate validation setting.This method retrieves the value associated with the
VALIDATE_CERTIFICATEkey 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_CERTIFICATEis 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_STRATEGYkey in the configuration can be:- A
Stringrepresenting the fully qualified class name of a class implementing the ArtifactReferenceResolverStrategy interface - A
Classobject of a class implementing the ArtifactReferenceResolverStrategy interface
- Returns:
- An ArtifactReferenceResolverStrategy instance.
- Throws:
IllegalStateException- if:- No ArtifactReferenceResolverStrategy is found for the
ARTIFACT_RESOLVER_STRATEGYkey - The class specified by the
ARTIFACT_RESOLVER_STRATEGYkey is not found - The object specified by the
ARTIFACT_RESOLVER_STRATEGYkey is neither a String, nor Class
- No ArtifactReferenceResolverStrategy is found for the
- See Also:
ArtifactReferenceResolverStrategy
- A
-
getStrategyTopicProfile
public SolaceTopicProfile getStrategyTopicProfile()
Retrieves theSolaceTopicProfileobject specified by theSTRATEGY_TOPIC_PROFILEconfiguration.This method attempts to retrieve the
SolaceTopicProfileobject from the configuration that was set using theSTRATEGY_TOPIC_PROFILEkey. TheSolaceTopicProfileis used by theSolaceTopicIdStrategyto map topics to artifact references.- Returns:
- The
SolaceTopicProfileobject if it was set in the configuration, or null if it wasn't set. - Throws:
IllegalStateException- if the value associated withSTRATEGY_TOPIC_PROFILEis neither null nor an instance ofSolaceTopicProfile.
-
getCacheTTL
public Duration getCacheTTL()
Retrieves the cache time-to-live (TTL) duration specified by theCACHE_TTL_MSconfiguration in milliseconds.This method attempts to retrieve and convert the cache TTL value from the configuration that was set using the
CACHE_TTL_MSkey. 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
Durationrepresenting the cache TTL in milliseconds. - Throws:
IllegalStateException- if the value associated withCACHE_TTL_MSis 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_LATESTconfiguration.This method attempts to retrieve the cache latest property from the configuration that was set using the
CACHE_LATESTkey. 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_LATESTcannot be parsed as a valid boolean.
-
getUseCachedOnError
public boolean getUseCachedOnError()
Retrieves the use cached on error property specified by theUSE_CACHED_ON_ERRORconfiguration.This method attempts to retrieve the use cached on error property from the configuration that was set using the
USE_CACHED_ON_ERRORkey. 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_ERRORcannot 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_ATTEMPTSkey in the configuration.- Returns:
- A long value representing the number of attempts to make.
- Throws:
IllegalStateException- if the value associated withREQUEST_ATTEMPTSis 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_MSkey. The backoff time determines the wait time between retry attempts when communicating with the schema registry.- Returns:
- A
Durationrepresenting the backoff time in milliseconds. - Throws:
IllegalStateException- if the value associated withREQUEST_ATTEMPT_BACKOFF_MSis 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_ARTIFACTconfiguration.This method retrieves the value associated with the
AUTO_REGISTER_ARTIFACTkey 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_ARTIFACTcannot 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_EXISTSkey in the configuration. This property controls how the system handles artifact registration when a similar artifact already exists in the registry.- Returns:
- The
SchemaResolverProperties.IfArtifactExistsstrategy 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
-
-