AKTIN : Broker : Client Websocket

Broker websocket client library. This library can be used to keep a live connection to the broker and retrieve notifications for new queries.

License

License

Categories

Categories

CLI User Interface
GroupId

GroupId

org.aktin
ArtifactId

ArtifactId

broker-client-websocket
Last Version

Last Version

0.10
Release Date

Release Date

Type

Type

jar
Description

Description

AKTIN : Broker : Client Websocket
Broker websocket client library. This library can be used to keep a live connection to the broker and retrieve notifications for new queries.
Project Organization

Project Organization

Uniklinik RWTH Aachen

Download broker-client-websocket

How to add to project

<!-- https://jarcasting.com/artifacts/org.aktin/broker-client-websocket/ -->
<dependency>
    <groupId>org.aktin</groupId>
    <artifactId>broker-client-websocket</artifactId>
    <version>0.10</version>
</dependency>
// https://jarcasting.com/artifacts/org.aktin/broker-client-websocket/
implementation 'org.aktin:broker-client-websocket:0.10'
// https://jarcasting.com/artifacts/org.aktin/broker-client-websocket/
implementation ("org.aktin:broker-client-websocket:0.10")
'org.aktin:broker-client-websocket:jar:0.10'
<dependency org="org.aktin" name="broker-client-websocket" rev="0.10">
  <artifact name="broker-client-websocket" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.aktin', module='broker-client-websocket', version='0.10')
)
libraryDependencies += "org.aktin" % "broker-client-websocket" % "0.10"
[org.aktin/broker-client-websocket "0.10"]

Dependencies

compile (1)

Group / Artifact Type Version
org.java-websocket : Java-WebSocket jar 1.3.0

test (1)

Group / Artifact Type Version
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

AKTIN Broker

A content-agnostic data exchange middle-ware for federated data warehouses.

This software is not designed for standalone usage. Rather it is to be used within federated data warehouse environments like e.g. research networks or multi-center clinical study registries in conjunction with local workflows and processing infrastructure.

The broker infrastructure contains two main components: The central component broker-server is used to publish information to be distributed. The local component broker-client is used by multiple parties to retrieve the published information and subsequently report status updates and response-data.

The middleware infrastructure is content-agnostic in the sense that it can be used with any format or kind of data. A typical scenario is submitting a query for data extraction (e.g. SQL) to the broker (server) to be received by multiple clients which in turn process the query and return status/progress information and resulting extracted data. Other use cases include distribution of metadata/terminology and processing of material transfer requests.

As all communication is based on RESTful HTTP endpoints, the broker-client is optional and can be replaced with simple HTTP calls.

Example for a typical scenario:

Analyst          Broker-Server        Broker-Client-1        Broker-Client-2      ....

submit query --->   publish query
                        |
                        |    <-----     ask for queries
                        |                    |
                        |    ----->     receive new query
                        |                    |
                        |    <-----     report status
                        |                    | (internal workflow 
                        |                    | and query execution)
                        |    <-----     report results
                        |
                (collect responses)
                        |
get status update <---  |
                        |
                        |
                        |    <-----------------------------     ask for queries
                        |                                            |
                        |    ----------------------------->     receive new query
                        |                                            |
                        |    <-----------------------------     report status
                        |                                            | (internal workflow 
                        |                                            | and query execution)
                        |    <-----------------------------     report results
                        |
retrieve results <---   |

Getting started

The easiest way to use the software is to download and run the pre-build binary distribution of broker-admin-dist.

Running the broker

To run the central broker component, first unpack the binary distribution broker-admin-dist-1.x.zip. For running the application, you need a Java 8 runtime environment or newer. We recommend to use the latest OpenJDK version (currently OpenJDK 15). Open a command shell in the extracted folder and run the script run_broker.sh for Linux/MingW/GitBash or run_broker.bat for Windows respectively. To change startup options (e.g port), edit the startup script.

Building from source code

To build the project from its source code, you need a Java runtime environment (e.g. OpenJDK 15, minimum is Java 8) and the build-tool Apache Maven. To build the project, download/clone the repository source code and run mvn clean install via command shell in the main directory. After the build process is completed, you can find the broker binary distribution in the subfolder broker-admin-dist/target. To run the broker, see section Getting startet above.

