跳到主要内容
版本:2.3.13

Socket

Socket 源连接器

支持这些引擎​

Spark
Flink
SeaTunnel Zeta

关键特性​

描述​

用于从 Socket 读取数据。

数据类型映射​

文件没有特定的类型列表,我们可以通过在配置中指定 Schema 来指示相应的数据需要转换为哪种 SeaTunnel 数据类型。

SeaTunnel 数据类型
STRING
SHORT
INT
BIGINT
BOOLEAN
DOUBLE
DECIMAL
FLOAT
DATE
TIME
TIMESTAMP
BYTES
ARRAY
MAP

选项​

参数名类型必须默认值描述
hostString是-socket 服务器主机
portInteger是-socket 服务器端口
common-options否-源插件通用参数,请参考 源通用选项 详见。

如何创建 Socket 数据同步作业​

  • 配置 SeaTunnel 配置文件

以下示例演示如何创建从 Socket 读取数据并在本地客户端上打印的数据同步作业:

# 设置要执行的任务的基本配置
env {
parallelism = 1
job.mode = "BATCH"
}

# 创建源以连接到 socket
source {
Socket {
host = "localhost"
port = 9999
}
}

# 控制台打印读取的 socket 数据
sink {
Console {
parallelism = 1
}
}
  • 启动端口监听
nc -l 9999
  • 启动 SeaTunnel 任务

  • Socket 源发送测试数据

~ nc -l 9999
test
hello
flink
spark
  • 控制台 Sink 打印数据
[test]
[hello]
[flink]
[spark]

变更日志​

Change Log
ChangeCommitVersion
[improve] socket options (#9517)https://github.com/apache/seatunnel/commit/af83a302cf2.3.12
[Feature][Restapi] Allow metrics information to be associated to logical plan nodes (#7786)https://github.com/apache/seatunnel/commit/6b7c53d03c2.3.9
[Improve] Remove use SeaTunnelSink::getConsumedType method and mark it as deprecated (#5755)https://github.com/apache/seatunnel/commit/8de74081002.3.4
[Improve][build] Give the maven module a human readable name (#4114)https://github.com/apache/seatunnel/commit/d7cd6010512.3.1
[Improve][Project] Code format with spotless plugin. (#4101)https://github.com/apache/seatunnel/commit/a2ab1665612.3.1
[Feature][Connector] add get source method to all source connector (#3846)https://github.com/apache/seatunnel/commit/417178fb842.3.1
[Hotfix][OptionRule] Fix option rule about all connectors (#3592)https://github.com/apache/seatunnel/commit/226dc6a1192.3.0
[Improve][Connector-V2][Socket] Unified exception for socket source & sink connector (#3511)https://github.com/apache/seatunnel/commit/581292f2102.3.0
[feature][connector][socket] Add Socket Connector Option Rules (#3317)https://github.com/apache/seatunnel/commit/b85317bcbe2.3.0
[Improve][all] change Log to @Slf4j (#3001)https://github.com/apache/seatunnel/commit/6016100f122.3.0-beta
[DEV][Api] Replace SeaTunnelContext with JobContext and remove singleton pattern (#2706)https://github.com/apache/seatunnel/commit/cbf82f755c2.2.0-beta
[#2606]Dependency management split (#2630)https://github.com/apache/seatunnel/commit/fc047be69b2.2.0-beta
[Feature][Connector-V2] Socket Connector Sink (#2549)https://github.com/apache/seatunnel/commit/94f4600a4e2.2.0-beta
[api-draft][Optimize] Optimize module name (#2062)https://github.com/apache/seatunnel/commit/f79e3112b12.2.0-beta