Skip to content

bcgov/jrcc-document-access-libs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

1172c3e · Jul 22, 2019
Jul 19, 2019
Jul 5, 2019
Jul 22, 2019
Jul 22, 2019
Jul 17, 2019
Jul 22, 2019
Jul 17, 2019
Jul 17, 2019
Jul 16, 2019
Jun 28, 2019
Jun 28, 2019
Jul 17, 2019
Jul 22, 2019

Repository files navigation

jrcc-document-access-libs

This library provides a service to store documents using redis cache.

Road Map

  • 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

jrcc document access spring boot starter

This provide a spring boot starter for the document access lib using redis

Usage

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

Plugins

Common Options

name definition required
bcgov.access.input.document-type String No
bcgov.access.input.plugin-type String Yes

bcgov.access.input.document-type

  • Value type is String
  • Default value is unknown

Sets the document type to be manipulated

bcgov.access.input.plugin-type

  • Value type is String

Sets the plugin type

Input Plugins

You can configure the document input using bcgov.access.input property.

Console Input Plugin

Description

Reads document form the standard input. Each document is assumed to be one line

Configuration

bcgov.access.input.plugin=console

Input Configuration Options

There are no special configuration options for this plugin, but it does support the Common Options.

Http Input Plugin

Description

Using this input you can receive a single document over http(s). For more details have a look at the document API.

Setup

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.

Configuration Options

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

RabbitMq Input Plugin

Description

Using this plugin you can receive messages from a spefied rabbitMq queue.

Setup

bcgov.access.input.plugin=rabbitmq

Configuration Options

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
bcgov.access.input.rabbitmq.retryDelay
  • 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.

bcgov.access.input.rabbitmq.retryCount
  • Value type is Int
  • Default value is 1

Sets the maximum attempt to reprocess a message in the queue.

Output Plugins

You can configure the document input using bcgov.access.output property.

Console Output Plugin

Description

A simple output wich pring document information to STDOUT. The console output is mostly used when testing the application configuration.

Setup

bcgov.access.output.plugin=console

Configuration Options

It support the [Common Options](#Common Options) and the following options:

name type required
bcgov.access.output.console.format String No
bcgov.access.output.console.format
  • 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

RabbitMq Output Plugin

Description

Push documents to a RabbitMq exchange and store document to Redis Cache.

Setup

bcgov.access.output.plugin=rabbitmq

Configuration Options

It support the [Common Options](#Common Options) and the following options:

name type required
bcgov.access.output.rabbitmq.ttl Int No
bcgov.access.output.rabbitmq.ttl
  • 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

References

Sample App

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

Postman config

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

binding

Release

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