Grape is a distributed delay job system based on Redis.
-
[1.3.2] Redis version 3.0.2
-
[1.3.1] improve API and bugfix.
-
1.3.0 support redis cluster model.
-
1.2.2 is a stable version of 1.2 and has fixed several bugs.
-
1.3.1 optimized the scheduling model and supports zero delay scheduling algorithms
-
1.1.0 add admin web UI project.
-
1.0.0 have released a Redis based delayed job system and opened the rest interface.
A job in Grape during its life it can be in one of four states: "delay", "ready", "remain", or "failed".
Here is a picture of the typical job lifecycle:
Access grape admin endpoint: http://localhost:9595/
Quick Start 快速开始
git clone https://github.com/dinstone/grape.git
cd grape
maven package
cd grape/grape-server/target
unzip grape-server-1.3.0.zip
cd grape-server-1.3.0/config/
edit redis config from config.json file.
- jedis pooled client config
{
"redis": {
"nodes": [
{
"host": "127.0.0.1",
"port": 6379
}
],
"model": "pooled",
"maxTotal": 8,
"minIdle": 1,
"timeout": 2000,
"maxWaitMillis": 3000,
"numTestsPerEvictionRun": -1,
"minEvictableIdleTimeMillis": 60000,
"timeBetweenEvictionRunsMillis": 30000
}
}
- jedis cluster client config
{
"redis": {
"nodes": [
{
"host": "192.168.1.120",
"port": 7001
},
{
"host": "192.168.1.120",
"port": 7002
},
{
"host": "192.168.1.120",
"port": 7003
}
],
"model": "cluster",
"maxTotal": 4,
"minIdle": 1,
"timeout": 2000,
"maxWaitMillis": 3000,
"numTestsPerEvictionRun": -1,
"minEvictableIdleTimeMillis": 60000,
"timeBetweenEvictionRunsMillis": 30000
}
}
edit users info from user.json file.
{
"admin": {
"password": "grape",
"roles": [
"writer",
"reader"
]
},
"guid": {
"password": "grape",
"roles": [
"reader"
]
}
}
cd grape-server-1.3.1/bin
./start.sh
cd grape-server-1.3.1/bin
./stop.sh
You can find the complete API Definition here.
Example Request
curl --location 'http://localhost:9521/api/job/produce?tube=test&jid=j004&dtr=1000&ttr=10000' \
--header 'Content-Type: application/json' \
--data '{
"orderId": "j001",
"sumMoney": 2000,
"count": 10000
}'
Example Response 200 - OK
true
Example Request
curl --location --request DELETE 'http://localhost:9521/api/job/delete?tube=test&jid=j001'
Example Response200 OK
true
Example Request
curl --location 'http://localhost:9521/api/job/consume?tube=test&max=10'
Example Response200 OK
[
{
"id": "j004",
"dtr": 1000,
"ttr": 10000,
"noe": 0,
"data": "ewogICAgIm9yZGVySWQiOiAiajAwMSIsCiAgICAic3VtTW9uZXkiOiAyMDAwLAogICAgImNvdW50IjogMTAwMDAKfQ"
}
]
Example Request
curl --location --request DELETE 'http://localhost:9521/api/job/finish?tube=test&jid=j003'
Example Response200 OK
true
Example Request
curl --location --request PUT 'http://localhost:9521/api/job/release?tube=test&jid=j001&dtr=20000'
Example Response200 OK
true
Example Request
curl --location 'http://localhost:9521/api/tube/list'
Example Response200 OK
[
"test"
]
Example Request
curl --location 'http://localhost:9521/api/tube/stats'
Example Response200 OK
[
{
"dateTime": 1689390610122,
"tubeName": "test",
"totalJobSize": 0,
"finishJobSize": 0,
"delayQueueSize": 0,
"retainQueueSize": 0,
"failedQueueSize": 1
}
]
Grape is released under the Apache License 2.0.