Enterprise WeChat
Enterprise WeChat sink connector
Support Those Engines
Spark
Flink
SeaTunnel Zeta
Description
A sink plugin that sends SeaTunnel rows to an Enterprise WeChat robot webhook. The connector
identifier in job configuration is WeChat. Each row is serialized into a plain-text message with
the fields rendered as fieldName: fieldValue, joined by the literal two-character sequence \n
(not real newlines) before the request is sent to the webhook.
The connector extends the Http sink. It also accepts the generic
multi_table_sink_replica option for fan-out writes. Note that retry,
retry_backoff_multiplier_ms and retry_backoff_max_ms are accepted by the option rule but are
not read by the current sink writer, so no retries are performed.
For example, if the data from upstream is
{"alarmStatus": "firing", "alarmTime": "2022-08-03 01:38:49", "alarmContent": "The disk usage exceeds the threshold"}, the text content sent to the WeChat robot is the following (the\nsequences below are the literal two characters backslash +n, not real newlines):alarmStatus: firing\nalarmTime: 2022-08-03 01:38:49\nalarmContent: The disk usage exceeds the threshold
Key features
Data Type Mapping
The connector renders every upstream row as one plain-text message. Each field is converted to its
string representation (String.valueOf(value)) and joined with its field name using the literal
sequence \n, so no per-type JSON structure exists on the wire.
| SeaTunnel Data Type | Enterprise WeChat Message Field |
|---|---|
| string | fieldName: string |
| tinyint / smallint / int / bigint | fieldName: number |
| float / double | fieldName: number |
| boolean | fieldName: true/false |
| date / time / timestamp | fieldName: ISO string |
| bytes / array / map / row | fieldName: String(toString) |
Options
| name | type | required | default value | description |
|---|---|---|---|---|
| url | String | Yes | - | Enterprise WeChat robot webhook URL, format https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=XXXXXX. |
| mentioned_list | array | No | - | User IDs to mention in the group. Use @all to mention everyone. |
| mentioned_mobile_list | array | No | - | Mobile phone numbers to mention in the group. Use @all to mention everyone. |
| retry | int | No | - | Accepted by the option rule, but the current sink writer never reads this option, so no retries are performed. |
| retry_backoff_multiplier_ms | int | No | 100 | Accepted by the option rule, but not applied by the current sink writer. |
| retry_backoff_max_ms | int | No | 10000 | Accepted by the option rule, but not applied by the current sink writer. |
| multi_table_sink_replica | int | No | 1 | Number of writer replicas used when writing multiple tables. |
| common-options | no | - | Sink plugin common parameters, please refer to Sink Common Options for details. |
url [string]
Enterprise WeChat webhook URL format is
https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=XXXXXX. The key query parameter is the
robot key generated in the Enterprise WeChat group robot settings.
mentioned_list [array]
A list of user IDs to mention in the group. Use @all to mention everyone. If the user ID is
unavailable, use mentioned_mobile_list.
mentioned_mobile_list [array]
Mobile phone numbers to mention in the group. Use @all to mention everyone.
retry [int]
Accepted by the option rule, but the current sink writer never reads this option, so no retries are performed regardless of the configured value.
retry_backoff_multiplier_ms [int]
Accepted by the option rule, but not applied by the current sink writer.
retry_backoff_max_ms [int]
Accepted by the option rule, but not applied by the current sink writer.
multi_table_sink_replica [int]
Number of writer replicas used when writing multiple tables. Increase this value to add more
parallel writers per table. Default is 1.
common options
Sink plugin common parameters, please refer to Sink Common Options for details.
Task Example
Simple
env {
parallelism = 1
job.mode = "BATCH"
}
source {
FakeSource {
row.num = 1
schema = {
fields {
alarmStatus = string
alarmTime = string
alarmContent = string
}
}
rows = [
{
fields = ["firing", "2022-08-03 01:38:49", "The disk usage exceeds the threshold"]
}
]
}
}
sink {
WeChat {
url = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=693axxx6-7aoc-4bc4-97a0-0ec2sifa5aaa"
}
}
Mention users and phone numbers
env {
parallelism = 1
job.mode = "BATCH"
}
source {
FakeSource {
row.num = 1
schema = {
fields {
alarmStatus = string
alarmTime = string
alarmContent = string
}
}
rows = [
{
fields = ["firing", "2022-08-03 01:38:49", "The disk usage exceeds the threshold"]
}
]
}
}
sink {
WeChat {
url = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=693axxx6-7aoc-4bc4-97a0-0ec2sifa5aaa"
mentioned_list = ["wangqing", "@all"]
mentioned_mobile_list = ["13800001111", "@all"]
}
}
Changelog
Change Log
| Change | Commit | Version |
|---|---|---|
| [improve] http connector options (#8969) | https://github.com/apache/seatunnel/commit/63ff9f910a | 2.3.10 |
| [Feature][Restapi] Allow metrics information to be associated to logical plan nodes (#7786) | https://github.com/apache/seatunnel/commit/6b7c53d03c | 2.3.9 |
| [Feature][Core] Support using upstream table placeholders in sink options and auto replacement (#7131) | https://github.com/apache/seatunnel/commit/c4ca74122c | 2.3.6 |
| [Feature][Connector-V2] Support TableSourceFactory/TableSinkFactory on http (#5816) | https://github.com/apache/seatunnel/commit/6f49ec6ead | 2.3.4 |
| [Improve][build] Give the maven module a human readable name (#4114) | https://github.com/apache/seatunnel/commit/d7cd601051 | 2.3.1 |
| [Improve][Project] Code format with spotless plugin. (#4101) | https://github.com/apache/seatunnel/commit/a2ab166561 | 2.3.1 |
| [Hotfix][OptionRule] Fix option rule about all connectors (#3592) | https://github.com/apache/seatunnel/commit/226dc6a119 | 2.3.0 |
| [Feature][Connector-V2][Http] Add option rules && Improve Myhours sink connector (#3351) | https://github.com/apache/seatunnel/commit/cc8bb60c83 | 2.3.0 |
| [Bug][Connector-V2] Fix wechat sink data serialization (#2856) | https://github.com/apache/seatunnel/commit/3aee11fc16 | 2.3.0-beta |
| [Feature][Connector-V2] Add Enterprise Wechat sink connector (#2412) | https://github.com/apache/seatunnel/commit/3e200e0a38 | 2.2.0-beta |