This is an automated email from the ASF dual-hosted git repository.
davidradl pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/flink-connector-http.git
The following commit(s) were added to refs/heads/main by this push:
new 9278dad [FLINK-39361][connector-http] Improve README with SQL
examples (#30)
9278dad is described below
commit 9278dadff0cb1f417103f35a928bcf49afda4545
Author: Feat Zhang <[email protected]>
AuthorDate: Fri Jun 26 15:54:20 2026 +0800
[FLINK-39361][connector-http] Improve README with SQL examples (#30)
* [connector-http] Add Quick Start section to Table HTTP connector docs
- Add Quick Start section with SQL examples for HTTP Sink and HTTP Lookup
Source to both English and Chinese documentation
- Fix HTTP Lookup connector name: use 'http' (not 'rest-lookup')
- Add DataStream API example for HTTP Sink (English docs)
- Add Quick Start entry to TOC
* [connector-http] Fix connector identifier and add DataStream example to
zh docs
- Fix SQL sink connector identifier: 'http-sink' -> 'http-async-sink' to
match
HttpDynamicTableSinkFactory.IDENTIFIER (both English and Chinese docs)
- Add DataStream API example for HttpSink to Chinese documentation
* [connector-http] Fix all http-sink connector identifiers to
http-async-sink
Fix remaining occurrences of 'http-sink' -> 'http-async-sink' in:
- HTTP Sink table creation example
- Sink Connector Options table description
- Batch submission mode example
- Single submission mode example
(both English and Chinese documentation)
---
docs/content.zh/docs/connectors/table/http.md | 88 ++++++++++++++++++++++++--
docs/content/docs/connectors/table/http.md | 89 +++++++++++++++++++++++++--
2 files changed, 169 insertions(+), 8 deletions(-)
diff --git a/docs/content.zh/docs/connectors/table/http.md
b/docs/content.zh/docs/connectors/table/http.md
index 13d7a54..8781ae0 100644
--- a/docs/content.zh/docs/connectors/table/http.md
+++ b/docs/content.zh/docs/connectors/table/http.md
@@ -38,6 +38,7 @@ The HTTP source connector supports [Lookup
Joins](https://nightlies.apache.org/f
<!-- TOC -->
* [HTTP Connector](#http-connector)
+ * [Quick Start](#quick-start)
* [Dependencies](#dependencies)
* [Migration from GetInData HTTP
connector](#migration-from-getindata-http-connector)
* [Working with HTTP lookup source
tables](#working-with-http-lookup-source-tables)
@@ -73,6 +74,85 @@ The HTTP source connector supports [Lookup
Joins](https://nightlies.apache.org/f
* [Logging the HTTP content](#logging-the-http-content)
* [Restrictions at this time](#restrictions-at-this-time)
<!-- TOC -->
+## Quick Start
+
+### SQL示例 — HTTP Sink
+
+使用HTTP Sink连接器通过SQL将Flink记录写入外部HTTP端点:
+
+```sql
+CREATE TABLE http_sink (
+ id BIGINT,
+ name STRING,
+ status STRING
+) WITH (
+ 'connector' = 'http-async-sink',
+ 'url' = 'https://api.example.com/events',
+ 'format' = 'json',
+ 'insert-method' = 'POST'
+);
+
+INSERT INTO http_sink SELECT id, name, status FROM source_table;
+```
+
+### SQL示例 — HTTP Lookup Source
+
+使用HTTP Lookup连接器通过外部HTTP API丰富流数据:
+
+```sql
+-- 定义HTTP查找表
+CREATE TABLE http_lookup (
+ id STRING,
+ payload STRING
+) WITH (
+ 'connector' = 'http',
+ 'url' = 'https://api.example.com/data',
+ 'format' = 'json'
+);
+
+-- 使用查找连接丰富流数据
+SELECT s.event_id, h.payload
+FROM stream_table AS s
+JOIN http_lookup FOR SYSTEM_TIME AS OF s.proc_time AS h
+ ON s.event_id = h.id;
+```
+
+完整配置选项列表和高级功能(TLS、mTLS、OIDC认证、重试策略、代理支持等),请参阅下方详细章节。
+
+### DataStream API示例 — HTTP Sink
+
+在Flink DataStream API中使用HTTP Sink连接器:
+
+```java
+import org.apache.flink.connector.http.HttpSink;
+import org.apache.flink.connector.http.sink.HttpSinkRequestEntry;
+import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
+import org.apache.flink.streaming.api.datastream.DataStream;
+
+import java.nio.charset.StandardCharsets;
+
+public class HttpSinkExample {
+ public static void main(String[] args) throws Exception {
+ StreamExecutionEnvironment env =
StreamExecutionEnvironment.getExecutionEnvironment();
+
+ DataStream<String> sourceStream = env.fromElements("event1", "event2",
"event3");
+
+ HttpSink<String> httpSink = HttpSink.<String>builder()
+ .setEndpointUrl("https://api.example.com/events")
+ .setElementConverter(
+ (element, context) ->
+ new HttpSinkRequestEntry("POST",
element.getBytes(StandardCharsets.UTF_8)))
+ .build();
+
+ sourceStream.sinkTo(httpSink);
+
+ env.execute("HTTP Sink示例");
+ }
+}
+```
+
+完整配置选项列表和高级功能(TLS、mTLS、OIDC认证、重试策略、代理支持等),请参阅下方详细章节。
+
## Dependencies
{{< sql_connector_download_table "http" >}}
@@ -482,7 +562,7 @@ CREATE TABLE http (
id bigint,
some_field string
) WITH (
- 'connector' = 'http-sink',
+ 'connector' = 'http-async-sink',
'url' = 'http://example.com/myendpoint',
'format' = 'json'
)
@@ -502,7 +582,7 @@ another format name.
| Option | Required | Description/Value
|
|-------------------------------------------|----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
-| connector | required | Specify what
connector to use. For HTTP Sink it should be set to _'http-sink'_.
|
+| connector | required | Specify what
connector to use. For HTTP Sink it should be set to _'http-async-sink'_.
|
| format | required | Specify what format
to use.
|
| url | required | The base URL that
should be used for HTTP requests. For example _http://localhost:8080/client_.
|
| insert-method | optional | Specify which HTTP
method to use in the request. The value should be set either to `POST` or
`PUT`.
|
@@ -592,7 +672,7 @@ CREATE TABLE http (
id bigint,
some_field string
) WITH (
- 'connector' = 'http-sink',
+ 'connector' = 'http-async-sink',
'url' = 'http://example.com/myendpoint',
'format' = 'json',
'http.sink.request.batch.size' = '50'
@@ -610,7 +690,7 @@ CREATE TABLE http (
id bigint,
some_field string
) WITH (
- 'connector' = 'http-sink',
+ 'connector' = 'http-async-sink',
'url' = 'http://example.com/myendpoint',
'format' = 'json',
'http.sink.writer.request.mode' = 'single'
diff --git a/docs/content/docs/connectors/table/http.md
b/docs/content/docs/connectors/table/http.md
index 13d7a54..120847e 100644
--- a/docs/content/docs/connectors/table/http.md
+++ b/docs/content/docs/connectors/table/http.md
@@ -38,6 +38,7 @@ The HTTP source connector supports [Lookup
Joins](https://nightlies.apache.org/f
<!-- TOC -->
* [HTTP Connector](#http-connector)
+ * [Quick Start](#quick-start)
* [Dependencies](#dependencies)
* [Migration from GetInData HTTP
connector](#migration-from-getindata-http-connector)
* [Working with HTTP lookup source
tables](#working-with-http-lookup-source-tables)
@@ -73,6 +74,86 @@ The HTTP source connector supports [Lookup
Joins](https://nightlies.apache.org/f
* [Logging the HTTP content](#logging-the-http-content)
* [Restrictions at this time](#restrictions-at-this-time)
<!-- TOC -->
+## Quick Start
+
+This guide provides quick examples to get started with the HTTP connector.
+
+### SQL Example — HTTP Sink
+
+Use the HTTP Sink connector to write Flink records to an external HTTP
endpoint via SQL:
+
+```sql
+CREATE TABLE http_sink (
+ id BIGINT,
+ name STRING,
+ status STRING
+) WITH (
+ 'connector' = 'http-async-sink',
+ 'url' = 'https://api.example.com/events',
+ 'format' = 'json',
+ 'insert-method' = 'POST'
+);
+
+INSERT INTO http_sink SELECT id, name, status FROM source_table;
+```
+
+### SQL Example — HTTP Lookup Source
+
+Use the HTTP Lookup connector to enrich a stream with data from an external
HTTP API:
+
+```sql
+-- Define the HTTP lookup table
+CREATE TABLE http_lookup (
+ id STRING,
+ payload STRING
+) WITH (
+ 'connector' = 'http',
+ 'url' = 'https://api.example.com/data',
+ 'format' = 'json'
+);
+
+-- Enrich a stream using a lookup join
+SELECT s.event_id, h.payload
+FROM stream_table AS s
+JOIN http_lookup FOR SYSTEM_TIME AS OF s.proc_time AS h
+ ON s.event_id = h.id;
+```
+
+### DataStream API Example — HTTP Sink
+
+Use the HTTP Sink connector in the Flink DataStream API:
+
+```java
+import org.apache.flink.connector.http.HttpSink;
+import org.apache.flink.connector.http.sink.HttpSinkRequestEntry;
+import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
+import org.apache.flink.streaming.api.datastream.DataStream;
+
+import java.nio.charset.StandardCharsets;
+
+public class HttpSinkExample {
+ public static void main(String[] args) throws Exception {
+ StreamExecutionEnvironment env =
StreamExecutionEnvironment.getExecutionEnvironment();
+
+ DataStream<String> sourceStream = env.fromElements("event1", "event2",
"event3");
+
+ HttpSink<String> httpSink = HttpSink.<String>builder()
+ .setEndpointUrl("https://api.example.com/events")
+ .setElementConverter(
+ (element, context) ->
+ new HttpSinkRequestEntry("POST",
element.getBytes(StandardCharsets.UTF_8)))
+ .build();
+
+ sourceStream.sinkTo(httpSink);
+
+ env.execute("HTTP Sink Example");
+ }
+}
+```
+
+For a full list of configuration options and advanced features (TLS, mTLS,
OIDC authentication,
+retry strategies, proxy support, etc.), refer to the detailed sections below.
+
## Dependencies
{{< sql_connector_download_table "http" >}}
@@ -482,7 +563,7 @@ CREATE TABLE http (
id bigint,
some_field string
) WITH (
- 'connector' = 'http-sink',
+ 'connector' = 'http-async-sink',
'url' = 'http://example.com/myendpoint',
'format' = 'json'
)
@@ -502,7 +583,7 @@ another format name.
| Option | Required | Description/Value
|
|-------------------------------------------|----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
-| connector | required | Specify what
connector to use. For HTTP Sink it should be set to _'http-sink'_.
|
+| connector | required | Specify what
connector to use. For HTTP Sink it should be set to _'http-async-sink'_.
|
| format | required | Specify what format
to use.
|
| url | required | The base URL that
should be used for HTTP requests. For example _http://localhost:8080/client_.
|
| insert-method | optional | Specify which HTTP
method to use in the request. The value should be set either to `POST` or
`PUT`.
|
@@ -592,7 +673,7 @@ CREATE TABLE http (
id bigint,
some_field string
) WITH (
- 'connector' = 'http-sink',
+ 'connector' = 'http-async-sink',
'url' = 'http://example.com/myendpoint',
'format' = 'json',
'http.sink.request.batch.size' = '50'
@@ -610,7 +691,7 @@ CREATE TABLE http (
id bigint,
some_field string
) WITH (
- 'connector' = 'http-sink',
+ 'connector' = 'http-async-sink',
'url' = 'http://example.com/myendpoint',
'format' = 'json',
'http.sink.writer.request.mode' = 'single'