Appearance
RocketMQ 
往RocketMQ队列发送消息
业务属性 
| 属性 | 含义 | 说明 | 输入限定 | 示例值 | 
|---|---|---|---|---|
| enable | 是否启用该控件,未启用时不编译 | 是否编译 | 选择值 | 启用 | 
| name | 控件返回值命名 | 控件输出值变量名 | 常量 | rocketMQ | 
| text | 与控件关联的文本 | 设计页控件显示 | 常量 | sendRocketMQMessage | 
| rocketMQ | 消息队列 | 可选已在资源配置中配置的RocketMQ队列资源 | 选择值 | myRocketMQ | 
| topic | topic名称 | 指定发送消息的topic | 常量/流程变量 | topic1 | 
| message | 消息内容 | 发送的消息内容 | 常量,Json数据节点可用流程变量/流程变量 | {"key":"#{value}"} | 
| tag | 发送消息的tag | 设置发送消息的tag,便于消费者对消息进行过滤 | 常量/流程变量 | tag1 | 
| key | 发送消息的key | 决定消息发送的队列,保证消息的顺序性 | 常量/流程变量 | #{key} | 
| delay | 延迟发送等级 | 常量/流程变量 | 1 | |
| throwable | 发生异常时中断请求 | 启用:控件执行异常时立即中断请求,并返回错误 禁用:控件执行异常时将被忽略,并继续执行其后的流程 | 选择值 | 启用 | 
输出值 
- 消息发送成功时输出值
控件返回以属性name为名称的实体,该实体包含属性result,并且result为boolean类型的true。
- throwable为“禁用”,消息发送失败时输出值
控件返回以属性name为名称的实体,该实体包含表示异常信息的属性err(此时属性result为nil)。
使用示例 
假设已创建RocketMQ资源,资源名称为:myRocketMQ,需要向主题名称为ExampleTopic发送消息。
发送常量消息 
- RocketMQ控件设置
添加RocketMQ控件并命名为sendResult,属性设置为:
rocketMQ:myRocketMQ; topic:ExampleTopic
message:this is a example message

- 输出发送结果
添加输出控件Return,data设置为:
json
{
  "sendResult": "#{sendResult}"
}{
  "sendResult": "#{sendResult}"
}
- 接口调用
使用curl请求接口:
$ curl http://localhost:6636/api/rocketMQ$ curl http://localhost:6636/api/rocketMQ接口返回:
json
{
    "sendResult": {
        "result": true
    }
}{
    "sendResult": {
        "result": true
    }
}使用流程变量发送消息 
- RocketMQ控件设置
在前面示例的基础上,修改message属性设置为:
json
{
  "message": "#{body.message}"
}{
  "message": "#{body.message}"
}
- 接口调用
使用curl请求接口:
$ curl http://localhost:6636/api/rocketMQ -d "{\"message\":\"This is an example message sent to RocketMQ\"}"$ curl http://localhost:6636/api/rocketMQ -d "{\"message\":\"This is an example message sent to RocketMQ\"}"接口返回:
json
{
    "sendResult": {
        "result": true
    }
}{
    "sendResult": {
        "result": true
    }
}