This library provides a service to store documents using redis cache.
- Store a document in redis cache
- Retrieve document from redis cache
- Publish a document ready message to rabbitMq
- Subscribe when a document is ready from rabbitMq
This provide a spring boot starter for the document access lib using redis
Add jrcc-access-spring-boot-starter
to your project
<dependency>
<groupId>ca.gov.bc.open</groupId>
<artifactId>jrcc-access-spring-boot-starter</artifactId>
<version>0.3.3</version>
</dependency>
Add settings into application.settings
file using the following configuration guide
name | definition | required |
---|---|---|
bcgov.access.input.document-type | String | No |
bcgov.access.input.plugin-type | String | Yes |
- Value type is String
- Default value is
unknown
Sets the document type to be manipulated
- Value type is String
Sets the plugin type
You can configure the document input using bcgov.access.input
property.
Reads document form the standard input. Each document is assumed to be one line
bcgov.access.input.plugin=console
There are no special configuration options for this plugin, but it does support the Common Options.
Using this input you can receive a single document over http(s). For more details have a look at the document API.
bcgov.access.input.plugin=http
You can configure the webserver using standard spring configuration. Document sent to the api are handle with the default documentReadyHandler.
There are no special configuration options for this plugin, but it does support the Common Options and spring standard EMBEDDED SERVER CONFIGURATION (ServerProperties). Common Application Properties
exemple to run the service on port 5050
server.port=5050
Using this plugin you can receive messages from a spefied rabbitMq queue.
bcgov.access.input.plugin=rabbitmq
It support the Common Options and the following options:
name | type | required |
---|---|---|
bcgov.access.input.rabbitmq.retryDelay | Int | No |
bcgov.access.input.rabbitmq.retryCount | Int | No |
- Value type is Int
- Default value is
0
Sets the delay between retries when the service if failing to process the message and throwing application known errors.
- Value type is Int
- Default value is
1
Sets the maximum attempt to reprocess a message in the queue.
You can configure the document input using bcgov.access.output
property.
A simple output wich pring document information to STDOUT. The console output is mostly used when testing the application configuration.
bcgov.access.output.plugin=console
It support the [Common Options](#Common Options) and the following options:
name | type | required |
---|---|---|
bcgov.access.output.console.format | String | No |
- Value type is String
- Default value is
default
- Value can be any of
default
,xml
When set to default
the output is truncated to 100 chars.
When set to xml
the plugins tries to prettify the xml document or return the content of the document
bcgov.access.output.console.format=xml
Push documents to a RabbitMq exchange and store document to Redis Cache.
bcgov.access.output.plugin=rabbitmq
It support the [Common Options](#Common Options) and the following options:
name | type | required |
---|---|---|
bcgov.access.output.rabbitmq.ttl | Int | No |
- Value type is Int
- Default value is
1
Sets the time to live for document in the temporary storage (expressed in hours)
bcgov.access.output.rabbitmq.ttl
The sample app is a demo that shows the usage of jrcc-access-spring-boot-starter
Install jrcc-access-libs
Run the make.bat
file
Run the sample
mvn clean install -P sample-app
mvn spring-boot:run -f jrcc-access-spring-boot-sample-app/pom.xml
This app is configure to receive document using the http plugin.
you can use this Postman collection to interact with the server.
For body, select binary and click select file
set the http header to Content-Type:application/octet-stream
if you want to run the sample app using redis and rabbitmq do the following
Create a redis container
docker run --name some-redis -p 6379:6379 -d redis
Create a rabit container
docker run -d --hostname some-rabbit --name some-rabbit -p 15672:15672 -p 5672:5672 rabbitmq:3-management
update the application.yml
bcgov:
access:
input: http
output:
document-type: test-doc
plugin: rabbitmq
rabbitmq:
ttl: 1
logging:
level:
ca:
gov:
bc: DEBUG
To view the message in a queue, login to rabbitmq management console with default guest/guest and create a binding to the document.ready
exchange using test-doc
routing key
To create a new release run on develop branch
mvn versions:set -DartifactId=* -DgroupId=*
it will prompt you for the new version
do a pull request against dev