redisClient
x/redisClient
组件:redis客户端。可以执行redis命令。
# 配置
字段 | 类型 | 说明 | 默认值 |
---|---|---|---|
cmd | string | redis执行命令,例如:SET/GET/Del,可以使用${}占位符替换metadata元数据 | 无 |
params | string | 执行命令参数,可以使用${}占位符替换metadata元数据 | 无 |
poolSize | int | 连接池大小 | 0 |
server | string | redis服务器地址 | 无 |
提示
cmd
和params
:可以使用${}占位符替换metadata元数据,支持${msg.data}获取消息负荷,${msg.type}获取消息类型
# Relation Type
- Success: 执行成功,把消息发送到
Success
链 - Failure: 执行失败,把消息发送到
Failure
链
# 执行结果
执行结果替换到msg.Data,流转到下一个节点。
# 配置示例
{
"id": "s5",
"type": "x/redisClient",
"name": "保存到redis",
"debugMode": true,
"configuration": {
"cmd": "SET",
"params": ["${key}", "${msg.data}"],
"poolSize": 10,
"Server": "192.168.1.1:6379"
}
}
1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
# 应用示例
应用示例参考:redisClient (opens new window)
{
"ruleChain": {
"id":"chain_msg_type_switch",
"name": "测试规则链-msgTypeSwitch",
"root": false,
"debugMode": false
},
"metadata": {
"nodes": [
{
"id": "s1",
"type": "msgTypeSwitch",
"name": "过滤",
"debugMode": true
},
{
"id": "s2",
"type": "log",
"name": "记录日志1",
"debugMode": true,
"configuration": {
"jsScript": "return msgType+':s2--'+JSON.stringify(msg);"
}
},
{
"id": "s3",
"type": "log",
"name": "记录日志2",
"debugMode": true,
"configuration": {
"jsScript": "return msgType+':s3--'+JSON.stringify(msg);"
}
},
{
"id": "s5",
"type": "x/redisClient",
"name": "保存到redis",
"debugMode": true,
"configuration": {
"cmd": "SET",
"params": ["${key}", "${msg.data}"],
"poolSize": 10,
"Server": "192.168.1.1:6379"
}
},
{
"id": "s6",
"type": "x/redisClient",
"name": "保存到redis",
"debugMode": true,
"configuration": {
"cmd": "SET",
"params": ["${key}", "${value}"],
"poolSize": 10,
"Server": "192.168.1.1:6379"
}
}
],
"connections": [
{
"fromId": "s1",
"toId": "s2",
"type": "TEST_MSG_TYPE1"
},
{
"fromId": "s1",
"toId": "s3",
"type": "TEST_MSG_TYPE2"
},
{
"fromId": "s3",
"toId": "s5",
"type": "Success"
},
{
"fromId": "s2",
"toId": "s6",
"type": "Success"
}
]
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
在 GitHub 上编辑此页 (opens new window)
上次更新: 2024/06/21, 04:40:14