docs/en/10-third-party/01-collection/12-flink.md
import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import FlinkCommonInfo from '../../assets/resources/_flink-common-info.mdx'
Apache Flink is an open-source distributed stream batch integrated processing framework supported by the Apache Software Foundation, which can be used for many big data processing scenarios such as stream processing, batch processing, complex event processing, real-time data warehouse construction, and providing real-time data support for machine learning. At the same time, Flink has a wealth of connectors and various tools that can interface with numerous different types of data sources to achieve data reading and writing. In the process of data processing, Flink also provides a series of reliable fault-tolerant mechanisms, effectively ensuring that tasks can run stably and continuously even in the event of unexpected situations.
With the help of TDengine's Flink connector, Apache Flink can seamlessly integrate with the TDengine database. On the one hand, it can accurately store the results obtained after complex calculations and deep analysis into the TDengine database, achieving efficient storage and management of data; On the other hand, it is also possible to quickly and stably read massive amounts of data from the TDengine database, and conduct comprehensive and in-depth analysis and processing on this basis, fully tapping into the potential value of the data, providing strong data support and scientific basis for enterprise decision-making, greatly improving the efficiency and quality of data processing, and enhancing the competitiveness and innovation ability of enterprises in the digital age.
Prepare the following environment:
Flink Connector supports all platforms that can run Flink 1.19 and above versions.
<FlinkCommonInfo />The parameters for establishing a connection include URL and Properties. The URL specification format is:
jdbc: TAOS-WS://[host_name]:[port]/[database_name]?[user={user}|&password={password}|&timezone={timezone}]
Parameter description:
The core function of Sink is to efficiently and accurately write Flink processed data from different data sources or operators into TDengine. In this process, the efficient write mechanism possessed by TDengine played a crucial role, effectively ensuring the fast and stable storage of data.
:::note
:::
Sink Properties
TD_SUPERTABLE_NAME.RowData of Flink, it only needs to be set to RowData. It is also possible to inherit TDengineSinkRecordSerializer and implement the serialize method, customizing the deserialization method based on the received data type.PROPERTY_KEY_ENABLE_AUTO_RECONNECT is true.PROPERTY_KEY_ENABLE_AUTO_RECONNECT is true.Usage example:
Write the data of the RowData type into the sub-table corresponding to the super table sink_meters in the power_sink database.
Usage example:
Write the data of the RowData type into the sink_normal table in the power_sink database.
Usage example:
Write the data of the custom type into the sub-tables corresponding to the super table sink_meters in the power_sink database.
:::note
:::
Extract data from multiple different data source databases (such as MySQL, Oracle, Kafka etc.) using Flink Table, perform custom operator operations (such as data cleaning, format conversion, associating data from different tables, etc.), and then write the processed results into the TDengine.
Parameter configuration instructions:
| Parameter Name | Type | Parameter Description |
|---|---|---|
| connector | string | connector identifier, set tdengine-connector |
| td.jdbc.url | string | url of the connection |
| td.jdbc.mode | string | connector type sink |
| sink.db.name | string | target database name |
| sink.batch.size | integer | batch size written |
| sink.supertable.name | string | name of the supertable |
| sink.table.name | string | the table name of a sub table or a normal table |
Usage example:
Write data into the sub-tables corresponding to the super table sink_meters in the power_sink database via SQL statements.
Usage example:
Write data into the sink_normal table in the power_sink database via SQL statements.
Usage example:
Write data of the Row type into the sub-tables corresponding to the super table sink_meters in the power_sink database.