项目作者: jether2011

项目描述 :
Springboot JMS
高级语言: Java
项目地址: git://github.com/jether2011/springboot-jms.git
创建时间: 2019-01-24T22:57:04Z
项目社区:https://github.com/jether2011/springboot-jms

开源协议:

下载


Springboot - JMS

This application uses:

  1. SpringBoot 2
  2. ReactiveMongo
  3. JmsTemplate (ActiveMQ)
  4. Mongo ATLAS (Mongo cluster on cloud)

Image to illustrate the app:

Spring boot 2 + JMS

App URL

Resources: acquisition, instrument

API access at: https://jms-jr.herokuapp.com/api/v1/[resources]

Swagger access at: https://jms-jr.herokuapp.com/swagger-ui.html

Swagger Doc access at: https://jms-jr.herokuapp.com/v2/api-docs

Endpoints

Resources (examples to use and test):

POST

Instruments

  1. {
  2. "name":"SJC Pluviometer Station",
  3. "code":"JR2019"
  4. }
JS
  1. var settings = {
  2. "async": true,
  3. "crossDomain": true,
  4. "url": "https://jms-jr.herokuapp.com/api/v1/instrument",
  5. "method": "POST",
  6. "headers": {
  7. "content-type": "application/json",
  8. "cache-control": "no-cache",
  9. "postman-token": "60e655ce-5e78-fc42-7355-eb8bb58df893"
  10. },
  11. "processData": false,
  12. "data": "{\n\t\"name\":\"SJC Pluviometer Station\",\n\t\"code\":\"JR2019\"\n}"
  13. }
  14. $.ajax(settings).done(function (response) {
  15. console.log(response);
  16. });
CURL
  1. curl -X POST \
  2. https://jms-jr.herokuapp.com/api/v1/instrument \
  3. -H 'cache-control: no-cache' \
  4. -H 'content-type: application/json' \
  5. -H 'postman-token: c9108a7a-402b-9879-0a51-310a8e1d1e79' \
  6. -d '{
  7. "name":"SJC Pluviometer Station",
  8. "code":"JR2019"
  9. }'
NODE Unirest
  1. var unirest = require("unirest");
  2. var req = unirest("POST", "https://jms-jr.herokuapp.com/api/v1/instrument");
  3. req.headers({
  4. "postman-token": "0e6621d4-e455-4400-4230-035a7f3acc10",
  5. "cache-control": "no-cache",
  6. "content-type": "application/json"
  7. });
  8. req.type("json");
  9. req.send({
  10. "name": "SJC Pluviometer Station",
  11. "code": "JR2019"
  12. });
  13. req.end(function (res) {
  14. if (res.error) throw new Error(res.error);
  15. console.log(res.body);
  16. });
JAVA Unirest
  1. HttpResponse<String> response = Unirest.post("https://jms-jr.herokuapp.com/api/v1/instrument")
  2. .header("content-type", "application/json")
  3. .header("cache-control", "no-cache")
  4. .header("postman-token", "f3ad9ac4-2fb0-9cc3-8075-d2724ce2ddd5")
  5. .body("{\n\t\"name\":\"SJC Pluviometer Station\",\n\t\"code\":\"JR2019\"\n}")
  6. .asString();

Acquisitions

The acquisition endpoint serialize the arrived object and post into a acquisition Queue and the consumer consume this object and save into database.

  1. {
  2. "value": 0.12,
  3. "instrument": {
  4. "id": "5c4f1a50c4060226a6e93c92"
  5. }
  6. }
JS
  1. var settings = {
  2. "async": true,
  3. "crossDomain": true,
  4. "url": "https://jms-jr.herokuapp.com/api/v1/acquisition",
  5. "method": "POST",
  6. "headers": {
  7. "content-type": "application/json",
  8. "cache-control": "no-cache",
  9. },
  10. "processData": false,
  11. "data": "{\n\t\"value\": 0.12,\n\t\"instrument\": {\n\t\t\"id\": \"5c4f1a50c4060226a6e93c92\"\n\t}\n}\n"
  12. }
  13. $.ajax(settings).done(function (response) {
  14. console.log(response);
  15. });
