Spring Boot Sophora Commons is a convenient way to configure the connection to a Sophora Server in a Spring Boot project. Additional functionalty includes a health indicator for the server connection and metrics for the document cache.
Installation
First, add the following dependency to your pom.xml
:
<dependency>
<groupId>com.subshell.sophora</groupId>
<artifactId>spring-boot-sophora-commons</artifactId>
<version>${spring-boot-sophora-commons.version}</version>
</dependency>
Then, you need to configure your project's @SpringBootApplication
component scan to include the package com.subshell.sophora.springbootsophoracommons
. Don't forget to add your project's package to the list, otherwise Spring won't scan it:
@SpringBootApplication(
scanBasePackages = {"<package of current project>", "com.subshell.sophora.springbootsophoracommons"}
)
public class MySpringBootApplication {
// ...
Configuration of the Server Connection
Common configuration properties to connect to a Sophora Server
Property | Description | Default |
---|---|---|
sophora.client.server-connection.urls | Defines the connection url to the Sophora Server. It is also possible to define a list of connection urls. This is especially useful in conjunction with the property sophora.client.server-connection.noOtherHosts . | - |
sophora.client.server-connection.url | This configuration option is deprecated and will be removed from version 5. Please use sophora.client.server-connection.urls instead | |
sophora.client.server-connection.username | Sophora username | - |
sophora.client.server-connection.password | The password of the Sophora user | - |
sophora.client.server-connection.accessToken | Defines an accesstoken for a sessionless connection. Please refer the Sophora Cloud Delivery documentation for further information. | - |
sophora.client.server-connection.sessionless | Defines whether it is a sessionless connection or not. Please refer the Sophora Cloud Delivery documentation for further information. | false |
sophora.client.server-connection.noOtherHosts | Defines whether a connection to another known server should be tried if the defined Sophroa Server is not reachable. If the value is set to true, an attempt is made to reach one of the configured servers. | false |
sophora.client.server-connection.deferLogin | Whether the client should login in automatically. If set to true, the method com.subshell.sophora.client.ISophoraClient#login() must be called manuelly. | false |
sophora.client.server-connection.retries | Specifies the number of connection retries the Sophora Client will attempt, when connecting to the server fails. | 3 |
sophora.client.server-connection.retryInterval | Specifies the interval in seconds between connection retries to the server. | 5 |
sophora.client.server-connection.reconnectOnNonMatchingAPI | If set to false this client will not reconnect to the Sophora server if the API versions of the server and client are potentially incompatible. | true |
sophora.client.server-connection.useMigrationMode | The use of the migration mode is discouraged and should at most be used in migration scenarios. | false |
sophora.client.server-connection.internal | Enforces the use of the internal connection data. By default the external connection data are used, if available. Please refer the configuration properties sophora.remote.api.external.* of the Sophora Server for further information about the external connection data. | false |
sophora.client.server-connection.readTimeout | Sets the request timeout when communicating with the server in milliseconds. Use this setting if you are experiencing read timeouts. | 300000 (5 minutes) |
Proxy Configuration
Configuration of a proxy that is used to connect to the Sophora Server
Property | Description | Default |
---|---|---|
sophora.client.proxy.host | Hostname of the proxy | - |
sophora.client.proxy.port | Port of the proxy | - |
sophora.client.proxy.username | Username for authentication to the proxy | - |
sophora.client.proxy.password | Password for the username | - |
sophora.client.proxy.socksHost | Defines the host of a Socks proxy | - |
sophora.client.proxy.socksPort | Defines the port of a Socks proxy | - |
Cache Configuration
Property | Description | Default |
---|---|---|
sophora.client.cache.cacheDir | Absolute path to the cache directory. Can be used to define the directory in which the document cache will store its data. Will use an EhCache to cache the data per default. Should not be used if multiple SophoraClients will run in the same JVM. This has no effect if any of the documentCacheElementsInMemory options has been activated as these will result in a different cache implementation. | - |
sophora.client.cache.thumbnailCacheSize | The total number of thumbnails cached by this client.. | 100 |
sophora.client.cache.documentCacheElementsInMemory | The number of documents to be cached in memory. | 50 |
sophora.client.cache.publishedDocumentCacheElementsInMemory | The number of published documents to be cached. | 50 |
sophora.client.cache.useDocumentCacheOverflowToDisk | Defines whether the cache should be persisted on disk. | false |
sophora.client.cache.fireDocumentChangedEventForInheritedPropertiesChanges | Defines whether DocumentChangedEvents should be broadcasted for changes of inherited properties. | false |
Binary Data
Property | Description | Default |
---|---|---|
sophora.client.binary-data.binaryDataCacheMimeTypeBlacklist | Per default, all binary data is cached. Specifies a list of mime types that should not be cached by the client. | - |
sophora.client.binary-data.binaryDataCacheMaximumSizeInBytes | Sets the maximum in-memory size of the overall binary data cache (not per entry) in bytes. | 128000000 |
Miscellaneous
Summarizes various configuration options
Property | Description | Default |
---|---|---|
sophora.client.misc.dataDir | Absolute path to the data directory of the Sophora Info Dao. | - |
sophora.client.misc.locale | Sets the locale of the SophoraClient. Uses the ISO 639 alpha-2 or alpha-3 language code. | de |
sophora.client.misc.jmxName | Configures the name with which the SophoraClient will be presented via JMX. | - |
sophora.client.misc.updateInterval | Sets the update interval in milliseconds in which the client will fetch events from the Sophora server. | 3000 |
sophora.client.misc.forceSlaveConnection | When true this client can log in to replica servers without being redirected to the primary server. When used to modify documents this will lead to differences between the Sophora servers that will not be synchronized between each other. Use carefully. | false |
sophora.client.misc.useACS | Enables this client to use an additional content server, if enabled in the cluster. | false |
sophora.client.misc.useReadAnywhere | Defines whether this client should also read content from appropriate replica server. | false |
sophora.client.misc.listeningToDerivedDocumentChanges | Defines whether the client should listen to com.subshell.sophora.api.event.DerivedDocumentChangedEvents. As of version 5 DerivedDocumentChangedEvent are always broadcasted, this configuration option is depreacted and will be removed from version 5. |
Configuration of the ToolInfo
Property | Description | Default |
---|---|---|
sophora.client.toolInfo.enabled | If enabled, the application will be registered as a tool. | false |
sophora.client.toolInfo.name | The name of the tool | Defaults to the application name or the artifact id. |
sophora.client.toolInfo.hostname | The hostname of the tool | - |
sophora.client.toolInfo.httpPort | The HTTP port of the tool | - |
sophora.client.toolInfo.httpsPort | The HTTPs port of the tool | - |
sophora.client.toolInfo.jolokiaPath | URL path to the jolokia API of the tool | - |
sophora.client.toolInfo.additionalInfo | Additional tool info as key-value pairs. | - |
Sophora tools may be present in the list of tools within the Sophora Dashboard. There is also an HTTP endpoint in the Content-API, which lists the currently connected tools in a JSON representation.
Sophora Health Indicator
To enable an endpoint showing the client's status (e.g. the server(s) the client is connected to, along with some additional information), edit your application.yaml
as follows:
management:
endpoints:
web:
exposure:
include: sophora, ...
Metrics
Spring Boot Sophora Commons exports metrics for the document cache, if the default cache implementation is used. The following metrics are available:
- sophora_client_cache_documents_hitCount
- sophora_client_cache_documents_missCount
- sophora_client_cache_documents_getCount
- sophora_client_cache_documents_objectCount
- sophora_client_cache_sophoraIds_hitCount
- sophora_client_cache_sophoraIds_missCount
- sophora_client_cache_sophoraIds_getCount
- sophora_client_cache_sophoraIds_objectCount
- sophora_client_cache_externalIds_hitCount
- sophora_client_cache_externalIds_missCount
- sophora_client_cache_externalIds_getCount
- sophora_client_cache_externalIds_objectCount