MetaQ data source
DataWorks Data Integration can use MetaQ Reader to read data from Message Queue (MQ). This topic describes the MetaQ data reading capabilities of DataWorks.
Supported versions
MetaQ Reader subscribes to real-time messages in MetaQ by using the Message Queue Java SDK. The Java SDK versions are as follows:
<dependency>
<groupId>com.taobao.metaq.final</groupId>
<artifactId>metaq-client</artifactId>
<version>4.0.1</version>
</dependency>
<dependency>
<groupId>com.aliyun.openservices</groupId>
<artifactId>ons-sdk</artifactId>
<version>1.3.1</version>
</dependency>Limits
Currently, MQ data can be read only with the MetaQ Reader plug-in in script mode.
MetaQ Reader supports Serverless resource groups (recommended) and exclusive Data Integration resource groups.
Supported field types
The following field types are supported.
Field type | Offline read (MetaQ Reader) |
STRING | Supported |
MetaQ Reader maps MetaQ types as follows.
Data Integration data type | Message Queue data type |
STRING | STRING |
Develop a data synchronization task
For information about the entry point for and the procedure of configuring a synchronization task, see the following configuration guides.
For the procedure, see Script mode configuration.
For all parameters and a sample script in script mode, see Appendix: MetaQ sample script and parameter descriptions.
Appendix: MetaQ sample script and parameter descriptions
Configure a batch synchronization task by using the code editor
If you want to configure a batch synchronization task by using the code editor, you must configure the related parameters in the script based on the unified script format requirements. For more information, see Script mode configuration. The following information describes the parameters that you must configure for data sources when you configure a batch synchronization task by using the code editor.
Sample reader script
{
"job": {
"content": [
{
"reader": {
"name": "metaqreader",
"parameter": {
"accessId": "<yourAccessKeyId>",
"accessKey": "<yourAccessKeySecret>",
"consumerId": "Test01",
"topicName": "test",
"subExpression": "*",
"onsChannel": "ALIYUN",
"domainName": "***.aliyun.com",
"contentType": "singlestringcolumn",
"beginOffset": "lastRead",
"nullCurrentOffset": "begin",
"fieldDelimiter": ",",
"column": [
"col0"
],
"fieldDelimiter": ","
}
},
"writer": {
"name": "streamwriter",
"parameter": {
"print": false
}
}
}
]
}
}Reader script parameters
Parameter | Description | Required |
accessId | The access key information for Message Queue, used for authentication. | Yes |
accessKey | Yes | |
consumerId | A consumer, also called a message subscriber, receives and processes messages. consumerIdAn identifier for a class of consumers. Consumers with the same identifier typically receive and process the same type of messages using the same processing logic. | Yes |
topicName | A message topic, which is the primary message category. Messages are classified by topic. | Yes |
subExpression | A message subtopic. | Yes |
onsChannel | Used to authenticate with Message Queue. | Yes |
unitName | The destination unit that receives messages. Common units include:
| No |
instanceName | The consumer instance name. | No |
domainName | The Message Queue endpoint. | Yes |
contentType | The message type. Supported values are singlestringcolumn (a STRING message), text (a text message), and json (a JSON message). | Yes |
beginOffset | The offset at which the task starts reading. Supported values are begin (from the start) and lastRead (from the last offset read). | No |
nullCurrentOffset | Where to start reading when the previous offset is empty. Supported values are begin (from the start) and current (from the current offset). | Yes |
fieldDelimiter | The column delimiter for message strings in delimiter mode, such as a comma. Control characters are supported, for example \u0001. | Yes |
column | The list of fields to read. | Yes |
beginDateTime | The start time for data consumption, which is the inclusive lower bound of the time range. beginDateTime is a yyyyMMddHHmmss timestamp string and can be used with DataWorks scheduling time parameters. | No Note beginDateTime and endDateTime are used together. |
endDateTime | The end time for data consumption, which is the exclusive upper bound of the time range. endDateTime is a yyyyMMddHHmmss timestamp string and can be used with DataWorks scheduling time parameters. |