Examples for using the broker

Below, you will find examples for typical use cases. For accessing the broker from Java/JRE-Applications, you can use the broker-client dependency (https://mvnrepository.com/artifact/org.aktin/broker-client) which communicates with the broker via HTTP. To demonstrate the simplicity of the RESTful API, the command line tool curl is used in the following examples for direct HTTP communication.

Submitting a request to the broker

This example performs authentication at the broker and creates a request containing query syntax which is to be distributed to all nodes.

# Admin authentication and store token in shell variable
TOKEN=`curl -s -H "Content-Type: application/xml" -X POST \
    -d '<credentials><username>admin</username><password>CHANGEME</password></credentials>' \
    http://localhost:8080/auth/login`

# Create a file containing the query syntax
echo "SELECT * FROM fhir_observation" > query1.sql

# submit the query
curl -i -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/sql" -X POST \
     -d @query1.sql http://localhost:8080/broker/request

# the response will contain a Location header for the newly created request. 
# We will use this location below to publish the request
curl -si -H "Authorization: Bearer $TOKEN" -X POST http://localhost:8080/broker/request/1/publish

Documentation on the RESTful API of the request administration endpoint can be found in RequestAdminEndpoint.java

Retrieving a request at the client side

In this example, the client will authenticate via API-key and receives the published request.

# list available requests
curl -is -H "Authorization: Bearer xxxApiKey123" http://localhost:8080/broker/my/request

# retrieve first request
curl -is -H "Authorization: Bearer xxxApiKey123" http://localhost:8080/broker/my/request/1

# update status to retrieved
curl -is -H "Authorization: Bearer xxxApiKey123" -X POST \
     http://localhost:8080/broker/my/request/1/status/retrieved

Supplying results to a request from the client side

This example demonstrates, how the client can supply arbitrary data as a result to a request.

# Create a file containing the query results
echo -e "a;b\n1;2\n3;4\n" > result1.csv

# submit the file contents
curl -i -H "Authorization: Bearer xxxApiKey123" -H "Content-Type: text/csv" -X PUT \
     -d @result1.csv http://localhost:8080/aggregator/my/request/1/result

# update status to completed
curl -is -H "Authorization: Bearer xxxApiKey123" -X POST \
     http://localhost:8080/broker/my/request/1/status/completed

Updating the client status for a request

A different client may also reject a query. (Note the different API-key to indicate a different client)

curl -is -H "Authorization: Bearer xxxApiKey567" -X POST \
     http://localhost:8080/broker/my/request/1/status/rejected

Possible request states are documented in broker-api/RequestStatus

Download the collection of results for a query

Once one or more clients have responded to a request e.g. by supplying result data, the submitter can retrieve the results either via individual REST calls or more conveniently via ZIP bundle:

# assuming authentication was already done (see first example)
# retrieve a download ID for the bundle containing all results and status updates
BUNDLE_ID=`curl -s -H "Authorization: Bearer $TOKEN"  http://localhost:8080/broker/export/request-bundle/1`

# download the results bundle
curl -s -H "Authorization: Bearer $TOKEN" --output results.zip \
     http://localhost:8080/broker/download/$BUNDLE_ID 

Using the web frontend

The broker includes a minimal web frontent, which can be used to view the status of connected nodes, manage requests and responses and download results. This frontent serves only as a built-in minimal user interface - for a better user experience, external customized frontents should be used.

To access the frontend, go to http://localhost:8080/admin/html/index.html once the broker is running. For login, use the username admin. The admin password is specified in the startup script and defaults to CHANGEME.

Using the broker-client library

To use broker functionality in java client applications, you can use the broker-client dependency (https://mvnrepository.com/artifact/org.aktin/broker-client). For a code example on how to use the client, see the following implementations:

org.aktin

AKTIN

The AKTIN Software provides a distributed and federated clinical data repository / data warehouse infrastructure. Researchers use it to share and access data.

Versions

Version
0.10
0.9
0.8
0.7
0.5
0.4
0.3
0.2
0.1