CURL
  1. curl -X POST \
  2. https://jms-jr.herokuapp.com/api/v1/acquisition \
  3. -H 'cache-control: no-cache' \
  4. -H 'content-type: application/json' \
  5. -H 'postman-token: a639058b-2efc-0e4d-fd56-4bd1e73f2042' \
  6. -d '{
  7. "value": 0.12,
  8. "instrument": {
  9. "id": "5c4f1a50c4060226a6e93c92"
  10. }
  11. }
  12. '
NODE Unirest
  1. var unirest = require("unirest");
  2. var req = unirest("POST", "https://jms-jr.herokuapp.com/api/v1/acquisition");
  3. req.headers({
  4. "cache-control": "no-cache",
  5. "content-type": "application/json"
  6. });
  7. req.type("json");
  8. req.send({
  9. "value": 0.12,
  10. "instrument": {
  11. "id": "5c4f1a50c4060226a6e93c92"
  12. }
  13. });
  14. req.end(function (res) {
  15. if (res.error) throw new Error(res.error);
  16. console.log(res.body);
  17. });
JAVA Unirest
  1. HttpResponse<String> response = Unirest.post("https://jms-jr.herokuapp.com/api/v1/acquisition")
  2. .header("content-type", "application/json")
  3. .header("cache-control", "no-cache")
  4. .body("{\n\t\"value\": 0.12,\n\t\"instrument\": {\n\t\t\"id\": \"5c4f1a50c4060226a6e93c92\"\n\t}\n}\n")
  5. .asString();

GET

Instruments

  1. var settings = {
  2. "async": true,
  3. "crossDomain": true,
  4. "url": "https://jms-jr.herokuapp.com/api/v1/instrument/all",
  5. "method": "GET",
  6. "headers": {
  7. "cache-control": "no-cache",
  8. }
  9. }
  10. $.ajax(settings).done(function (response) {
  11. console.log(response);
  12. });
  1. HttpResponse<String> response = Unirest.get("https://jms-jr.herokuapp.com/api/v1/instrument/all")
  2. .header("cache-control", "no-cache")
  3. .asString();
  1. [
  2. {
  3. "id": "5c4f1a50c4060226a6e93c92",
  4. "name": "SJC Pluviometer Station",
  5. "code": "JR2019",
  6. "created": "2019-01-28 13:05:52"
  7. }
  8. ]

Acquisitions

  1. var settings = {
  2. "async": true,
  3. "crossDomain": true,
  4. "url": "https://jms-jr.herokuapp.com/api/v1/acquisition/all",
  5. "method": "GET",
  6. "headers": {
  7. "cache-control": "no-cache",
  8. }
  9. }
  10. $.ajax(settings).done(function (response) {
  11. console.log(response);
  12. });
  1. HttpResponse<String> response = Unirest.get("https://jms-jr.herokuapp.com/api/v1/acquisition/all")
  2. .header("cache-control", "no-cache")
  3. .asString();
  1. [
  2. {
  3. "id": "5c4f26f0c4060226a6e93c9c",
  4. "value": 0.12,
  5. "created": "2019-01-28 13:59:44",
  6. "instrument": {
  7. "id": "5c4f1a50c4060226a6e93c92",
  8. "name": "SJC Pluviometer Station",
  9. "code": "JR2019",
  10. "created": "2019-01-28 13:05:52"
  11. }
  12. },
  13. {
  14. "id": "5c4f270bc4060226a6e93c9d",
  15. "value": 0.12,
  16. "created": "2019-01-28 14:00:11",
  17. "instrument": {
  18. "id": "5c4f1a50c4060226a6e93c92",
  19. "name": "SJC Pluviometer Station",
  20. "code": "JR2019",
  21. "created": "2019-01-28 13:05:52"
  22. }
  23. }
  24. ]