Common modules¶
Config¶
Spring Cloud Configuration service is provided.
Run the service in command line in folder jws/jws-config/
jws-config-service.exe --install
jws-config-service.exe --start (on Windows in administrator's terminal)
jws-config-service start(on Linux)
or
run-jws-config.exe (on Windows)
run-jws-config(on Linux)
**Default configuration **
| common-config/application.properties | |
|---|---|
| ## You can set all settings here for all applications | |
| eureka.client.serviceUrl.defaultZone=${EUREKA_URI:http://localhost:8761}/eureka/ eureka.client.enabled=true spring.servlet.multipart.max-file-size=150MB spring.servlet.multipart.max-request-size=150MB |
|
| ##LOG config: logging.level.root=${CXN_ROOT_LOG_LEVEL:INFO} logging.level.com.chemaxon.webservices.license=${LICENSE_LOG_LEVEL:INFO} |
|
| ##Communication settings of gateway: spring.cloud.gateway.server.webflux.httpclient.response-timeout=25000 spring.cloud.gateway.server.webflux.httpclient.connect-timeout=3000 spring.cloud.gateway.server.webflux.httpclient.pool.type=fixed spring.cloud.gateway.server.webflux.httpclient.pool.max-connections=100 spring.cloud.gateway.server.webflux.httpclient.pool.acquire-timeout=5000 |
You can set up timeout in JChem MicroServices. We use the Spring Cloud Gateway for it. These properties control when to interrupt waiting for an answer between Chemaxon services. There is also option to set maximum active connections and timeout limit for waiting when maximum connection limit is reached. |
| ##DB config: initOnStart=${DB_INIT_ON_START:AUTO} updateMode=${DB_UPDATE_MODE:EXIT} chemaxon.microservices.db.datasource.h2.dir=${CXN_STRUCTURE_DATA_DIR:./data/chemical-data/store} chemaxon.microservices.db.datasource.dialect=${CXN_DB_DIALECT:H2} chemaxon.microservices.db.datasource.url=${CXN_DB_JDBC_URL:jdbc:h2:nio:${chemaxon.microservices.db.datasource.h2.dir}/db;COMPRESS=true; chemaxon.microservices.db.datasource.username=${CXN_DB_JDBC_USER:user} chemaxon.microservices.db.datasource.password=${CXN_DB_JDBC_PASSWORD:password} chemaxon.microservices.db.import-export.dir=${CXN_DB_IMPORT_EXPORT_DIR:data/export} chemaxon.microservices.db.import-export.import-batch-size=${CXN_DB_IMPORT_EXPORT_BATCH_SIZE:5000} chemaxon.microservices.db.types[0].type-name=sample chemaxon.microservices.db.types[0].type-id=1 chemaxon.microservices.db.types[0].tautomer-handling-mode=OFF chemaxon.microservices.db.types[0].stereo-assumption=ABSOLUTE chemaxon.microservices.db.types[0].standardizer-config=aromatize chemaxon.microservices.db.types[1].type-name=taumol chemaxon.microservices.db.types[1].type-id=2 chemaxon.microservices.db.types[1].tautomer-handling-mode=GENERIC chemaxon.microservices.db.types[1].stereo-assumption=ABSOLUTE chemaxon.microservices.db.types[1].standardizer-config=aromatize |
If DB Web Services are run as part of a microservices system, specify here its configuration parameters. If DB Web Services are run as standalone web application, specify its configurations in its own module's application.properties file. See explanations here |
Configuration using table instead of the common-config/application.properties file How to use JWS-CONFIG with JDBC backend.¶
- Copy the right JDBC driver to 'extra-libs' folder.
- In jws-config/config/application.properties set the followings:
more on Spring data source settings: https://docs.spring.io/spring-boot/docs/current/reference/html/appendix-application-properties.html#data-properties
This setting will only work if you have a table, called: PROPERTIES with this 5 text fields (these fields can be any text fields):
- APPLICATION
- PROFILE
- LABEL
- KEY
- VALUE
example properties table creation SQL:
It is possible to use a different table than properties. In this case you have to set the QUERY to get key-value pairs, like:
What are the defaults in the example SQL?
Spring Cloud Config is designed to provide properties from git repositories. This database schema mimics that. In the git repository all application can have their own settings in their application_name.properties file, or common properties can be in application.properties file. The default value 'application' in the APPLICATION column means it is "found" in application.properties file so it is distributed to all applications.
Every properties file can be linked to a specific profile, like: production, development, aws, etc. and their settings are only taken into account if their profile is active. The default value 'default' in PROFILE column means this setting is not paired to any specific profile name, but to the default profile.
Since in the original concept the configuration distribution is solved by git repositories, all files are also part of a git branch. The branch currently checked out is represented in the LABEL column, with default value 'master' it is mimicking to be part of the master branch. Here basically any value different from NULL is acceptable.
In the KEY column the keys should be set with the Properties syntax, so a simple property, like:
should be a.b.c
so for
**{yml} **
users:
it is also transleted to a.b.c;
Example with lists:
properties:
yml:
would translate to this insert sql (if the defaults are as in the example table creation SQL):
| **config/application.properties ** |
|---|
| server.port=8888 logging.file.name=../logs/jws-config.log eureka.client.enabled=true spring.profiles.active=native spring.cloud.config.server.native.searchLocations=./common-config |
| config/bootstrap.properties |
|---|
Discovery¶
Eureka, the Netflix Service Discovery Server and Client is provided.
Run the service in command line in folder jws/jws-discovery/ :
jws-discovery-service.exe --install
jws-discovery-service.exe --start (on Windows in administrator's terminal)
jws-discovery-service start (on Linux)
or
run-jws-discovery.exe (on Windows)
run-jws-discovery(on Linux)
**Default configuration **
| **config/application.properties ** |
|---|
| server.port=8761 logging.file.name=../logs/jws-disocvery.log spring.config.import=optional:configserver:${CONFIG_SERVER_URI:http://localhost:8888} #Added in version 22.6.0. |
| config/bootstrap.properties |
|---|
| spring.cloud.config.failFast=true #Removed in version 22.6.0. spring.cloud.config.uri=${CONFIG_SERVER_URI:http://localhost:8888/} #Removed in version 22.6.0. spring.cloud.config.retry.initialInterval=3000 #Removed in version 22.6.0. spring.cloud.config.retry.multiplier=1.2 #Removed in version 22.6.0. spring.cloud.config.retry.maxInterval=60000 #Removed in version 22.6.0. spring.cloud.config.retry.maxAttempts=100 #Removed in version 22.6.0. |
Gateway¶
Spring Cloud Gateway is provided.
Run the service in command line in folder jws/jws-gateway/ :
jws-gateway-service.exe --install
jws-gateway-service.exe --start (on Windows in administrator's terminal)
jws-gateway-service start (on Linux)
or
run-jws-gateway.exe (on Windows)
run-jws- gateway(on Linux)
**Default configuration: **
| **config/application.properties ** |
|---|
| server.port=8080 logging.file.name=../logs/jws-gateway.log eureka.client.enabled=true spring.config.import=optional:configserver:${CONFIG_SERVER_URI:http://localhost:8888} #Added in version 22.6.0. |
| config/bootstrap.properties |
|---|
| spring.cloud.config.failFast=true #Removed in version 22.6.0. spring.cloud.config.uri=${CONFIG_SERVER_URI:http://localhost:8888/} #Removed in version 22.6.0 spring.cloud.config.retry.initialInterval=3000 #Removed in version 22.6.0. spring.cloud.config.retry.multiplier=1.2 #Removed in version 22.6.0. spring.cloud.config.retry.maxInterval=60000 #Removed in version 22.6.0. spring.cloud.config.retry.maxAttempts=100 #Removed in version 22.6.0. |
Allow CORS in Gateway¶
CORS is allowed by default for all origin but can be restricted in Gateway by below properties:
| **config/application.properties ** |
|---|
| management.endpoints.web.cors.allowed-origins=* #Removed in version 22.6.0 management.endpoints.web.cors.allowed-origin-patterns=* #Added in version 22.6.0 management.endpoints.web.cors.allowed-headers=* management.endpoints.web.cors.allowed-methods=* management.endpoints.web.cors.allow-credentials=true |
Message limitations in Gateway¶
You can set Gateway's maximum memory as any Java process in the appropriate .vmoptions file. (If you execute the service with jws-gateway-servcie, then use jws-gateway-service.vmoptions; if you execute the service with run-jws-gateway, then use run-jws-gateway.vmoptions.) The default setting is -Xmx256m, which means maximum 256 MB memory.
To protect Gateway from overloading its memory, we have introduced a filter to reject every message where Content-Length header is greater than ⅓ of the available maximum memory. With default memory settings this will lead you to reject every request with body greater than 85 MB.
You can also specify directly how many bytes do you allow in a request. For this set gateway.max-message-size=<number_of_bytes_to_allow> to the number of bytes you want to allow in a request. (Set this as any other property in Config server.)
If a request is too large, then a HTTP 413 error will be returned by the Gateway server.