RestFire is service which reliably makes async rest calls to given end point.
- Sending Sms Reliably.
- Sending Emails
- Making POST call to end service
- Event flow across services.
- Dropwizard
- Mongo
- [BigQueue] (https://github.com/bulldog2011/bigqueue)
- Rest end point accepts request with body and method POST,GET or PUT
- It persist request in bigqueu.
- Configurable number of threads pickup task and make rest call to end point.
- On 4XX it sidelines it to Mongo immediately.
- On 5XX it persist it back to Bigqueue and retries for given amount of time.
- Build image :
docker build -t restfire .
- Running docker image :
docker run -e "JAVA_PROCESS_MIN_HEAP=2g" -e "JAVA_PROCESS_MAX_HEAP=2g" -e "BIGQUEUE_PATH=/data" -e "DROP_MESSAGE_POST_MINUTES=5" -e "MONGO_HOST=flo-mongo-0.opinio.5673.mongodbdns.com" -e "MONGO_PORT=27000" -p 18000:18000 -v /data:/data <image-id>
1. POST Single Document : POST /v1/documents Header : Content-Type:application/json JsonFields :
- url : End point URL
- methodType : POST/PUT/GET
- headers : Headers for end point.
- body : Body to payload for end point.
Example Payload :
{ "url": "http://localhost:1221/api/orders",
"methodType": "POST",
"headers": [{
"key": "Content-Type",
"value": "application/json"
}, {
"key": "Authorization",
"value": "<TOKEN>"
}],
"body": {
"customerName": "Swapnil Marghade",
"orderId": "1234",
"details": {
"name": "sourceName 1",
"phone": "1222121"
}
}
}
2. POST multiple documents : POST /v1/documents/bulk
Header : Content-Type:application/json
Example Payload :
[
{ "url": "http://localhost:1221/api/orders",
"methodType": "POST",
"headers": [{
"key": "Content-Type",
"value": "application/json"
}, {
"key": "Authorization",
"value": "<TOKEN>"
}],
"body": {
"customerName": "Swapnil Marghade",
"orderId": "1234",
"details": {
"name": "sourceName 1",
"phone": "1222121"
}
}
}
]
3. GET Sidelined documents GET /v1/documents Query Params
- fromTime : Enqueue from time (in Millis)
- toTime : Enqueue to time (in Millis)
- id : Id of document
- methodType : POST/PUT/GET
Response
[{
"id": "611e5fc1-6bc7-4121-9d88-b89441b5a55b",
"enqueueTimestamp": 1467799512052,
"lastRetryTimestamp": 1468412992617,
"totalRetry": 60,
"url": "http://localhost:3000/v1/orders/23",
"methodType": "PUT",
"headers": [{
"key": "Content-Type",
"value": "application/json"
}],
"body": {
"status": "created"
},
"statusCode": 400,
"responseMessage": "Http : Something went wrong, status code is 400 With response : {\"statusCode\":400,\"error\":\"Bad Request\",\"message\":\"Cannot read property 'customerId' of null\",\"details\":null}"
}]
4. POST Replay sidelined document POST /v1/documents/replay
Header : Content-Type:application/json
JsonFields :
- fromTime : Enqueue from time (in Millis)
- toTime : Enqueue to time (in Millis)
- ids : List of sidelined document ids.
Example Payload :
{
"fromTime": 1469092108822,
"toTime": 1469092208822,
"ids": ["611e5fc1-6bc7-4121-9d88-b89441b5a55b", "611e5fc1-6bc7-4121-9d88-b89441b512b"]
}
5. POST Delete sidelined document POST /v1/documents/delete
Header : Content-Type:application/json
JsonFields :
- fromTime : Enqueue from time (in Millis)
- toTime : Enqueue to time (in Millis)
- ids : List of sidelined document ids.
Example Payload :
{
"fromTime": 1469092108822,
"toTime": 1469092208822,
"ids": ["611e5fc1-6bc7-4121-9d88-b89441b5a55b", "611e5fc1-6bc7-4121-9d88-b89441b512b"]
}