You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by ma...@apache.org on 2023/01/10 21:19:11 UTC
[flink] branch master updated: [FLINK-30485][Connector/RabbitMQ] Remove RabbitMQ connector. This closes #21550
This is an automated email from the ASF dual-hosted git repository.
martijnvisser pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git
The following commit(s) were added to refs/heads/master by this push:
new cfe794b792b [FLINK-30485][Connector/RabbitMQ] Remove RabbitMQ connector. This closes #21550
cfe794b792b is described below
commit cfe794b792b906b2129a24fdac456abbeefa28eb
Author: MartijnVisser <ma...@apache.org>
AuthorDate: Tue Jan 10 22:18:45 2023 +0100
[FLINK-30485][Connector/RabbitMQ] Remove RabbitMQ connector. This closes #21550
* [FLINK-30485][Connector/RabbitMQ] Use RabbitMQ 3.0.0 docs
* [FLINK-30485][Connector/RabbitMQ] Remove RabbitMQ docs
* [FLINK-30485][Connector/RabbitMQ] Remove RabbitMQ connector
---
.../docs/connectors/datastream/rabbitmq.md | 230 ------
.../content/docs/connectors/datastream/rabbitmq.md | 254 ------
docs/data/sql_connectors.yml | 2 +-
docs/setup_docs.sh | 1 +
.../5b9eed8a-5fb6-4373-98ac-3be2a71941b8 | 2 +-
.../flink-architecture-tests-production/pom.xml | 5 -
flink-architecture-tests/pom.xml | 7 -
.../flink-connector-rabbitmq/README.md | 11 -
.../22086d11-ddf8-434e-96c5-fa40a17ab23e | 0
.../621a723f-8a32-41f8-b2a5-9af8e4826fe7 | 0
.../archunit-violations/stored.rules | 4 -
flink-connectors/flink-connector-rabbitmq/pom.xml | 94 ---
.../connectors/rabbitmq/QueueingConsumer.java | 159 ----
.../rabbitmq/RMQDeserializationSchema.java | 104 ---
.../rabbitmq/RMQDeserializationSchemaWrapper.java | 64 --
.../streaming/connectors/rabbitmq/RMQSink.java | 269 -------
.../connectors/rabbitmq/RMQSinkPublishOptions.java | 80 --
.../streaming/connectors/rabbitmq/RMQSource.java | 442 -----------
.../rabbitmq/SerializableReturnListener.java | 26 -
.../flink/streaming/connectors/rabbitmq/Util.java | 36 -
.../rabbitmq/common/RMQConnectionConfig.java | 608 ---------------
.../architecture/TestCodeArchitectureTest.java | 40 -
.../streaming/connectors/rabbitmq/RMQSinkTest.java | 364 ---------
.../connectors/rabbitmq/RMQSourceITCase.java | 242 ------
.../connectors/rabbitmq/RMQSourceTest.java | 852 ---------------------
.../rabbitmq/common/RMQConnectionConfigTest.java | 189 -----
.../org.junit.jupiter.api.extension.Extension | 16 -
.../src/test/resources/archunit.properties | 31 -
.../src/test/resources/log4j2-test.properties | 28 -
.../flink-sql-connector-rabbitmq/pom.xml | 82 --
.../src/main/resources/META-INF/NOTICE | 9 -
flink-connectors/pom.xml | 2 -
flink-python/pom.xml | 2 +-
.../org/apache/flink/util/DockerImageVersions.java | 2 -
tools/ci/stage.sh | 2 -
35 files changed, 4 insertions(+), 4255 deletions(-)
diff --git a/docs/content.zh/docs/connectors/datastream/rabbitmq.md b/docs/content.zh/docs/connectors/datastream/rabbitmq.md
deleted file mode 100644
index aee35b45bac..00000000000
--- a/docs/content.zh/docs/connectors/datastream/rabbitmq.md
+++ /dev/null
@@ -1,230 +0,0 @@
----
-title: RabbitMQ
-weight: 7
-type: docs
-aliases:
- - /zh/dev/connectors/rabbitmq.html
----
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-
-# RabbitMQ 连接器
-
-## RabbitMQ 连接器的许可证
-
-Flink 的 RabbitMQ 连接器依赖了 "RabbitMQ AMQP Java Client",它基于三种协议下发行:Mozilla Public License 1.1 ("MPL")、GNU General Public License version 2 ("GPL") 和 Apache License version 2 ("ASL")。
-
-Flink 自身既没有复用 "RabbitMQ AMQP Java Client" 的代码,也没有将 "RabbitMQ AMQP Java Client" 打二进制包。
-
-如果用户发布的内容是基于 Flink 的 RabbitMQ 连接器的(进而重新发布了 "RabbitMQ AMQP Java Client" ),那么一定要注意这可能会受到 Mozilla Public License 1.1 ("MPL")、GNU General Public License version 2 ("GPL")、Apache License version 2 ("ASL") 协议的限制.
-
-## RabbitMQ 连接器
-
-这个连接器可以访问 [RabbitMQ](http://www.rabbitmq.com/) 的数据流。使用这个连接器,需要在工程里添加下面的依赖:
-
-{{< artifact flink-connector-rabbitmq >}}
-
-{{< py_download_link "rabbitmq" >}}
-
-注意连接器现在没有包含在二进制发行版中。集群执行的相关信息请参考 [这里]({{< ref "docs/dev/configuration/overview" >}}).
-
-### 安装 RabbitMQ
-安装 RabbitMQ 请参考 [RabbitMQ 下载页面](http://www.rabbitmq.com/download.html)。安装完成之后,服务会自动拉起,应用程序就可以尝试连接到 RabbitMQ 了。
-
-### RabbitMQ Source
-
-`RMQSource` 负责从 RabbitMQ 中消费数据,可以配置三种不同级别的保证:
-
-1. **精确一次**: 保证精确一次需要以下条件 -
- - *开启 checkpointing*: 开启 checkpointing 之后,消息在 checkpoints
- 完成之后才会被确认(然后从 RabbitMQ 队列中删除).
- - *使用关联标识(Correlation ids)*: 关联标识是 RabbitMQ 的一个特性,消息写入 RabbitMQ 时在消息属性中设置。
- 从 checkpoint 恢复时有些消息可能会被重复处理,source 可以利用关联标识对消息进行去重。
- - *非并发 source*: 为了保证精确一次的数据投递,source 必须是非并发的(并行度设置为1)。
- 这主要是由于 RabbitMQ 分发数据时是从单队列向多个消费者投递消息的。
-
-2. **至少一次**: 在 checkpointing 开启的条件下,如果没有使用关联标识或者 source 是并发的,
-那么 source 就只能提供至少一次的保证。
-
-3. **无任何保证**: 如果没有开启 checkpointing,source 就不能提供任何的数据投递保证。
-使用这种设置时,source 一旦接收到并处理消息,消息就会被自动确认。
-
-下面是一个保证 exactly-once 的 RabbitMQ source 示例。 注释部分展示了更加宽松的保证应该如何配置。
-
-{{< tabs "62892e62-eb37-4fed-aa0f-64690135b4d6" >}}
-{{< tab "Java" >}}
-```java
-final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
-// checkpointing is required for exactly-once or at-least-once guarantees
-env.enableCheckpointing(...);
-
-final RMQConnectionConfig connectionConfig = new RMQConnectionConfig.Builder()
- .setHost("localhost")
- .setPort(5000)
- ...
- .build();
-
-final DataStream<String> stream = env
- .addSource(new RMQSource<String>(
- connectionConfig, // config for the RabbitMQ connection
- "queueName", // name of the RabbitMQ queue to consume
- true, // use correlation ids; can be false if only at-least-once is required
- new SimpleStringSchema())) // deserialization schema to turn messages into Java objects
- .setParallelism(1); // non-parallel source is only required for exactly-once
-```
-{{< /tab >}}
-{{< tab "Scala" >}}
-```scala
-val env = StreamExecutionEnvironment.getExecutionEnvironment
-// checkpointing is required for exactly-once or at-least-once guarantees
-env.enableCheckpointing(...)
-
-val connectionConfig = new RMQConnectionConfig.Builder()
- .setHost("localhost")
- .setPort(5000)
- ...
- .build
-
-val stream = env
- .addSource(new RMQSource[String](
- connectionConfig, // config for the RabbitMQ connection
- "queueName", // name of the RabbitMQ queue to consume
- true, // use correlation ids; can be false if only at-least-once is required
- new SimpleStringSchema)) // deserialization schema to turn messages into Java objects
- .setParallelism(1) // non-parallel source is only required for exactly-once
-```
-{{< /tab >}}
-{{< tab "Python" >}}
-```python
-env = StreamExecutionEnvironment.get_execution_environment()
-# checkpointing is required for exactly-once or at-least-once guarantees
-env.enable_checkpointing(...)
-
-connection_config = RMQConnectionConfig.Builder() \
- .set_host("localhost") \
- .set_port(5000) \
- ...
- .build()
-
-stream = env \
- .add_source(RMQSource(
- connection_config,
- "queueName",
- True,
- SimpleStringSchema(),
- )) \
- .set_parallelism(1)
-```
-{{< /tab >}}
-{{< /tabs >}}
-
-#### 服务质量 (QoS) / 消费者预取(Consumer Prefetch)
-
-RabbitMQ Source 通过 `RMQConnectionConfig` 类提供了一种简单的方式,来设置 source channel 上的 `basicQos`(见下方示例)。要注意的是这里的 prefetch count 是对单个 channel 设置的,并且由于每个并发的 source 都持有一个 connection/channel,因此这个值实际上会乘以 source 的并行度,来表示同一时间可以向这个 job 总共发送多少条未确认的消息。如果需要更复杂的配置,可以通过重写 `RMQSource#setupChannel(Connection)` 方法来实现手动配置。
-
-{{< tabs "a899561b-bd98-4b65-a3a3-b81ee1f1f677" >}}
-{{< tab "Java" >}}
-```java
-final RMQConnectionConfig connectionConfig = new RMQConnectionConfig.Builder()
- .setPrefetchCount(30_000)
- ...
- .build();
-
-```
-{{< /tab >}}
-{{< tab "Scala" >}}
-```scala
-val connectionConfig = new RMQConnectionConfig.Builder()
- .setPrefetchCount(30000)
- ...
- .build
-```
-{{< /tab >}}
-{{< tab "Python" >}}
-```python
-connection_config = RMQConnectionConfig.Builder() \
- .set_prefetch_count(30000) \
- ...
- .build()
-```
-{{< /tab >}}
-{{< /tabs >}}
-
-RabbitMQ Source 默认情况下是不设置 prefetch count 的,这意味着 RabbitMQ 服务器将会无限制地向 source 发送消息。因此在生产环境中,最好要设置它。当消费海量数据的队列并且启用 checkpointing 时,消息只有在做完 checkpoint 后才会被确认,因此也许需要对 prefetch count 做一些调整来减少不必要的循环。
-
-更多关于 QoS 以及 prefetch 相关的内容可以参考 [这里](https://www.rabbitmq.com/confirms.html#channel-qos-prefetch).
-更多关于在 AMQP 0-9-1 中可选的选项可以参考 [这里](https://www.rabbitmq.com/consumer-prefetch.html).
-
-### RabbitMQ Sink
-该连接器提供了一个 `RMQSink` 类,用来向 RabbitMQ 队列发送数据。下面是设置 RabbitMQ sink 的代码示例:
-
-{{< tabs "b8966b60-db25-4853-8382-751bbe1a89c7" >}}
-{{< tab "Java" >}}
-```java
-final DataStream<String> stream = ...
-
-final RMQConnectionConfig connectionConfig = new RMQConnectionConfig.Builder()
- .setHost("localhost")
- .setPort(5000)
- ...
- .build();
-
-stream.addSink(new RMQSink<String>(
- connectionConfig, // config for the RabbitMQ connection
- "queueName", // name of the RabbitMQ queue to send messages to
- new SimpleStringSchema())); // serialization schema to turn Java objects to messages
-```
-{{< /tab >}}
-{{< tab "Scala" >}}
-```scala
-val stream: DataStream[String] = ...
-
-val connectionConfig = new RMQConnectionConfig.Builder()
- .setHost("localhost")
- .setPort(5000)
- ...
- .build
-
-stream.addSink(new RMQSink[String](
- connectionConfig, // config for the RabbitMQ connection
- "queueName", // name of the RabbitMQ queue to send messages to
- new SimpleStringSchema)) // serialization schema to turn Java objects to messages
-```
-{{< /tab >}}
-{{< tab "Python" >}}
-```python
-stream = ...
-
-connection_config = RMQConnectionConfig.Builder() \
- .set_host("localhost") \
- .set_port(5000) \
- ...
- .build()
-
-stream.add_sink(RMQSink(
- connection_config, # config for the RabbitMQ connection
- 'queueName', # name of the RabbitMQ queue to send messages to
- SimpleStringSchema())) # serialization schema to turn Java objects to messages
-```
-{{< /tab >}}
-{{< /tabs >}}
-
-更多关于 RabbitMQ 的信息请参考 [这里](http://www.rabbitmq.com/).
-
-{{< top >}}
diff --git a/docs/content/docs/connectors/datastream/rabbitmq.md b/docs/content/docs/connectors/datastream/rabbitmq.md
deleted file mode 100644
index 78fbccf5f53..00000000000
--- a/docs/content/docs/connectors/datastream/rabbitmq.md
+++ /dev/null
@@ -1,254 +0,0 @@
----
-title: RabbitMQ
-weight: 7
-type: docs
-aliases:
- - /dev/connectors/rabbitmq.html
----
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-
-# RabbitMQ Connector
-
-## License of the RabbitMQ Connector
-
-Flink's RabbitMQ connector defines a Maven dependency on the
-"RabbitMQ AMQP Java Client", is triple-licensed under the Mozilla Public License 1.1 ("MPL"), the GNU General Public License version 2 ("GPL") and the Apache License version 2 ("ASL").
-
-Flink itself neither reuses source code from the "RabbitMQ AMQP Java Client"
-nor packages binaries from the "RabbitMQ AMQP Java Client".
-
-Users that create and publish derivative work based on Flink's
-RabbitMQ connector (thereby re-distributing the "RabbitMQ AMQP Java Client")
-must be aware that this may be subject to conditions declared in the Mozilla Public License 1.1 ("MPL"), the GNU General Public License version 2 ("GPL") and the Apache License version 2 ("ASL").
-
-## RabbitMQ Connector
-
-This connector provides access to data streams from [RabbitMQ](http://www.rabbitmq.com/). To use this connector, add the following dependency to your project:
-
-{{< artifact flink-connector-rabbitmq >}}
-
-{{< py_download_link "rabbitmq" >}}
-
-Note that the streaming connectors are currently not part of the binary distribution. See linking with them for cluster execution [here]({{< ref "docs/dev/configuration/overview" >}}).
-
-### Installing RabbitMQ
-Follow the instructions from the [RabbitMQ download page](http://www.rabbitmq.com/download.html). After the installation the server automatically starts, and the application connecting to RabbitMQ can be launched.
-
-### RabbitMQ Source
-
-This connector provides a `RMQSource` class to consume messages from a RabbitMQ
-queue. This source provides three different levels of guarantees, depending
-on how it is configured with Flink:
-
-1. **Exactly-once**: In order to achieve exactly-once guarantees with the
-RabbitMQ source, the following is required -
- - *Enable checkpointing*: With checkpointing enabled, messages are only
- acknowledged (hence, removed from the RabbitMQ queue) when checkpoints
- are completed.
- - *Use correlation ids*: Correlation ids are a RabbitMQ application feature.
- You have to set it in the message properties when injecting messages into RabbitMQ.
- The correlation id is used by the source to deduplicate any messages that
- have been reprocessed when restoring from a checkpoint.
- - *Non-parallel source*: The source must be non-parallel (parallelism set
- to 1) in order to achieve exactly-once. This limitation is mainly due to
- RabbitMQ's approach to dispatching messages from a single queue to multiple
- consumers.
-
-
-2. **At-least-once**: When checkpointing is enabled, but correlation ids
-are not used or the source is parallel, the source only provides at-least-once
-guarantees.
-
-3. **No guarantee**: If checkpointing isn't enabled, the source does not
-have any strong delivery guarantees. Under this setting, instead of
-collaborating with Flink's checkpointing, messages will be automatically
-acknowledged once the source receives and processes them.
-
-Below is a code example for setting up an exactly-once RabbitMQ source.
-Inline comments explain which parts of the configuration can be ignored
-for more relaxed guarantees.
-
-{{< tabs "2674efc2-62ce-4c21-9399-7cf23c211f9f" >}}
-{{< tab "Java" >}}
-```java
-final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
-// checkpointing is required for exactly-once or at-least-once guarantees
-env.enableCheckpointing(...);
-
-final RMQConnectionConfig connectionConfig = new RMQConnectionConfig.Builder()
- .setHost("localhost")
- .setPort(5000)
- ...
- .build();
-
-final DataStream<String> stream = env
- .addSource(new RMQSource<String>(
- connectionConfig, // config for the RabbitMQ connection
- "queueName", // name of the RabbitMQ queue to consume
- true, // use correlation ids; can be false if only at-least-once is required
- new SimpleStringSchema())) // deserialization schema to turn messages into Java objects
- .setParallelism(1); // non-parallel source is only required for exactly-once
-```
-{{< /tab >}}
-{{< tab "Scala" >}}
-```scala
-val env = StreamExecutionEnvironment.getExecutionEnvironment
-// checkpointing is required for exactly-once or at-least-once guarantees
-env.enableCheckpointing(...)
-
-val connectionConfig = new RMQConnectionConfig.Builder()
- .setHost("localhost")
- .setPort(5000)
- ...
- .build
-
-val stream = env
- .addSource(new RMQSource[String](
- connectionConfig, // config for the RabbitMQ connection
- "queueName", // name of the RabbitMQ queue to consume
- true, // use correlation ids; can be false if only at-least-once is required
- new SimpleStringSchema)) // deserialization schema to turn messages into Java objects
- .setParallelism(1) // non-parallel source is only required for exactly-once
-```
-{{< /tab >}}
-{{< tab "Python" >}}
-```python
-env = StreamExecutionEnvironment.get_execution_environment()
-# checkpointing is required for exactly-once or at-least-once guarantees
-env.enable_checkpointing(...)
-
-connection_config = RMQConnectionConfig.Builder() \
- .set_host("localhost") \
- .set_port(5000) \
- ...
- .build()
-
-stream = env \
- .add_source(RMQSource(
- connection_config,
- "queueName",
- True,
- SimpleStringSchema(),
- )) \
- .set_parallelism(1)
-```
-{{< /tab >}}
-{{< /tabs >}}
-
-#### Quality of Service (QoS) / Consumer Prefetch
-
-The RabbitMQ Source provides a simple way to set the `basicQos` on the source's channel through the `RMQConnectionConfig`.
-Since there is one connection/ channel per-parallel source, this prefetch count will effectively be multiplied by the
-source's parallelism for how many total unacknowledged messages can be sent to the job at one time.
-If more complex configuration is required, `RMQSource#setupChannel(Connection)` can be overridden and manually configured.
-
-{{< tabs "e0b303d2-1bda-43fd-8335-f71eae1a8f6d" >}}
-{{< tab "Java" >}}
-```java
-final RMQConnectionConfig connectionConfig = new RMQConnectionConfig.Builder()
- .setPrefetchCount(30_000)
- ...
- .build();
-
-```
-{{< /tab >}}
-{{< tab "Scala" >}}
-```scala
-val connectionConfig = new RMQConnectionConfig.Builder()
- .setPrefetchCount(30000)
- ...
- .build
-```
-{{< /tab >}}
-{{< tab "Python" >}}
-```python
-connection_config = RMQConnectionConfig.Builder() \
- .set_prefetch_count(30000) \
- ...
- .build()
-```
-{{< /tab >}}
-{{< /tabs >}}
-
-The prefetch count is unset by default, meaning the RabbitMQ server will send unlimited messages. In production, it
-is best to set this value. For high volume queues and checkpointing enabled, some tuning may be required to reduce
-wasted cycles, as messages are only acknowledged on checkpoints if enabled.
-
-More about QoS and prefetch can be found [here](https://www.rabbitmq.com/confirms.html#channel-qos-prefetch)
-and more about the options available in AMQP 0-9-1 [here](https://www.rabbitmq.com/consumer-prefetch.html).
-
-### RabbitMQ Sink
-This connector provides a `RMQSink` class for sending messages to a RabbitMQ
-queue. Below is a code example for setting up a RabbitMQ sink.
-
-{{< tabs "78baf6a6-5967-44cc-851d-bdf759598728" >}}
-{{< tab "Java" >}}
-```java
-final DataStream<String> stream = ...
-
-final RMQConnectionConfig connectionConfig = new RMQConnectionConfig.Builder()
- .setHost("localhost")
- .setPort(5000)
- ...
- .build();
-
-stream.addSink(new RMQSink<String>(
- connectionConfig, // config for the RabbitMQ connection
- "queueName", // name of the RabbitMQ queue to send messages to
- new SimpleStringSchema())); // serialization schema to turn Java objects to messages
-```
-{{< /tab >}}
-{{< tab "Scala" >}}
-```scala
-val stream: DataStream[String] = ...
-
-val connectionConfig = new RMQConnectionConfig.Builder()
- .setHost("localhost")
- .setPort(5000)
- ...
- .build
-
-stream.addSink(new RMQSink[String](
- connectionConfig, // config for the RabbitMQ connection
- "queueName", // name of the RabbitMQ queue to send messages to
- new SimpleStringSchema)) // serialization schema to turn Java objects to messages
-```
-{{< /tab >}}
-{{< tab "Python" >}}
-```python
-stream = ...
-
-connection_config = RMQConnectionConfig.Builder() \
- .set_host("localhost") \
- .set_port(5000) \
- ...
- .build()
-
-stream.add_sink(RMQSink(
- connection_config, # config for the RabbitMQ connection
- 'queueName', # name of the RabbitMQ queue to send messages to
- SimpleStringSchema())) # serialization schema to turn Java objects to messages
-```
-{{< /tab >}}
-{{< /tabs >}}
-
-More about RabbitMQ can be found [here](http://www.rabbitmq.com/).
-
-{{< top >}}
diff --git a/docs/data/sql_connectors.yml b/docs/data/sql_connectors.yml
index 936440d3542..5d219bda78b 100644
--- a/docs/data/sql_connectors.yml
+++ b/docs/data/sql_connectors.yml
@@ -200,4 +200,4 @@ rabbitmq:
name: RabbitMQ
category: connector
maven: flink-connector-rabbitmq
- sql_url: https://repo.maven.apache.org/maven2/org/apache/flink/flink-sql-connector-rabbitmq/$version/flink-sql-connector-rabbitmq-$version.jar
+ sql_url: https://repo.maven.apache.org/maven2/org/apache/flink/flink-sql-connector-rabbitmq/3.0.0-1.16/flink-sql-connector-rabbitmq-3.0.0-1.16.jar
diff --git a/docs/setup_docs.sh b/docs/setup_docs.sh
index 6f11bda8d46..46e295fde95 100755
--- a/docs/setup_docs.sh
+++ b/docs/setup_docs.sh
@@ -67,6 +67,7 @@ integrate_connector_docs aws v4.0
integrate_connector_docs cassandra v3.0.0
integrate_connector_docs pulsar main "docs/layouts"
integrate_connector_docs jdbc v3.0.0
+integrate_connector_docs rabbitmq v3.0.0
cd ..
rm -rf tmp
diff --git a/flink-architecture-tests/flink-architecture-tests-production/archunit-violations/5b9eed8a-5fb6-4373-98ac-3be2a71941b8 b/flink-architecture-tests/flink-architecture-tests-production/archunit-violations/5b9eed8a-5fb6-4373-98ac-3be2a71941b8
index e11c5ffd820..3926bd7cf62 100644
--- a/flink-architecture-tests/flink-architecture-tests-production/archunit-violations/5b9eed8a-5fb6-4373-98ac-3be2a71941b8
+++ b/flink-architecture-tests/flink-architecture-tests-production/archunit-violations/5b9eed8a-5fb6-4373-98ac-3be2a71941b8
@@ -369,10 +369,10 @@ org.apache.flink.streaming.api.windowing.triggers.Trigger.onProcessingTime(long,
org.apache.flink.streaming.api.windowing.windows.TimeWindow.mergeWindows(java.util.Collection, org.apache.flink.streaming.api.windowing.assigners.MergingWindowAssigner$MergeCallback): Argument leaf type org.apache.flink.streaming.api.windowing.assigners.MergingWindowAssigner$MergeCallback does not satisfy: reside outside of package 'org.apache.flink..' or reside in any package ['..shaded..'] or annotated with @Public or annotated with @PublicEvolving or annotated with @Deprecated
org.apache.flink.streaming.connectors.kafka.FlinkKafkaProducer.invoke(org.apache.flink.streaming.connectors.kafka.FlinkKafkaProducer$KafkaTransactionState, java.lang.Object, org.apache.flink.streaming.api.functions.sink.SinkFunction$Context): Argument leaf type org.apache.flink.streaming.connectors.kafka.FlinkKafkaProducer$KafkaTransactionState does not satisfy: reside outside of package 'org.apache.flink..' or reside in any package ['..shaded..'] or annotated with @Public or annotated w [...]
org.apache.flink.streaming.connectors.kafka.internals.KafkaTopicPartition.dropLeaderData(java.util.List): Argument leaf type org.apache.flink.streaming.connectors.kafka.internals.KafkaTopicPartitionLeader does not satisfy: reside outside of package 'org.apache.flink..' or reside in any package ['..shaded..'] or annotated with @Public or annotated with @PublicEvolving or annotated with @Deprecated
-org.apache.flink.streaming.connectors.rabbitmq.RMQDeserializationSchema.deserialize(com.rabbitmq.client.Envelope, com.rabbitmq.client.AMQP$BasicProperties, [B, org.apache.flink.streaming.connectors.rabbitmq.RMQDeserializationSchema$RMQCollector): Argument leaf type org.apache.flink.streaming.connectors.rabbitmq.RMQDeserializationSchema$RMQCollector does not satisfy: reside outside of package 'org.apache.flink..' or reside in any package ['..shaded..'] or annotated with @Public or annotat [...]
org.apache.flink.streaming.runtime.operators.windowing.TimestampedValue.from(org.apache.flink.streaming.runtime.streamrecord.StreamRecord): Argument leaf type org.apache.flink.streaming.runtime.streamrecord.StreamRecord does not satisfy: reside outside of package 'org.apache.flink..' or reside in any package ['..shaded..'] or annotated with @Public or annotated with @PublicEvolving or annotated with @Deprecated
org.apache.flink.streaming.runtime.operators.windowing.TimestampedValue.getStreamRecord(): Returned leaf type org.apache.flink.streaming.runtime.streamrecord.StreamRecord does not satisfy: reside outside of package 'org.apache.flink..' or reside in any package ['..shaded..'] or annotated with @Public or annotated with @PublicEvolving or annotated with @Deprecated
org.apache.flink.streaming.runtime.streamrecord.LatencyMarker.getOperatorId(): Returned leaf type org.apache.flink.runtime.jobgraph.OperatorID does not satisfy: reside outside of package 'org.apache.flink..' or reside in any package ['..shaded..'] or annotated with @Public or annotated with @PublicEvolving or annotated with @Deprecated
org.apache.flink.streaming.runtime.tasks.ProcessingTimeServiceAware.setProcessingTimeService(org.apache.flink.streaming.runtime.tasks.ProcessingTimeService): Argument leaf type org.apache.flink.streaming.runtime.tasks.ProcessingTimeService does not satisfy: reside outside of package 'org.apache.flink..' or reside in any package ['..shaded..'] or annotated with @Public or annotated with @PublicEvolving or annotated with @Deprecated
org.apache.flink.table.operations.QueryOperation.accept(org.apache.flink.table.operations.QueryOperationVisitor): Argument leaf type org.apache.flink.table.operations.QueryOperationVisitor does not satisfy: reside outside of package 'org.apache.flink..' or reside in any package ['..shaded..'] or annotated with @Public or annotated with @PublicEvolving or annotated with @Deprecated
org.apache.flink.types.parser.FieldParser.getErrorState(): Returned leaf type org.apache.flink.types.parser.FieldParser$ParseErrorState does not satisfy: reside outside of package 'org.apache.flink..' or reside in any package ['..shaded..'] or annotated with @Public or annotated with @PublicEvolving or annotated with @Deprecated
+
diff --git a/flink-architecture-tests/flink-architecture-tests-production/pom.xml b/flink-architecture-tests/flink-architecture-tests-production/pom.xml
index 7535f312da4..f78899b41b9 100644
--- a/flink-architecture-tests/flink-architecture-tests-production/pom.xml
+++ b/flink-architecture-tests/flink-architecture-tests-production/pom.xml
@@ -168,11 +168,6 @@ under the License.
<groupId>org.apache.flink</groupId>
<artifactId>flink-connector-kafka</artifactId>
</dependency>
-
- <dependency>
- <groupId>org.apache.flink</groupId>
- <artifactId>flink-connector-rabbitmq</artifactId>
- </dependency>
</dependencies>
<build>
diff --git a/flink-architecture-tests/pom.xml b/flink-architecture-tests/pom.xml
index 0ab7a4b5d6d..027a36457d6 100644
--- a/flink-architecture-tests/pom.xml
+++ b/flink-architecture-tests/pom.xml
@@ -195,13 +195,6 @@ under the License.
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.apache.flink</groupId>
- <artifactId>flink-connector-rabbitmq</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
-
<!-- Test Utils -->
<dependency>
diff --git a/flink-connectors/flink-connector-rabbitmq/README.md b/flink-connectors/flink-connector-rabbitmq/README.md
deleted file mode 100644
index de8d1d89c69..00000000000
--- a/flink-connectors/flink-connector-rabbitmq/README.md
+++ /dev/null
@@ -1,11 +0,0 @@
-# License of the Rabbit MQ Connector
-
-Flink's RabbitMQ connector defines a Maven dependency on the
-"RabbitMQ AMQP Java Client", is triple-licensed under the Mozilla Public License 1.1 ("MPL"), the GNU General Public License version 2 ("GPL") and the Apache License version 2 ("ASL").
-
-Flink itself neither reuses source code from the "RabbitMQ AMQP Java Client"
-nor packages binaries from the "RabbitMQ AMQP Java Client".
-
-Users that create and publish derivative work based on Flink's
-RabbitMQ connector (thereby re-distributing the "RabbitMQ AMQP Java Client")
-must be aware that this may be subject to conditions declared in the Mozilla Public License 1.1 ("MPL"), the GNU General Public License version 2 ("GPL") and the Apache License version 2 ("ASL").
diff --git a/flink-connectors/flink-connector-rabbitmq/archunit-violations/22086d11-ddf8-434e-96c5-fa40a17ab23e b/flink-connectors/flink-connector-rabbitmq/archunit-violations/22086d11-ddf8-434e-96c5-fa40a17ab23e
deleted file mode 100644
index e69de29bb2d..00000000000
diff --git a/flink-connectors/flink-connector-rabbitmq/archunit-violations/621a723f-8a32-41f8-b2a5-9af8e4826fe7 b/flink-connectors/flink-connector-rabbitmq/archunit-violations/621a723f-8a32-41f8-b2a5-9af8e4826fe7
deleted file mode 100644
index e69de29bb2d..00000000000
diff --git a/flink-connectors/flink-connector-rabbitmq/archunit-violations/stored.rules b/flink-connectors/flink-connector-rabbitmq/archunit-violations/stored.rules
deleted file mode 100644
index b275792239b..00000000000
--- a/flink-connectors/flink-connector-rabbitmq/archunit-violations/stored.rules
+++ /dev/null
@@ -1,4 +0,0 @@
-#
-#Tue Feb 22 12:18:57 CET 2022
-Tests\ inheriting\ from\ AbstractTestBase\ should\ have\ name\ ending\ with\ ITCase=22086d11-ddf8-434e-96c5-fa40a17ab23e
-ITCASE\ tests\ should\ use\ a\ MiniCluster\ resource\ or\ extension=621a723f-8a32-41f8-b2a5-9af8e4826fe7
diff --git a/flink-connectors/flink-connector-rabbitmq/pom.xml b/flink-connectors/flink-connector-rabbitmq/pom.xml
deleted file mode 100644
index 5987505b90d..00000000000
--- a/flink-connectors/flink-connector-rabbitmq/pom.xml
+++ /dev/null
@@ -1,94 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.flink</groupId>
- <artifactId>flink-connectors</artifactId>
- <version>1.17-SNAPSHOT</version>
- </parent>
-
- <artifactId>flink-connector-rabbitmq</artifactId>
- <name>Flink : Connectors : RabbitMQ</name>
-
- <packaging>jar</packaging>
-
- <!-- Allow users to pass custom connector versions -->
- <properties>
- <rabbitmq.version>5.13.1</rabbitmq.version>
- </properties>
-
- <dependencies>
-
- <dependency>
- <groupId>org.apache.flink</groupId>
- <artifactId>flink-streaming-java</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>com.rabbitmq</groupId>
- <artifactId>amqp-client</artifactId>
- <version>${rabbitmq.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.flink</groupId>
- <artifactId>flink-streaming-java</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- <type>test-jar</type>
- </dependency>
-
- <dependency>
- <groupId>org.apache.flink</groupId>
- <artifactId>flink-runtime</artifactId>
- <version>${project.version}</version>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.flink</groupId>
- <artifactId>flink-test-utils</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.testcontainers</groupId>
- <artifactId>rabbitmq</artifactId>
- <scope>test</scope>
- </dependency>
-
- <!-- ArchUit test dependencies -->
-
- <dependency>
- <groupId>org.apache.flink</groupId>
- <artifactId>flink-architecture-tests-test</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
-</project>
diff --git a/flink-connectors/flink-connector-rabbitmq/src/main/java/org/apache/flink/streaming/connectors/rabbitmq/QueueingConsumer.java b/flink-connectors/flink-connector-rabbitmq/src/main/java/org/apache/flink/streaming/connectors/rabbitmq/QueueingConsumer.java
deleted file mode 100644
index f2e351a2f12..00000000000
--- a/flink-connectors/flink-connector-rabbitmq/src/main/java/org/apache/flink/streaming/connectors/rabbitmq/QueueingConsumer.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// Changes made to the source, taken from com.rabbitmq:amqp-client:4.2.0:
-// - copied from com.rabbitmq.client.QueueingConsumer
-// - updated naming conventions for the Apache Flink standards
-
-package org.apache.flink.streaming.connectors.rabbitmq;
-
-import com.rabbitmq.client.AMQP;
-import com.rabbitmq.client.Channel;
-import com.rabbitmq.client.ConsumerCancelledException;
-import com.rabbitmq.client.DefaultConsumer;
-import com.rabbitmq.client.Delivery;
-import com.rabbitmq.client.Envelope;
-import com.rabbitmq.client.ShutdownSignalException;
-import com.rabbitmq.utility.Utility;
-
-import java.io.IOException;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.TimeUnit;
-
-class QueueingConsumer extends DefaultConsumer {
- private final BlockingQueue<Delivery> queue;
-
- // When this is non-null the queue is in shutdown mode and nextDelivery should
- // throw a shutdown signal exception.
- private volatile ShutdownSignalException shutdown;
- private volatile ConsumerCancelledException cancelled;
-
- // Marker object used to signal the queue is in shutdown mode.
- // It is only there to wake up consumers. The canonical representation
- // of shutting down is the presence of shutdown.
- // Invariant: This is never on queue unless shutdown != null.
- private static final Delivery POISON = new Delivery(null, null, null);
-
- public QueueingConsumer(Channel channel) {
- this(channel, Integer.MAX_VALUE);
- }
-
- public QueueingConsumer(Channel channel, int capacity) {
- super(channel);
- this.queue = new LinkedBlockingQueue<>(capacity);
- }
-
- /** Check if we are in shutdown mode and if so throw an exception. */
- private void checkShutdown() {
- if (shutdown != null) {
- throw Utility.fixStackTrace(shutdown);
- }
- }
-
- /**
- * If delivery is not POISON nor null, return it.
- *
- * <p>If delivery, shutdown and cancelled are all null, return null.
- *
- * <p>If delivery is POISON re-insert POISON into the queue and throw an exception if POISONed
- * for no reason.
- *
- * <p>Otherwise, if we are in shutdown mode or cancelled, throw a corresponding exception.
- */
- private Delivery handle(Delivery delivery) {
- if (delivery == POISON || delivery == null && (shutdown != null || cancelled != null)) {
- if (delivery == POISON) {
- queue.add(POISON);
- if (shutdown == null && cancelled == null) {
- throw new IllegalStateException(
- "POISON in queue, but null shutdown and null cancelled. "
- + "This should never happen, please report as a BUG");
- }
- }
- if (null != shutdown) {
- throw Utility.fixStackTrace(shutdown);
- }
- if (null != cancelled) {
- throw Utility.fixStackTrace(cancelled);
- }
- }
- return delivery;
- }
-
- /**
- * Main application-side API: wait for the next message delivery and return it.
- *
- * @return the next message
- * @throws InterruptedException if an interrupt is received while waiting
- * @throws ShutdownSignalException if the connection is shut down while waiting
- * @throws ConsumerCancelledException if this consumer is cancelled while waiting
- */
- public Delivery nextDelivery()
- throws InterruptedException, ShutdownSignalException, ConsumerCancelledException {
- return handle(queue.take());
- }
-
- /**
- * Main application-side API: wait for the next message delivery and return it.
- *
- * @param timeout timeout in millisecond
- * @return the next message or null if timed out
- * @throws InterruptedException if an interrupt is received while waiting
- * @throws ShutdownSignalException if the connection is shut down while waiting
- * @throws ConsumerCancelledException if this consumer is cancelled while waiting
- */
- public Delivery nextDelivery(long timeout)
- throws InterruptedException, ShutdownSignalException, ConsumerCancelledException {
- return nextDelivery(timeout, TimeUnit.MILLISECONDS);
- }
-
- /**
- * Main application-side API: wait for the next message delivery and return it.
- *
- * @param timeout timeout
- * @param unit timeout unit
- * @return the next message or null if timed out
- * @throws InterruptedException if an interrupt is received while waiting
- * @throws ShutdownSignalException if the connection is shut down while waiting
- * @throws ConsumerCancelledException if this consumer is cancelled while waiting
- */
- public Delivery nextDelivery(long timeout, TimeUnit unit)
- throws InterruptedException, ShutdownSignalException, ConsumerCancelledException {
- return handle(queue.poll(timeout, unit));
- }
-
- @Override
- public void handleShutdownSignal(String consumerTag, ShutdownSignalException sig) {
- shutdown = sig;
- queue.add(POISON);
- }
-
- @Override
- public void handleCancel(String consumerTag) throws IOException {
- cancelled = new ConsumerCancelledException();
- queue.add(POISON);
- }
-
- @Override
- public void handleDelivery(
- String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body)
- throws IOException {
- checkShutdown();
- this.queue.add(new Delivery(envelope, properties, body));
- }
-}
diff --git a/flink-connectors/flink-connector-rabbitmq/src/main/java/org/apache/flink/streaming/connectors/rabbitmq/RMQDeserializationSchema.java b/flink-connectors/flink-connector-rabbitmq/src/main/java/org/apache/flink/streaming/connectors/rabbitmq/RMQDeserializationSchema.java
deleted file mode 100644
index f2e22ec1e44..00000000000
--- a/flink-connectors/flink-connector-rabbitmq/src/main/java/org/apache/flink/streaming/connectors/rabbitmq/RMQDeserializationSchema.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.flink.streaming.connectors.rabbitmq;
-
-import org.apache.flink.annotation.PublicEvolving;
-import org.apache.flink.api.common.serialization.DeserializationSchema;
-import org.apache.flink.api.java.typeutils.ResultTypeQueryable;
-import org.apache.flink.util.Collector;
-
-import com.rabbitmq.client.AMQP;
-import com.rabbitmq.client.Envelope;
-
-import java.io.IOException;
-import java.io.Serializable;
-
-/**
- * Interface for the set of methods required to parse an RMQ delivery.
- *
- * @param <T> The output type of the {@link RMQSource}
- */
-@PublicEvolving
-public interface RMQDeserializationSchema<T> extends Serializable, ResultTypeQueryable<T> {
-
- /**
- * Initialization method for the schema. It is called before the actual working methods {@link
- * #deserialize} and thus suitable for one time setup work.
- *
- * <p>The provided {@link DeserializationSchema.InitializationContext} can be used to access
- * additional features such as e.g. registering user metrics.
- *
- * @param context Contextual information that can be used during initialization.
- */
- default void open(DeserializationSchema.InitializationContext context) throws Exception {}
-
- /**
- * This method takes all the RabbitMQ delivery information supplied by the client extract the
- * data and pass it to the collector.
- *
- * <p><b>NOTICE:</b> The implementation of this method can call {@link
- * RMQCollector#setMessageIdentifiers} with a custom correlation ID and delivery tag if
- * checkpointing and {@code useCorrelationID} were enabled in the constructor of {@link
- * RMQSource}.
- *
- * @param envelope an AMQP {@link Envelope}.
- * @param properties the {@link AMQP.BasicProperties} of the message.
- * @param body the message itself as a byte array.
- * @param collector the {@link RMQCollector} that will collect the data.
- * @throws IOException When the body of the message can't be parsed
- */
- void deserialize(
- Envelope envelope,
- AMQP.BasicProperties properties,
- byte[] body,
- RMQCollector<T> collector)
- throws IOException;
-
- /**
- * Method to decide whether the element signals the end of the stream. If true is returned the
- * element won't be emitted.
- *
- * @param nextElement The element to test for the end-of-stream signal.
- * @return True, if the element signals end of stream, false otherwise.
- */
- boolean isEndOfStream(T nextElement);
-
- /**
- * Special collector for RMQ messages.
- *
- * <p>It extends the {@link Collector} to give the ability to collect more than 1 message and
- * the ability to set the message correlationId and deliveryTag.
- */
- interface RMQCollector<T> extends Collector<T> {
- /**
- * Sets the correlation id and the delivery tag that corresponds to the records originating
- * from the RMQ event. If the correlation id has been processed before, records will not be
- * emitted downstream.
- *
- * <p>If not set explicitly, the {@link AMQP.BasicProperties#getCorrelationId()} and {@link
- * Envelope#getDeliveryTag()} will be used.
- *
- * <p><b>NOTE:</b>Can be called once for a single invocation of a {@link
- * RMQDeserializationSchema#deserialize(Envelope, AMQP.BasicProperties, byte[],
- * RMQCollector)} method.
- *
- * @return true, if a message with given correlationId was seen before
- */
- boolean setMessageIdentifiers(String correlationId, long deliveryTag);
- }
-}
diff --git a/flink-connectors/flink-connector-rabbitmq/src/main/java/org/apache/flink/streaming/connectors/rabbitmq/RMQDeserializationSchemaWrapper.java b/flink-connectors/flink-connector-rabbitmq/src/main/java/org/apache/flink/streaming/connectors/rabbitmq/RMQDeserializationSchemaWrapper.java
deleted file mode 100644
index 0ddf91cb69f..00000000000
--- a/flink-connectors/flink-connector-rabbitmq/src/main/java/org/apache/flink/streaming/connectors/rabbitmq/RMQDeserializationSchemaWrapper.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.flink.streaming.connectors.rabbitmq;
-
-import org.apache.flink.api.common.serialization.DeserializationSchema;
-import org.apache.flink.api.common.typeinfo.TypeInformation;
-
-import com.rabbitmq.client.AMQP;
-import com.rabbitmq.client.Envelope;
-
-import java.io.IOException;
-
-/**
- * A default {@link RMQDeserializationSchema} implementation that uses the provided {@link
- * DeserializationSchema} to parse the message body.
- */
-final class RMQDeserializationSchemaWrapper<OUT> implements RMQDeserializationSchema<OUT> {
- private final DeserializationSchema<OUT> schema;
-
- RMQDeserializationSchemaWrapper(DeserializationSchema<OUT> deserializationSchema) {
- schema = deserializationSchema;
- }
-
- @Override
- public void deserialize(
- Envelope envelope,
- AMQP.BasicProperties properties,
- byte[] body,
- RMQCollector<OUT> collector)
- throws IOException {
- collector.collect(schema.deserialize(body));
- }
-
- @Override
- public TypeInformation<OUT> getProducedType() {
- return schema.getProducedType();
- }
-
- @Override
- public void open(DeserializationSchema.InitializationContext context) throws Exception {
- schema.open(context);
- }
-
- @Override
- public boolean isEndOfStream(OUT nextElement) {
- return schema.isEndOfStream(nextElement);
- }
-}
diff --git a/flink-connectors/flink-connector-rabbitmq/src/main/java/org/apache/flink/streaming/connectors/rabbitmq/RMQSink.java b/flink-connectors/flink-connector-rabbitmq/src/main/java/org/apache/flink/streaming/connectors/rabbitmq/RMQSink.java
deleted file mode 100644
index d0eb0efacc1..00000000000
--- a/flink-connectors/flink-connector-rabbitmq/src/main/java/org/apache/flink/streaming/connectors/rabbitmq/RMQSink.java
+++ /dev/null
@@ -1,269 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.flink.streaming.connectors.rabbitmq;
-
-import org.apache.flink.annotation.PublicEvolving;
-import org.apache.flink.api.common.serialization.RuntimeContextInitializationContextAdapters;
-import org.apache.flink.api.common.serialization.SerializationSchema;
-import org.apache.flink.configuration.Configuration;
-import org.apache.flink.streaming.api.functions.sink.RichSinkFunction;
-import org.apache.flink.streaming.connectors.rabbitmq.common.RMQConnectionConfig;
-import org.apache.flink.util.Preconditions;
-
-import com.rabbitmq.client.Channel;
-import com.rabbitmq.client.Connection;
-import com.rabbitmq.client.ConnectionFactory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.annotation.Nullable;
-
-import java.io.IOException;
-import java.util.concurrent.TimeoutException;
-
-/**
- * A Sink for publishing data into RabbitMQ.
- *
- * @param <IN>
- */
-public class RMQSink<IN> extends RichSinkFunction<IN> {
- private static final long serialVersionUID = 1L;
-
- private static final Logger LOG = LoggerFactory.getLogger(RMQSink.class);
-
- @Nullable protected final String queueName;
-
- private final RMQConnectionConfig rmqConnectionConfig;
- protected transient Connection connection;
- protected transient Channel channel;
- protected SerializationSchema<IN> schema;
- private boolean logFailuresOnly = false;
-
- @Nullable private final RMQSinkPublishOptions<IN> publishOptions;
-
- @Nullable private final SerializableReturnListener returnListener;
-
- /**
- * @param rmqConnectionConfig The RabbitMQ connection configuration {@link RMQConnectionConfig}.
- * @param queueName The queue to publish messages to.
- * @param schema A {@link SerializationSchema} for turning the Java objects received into bytes
- * @param publishOptions A {@link RMQSinkPublishOptions} for providing message's routing key
- * and/or properties
- * @param returnListener A SerializableReturnListener implementation object to handle returned
- * message event
- */
- private RMQSink(
- RMQConnectionConfig rmqConnectionConfig,
- @Nullable String queueName,
- SerializationSchema<IN> schema,
- @Nullable RMQSinkPublishOptions<IN> publishOptions,
- @Nullable SerializableReturnListener returnListener) {
- this.rmqConnectionConfig = rmqConnectionConfig;
- this.queueName = queueName;
- this.schema = schema;
- this.publishOptions = publishOptions;
- this.returnListener = returnListener;
- }
-
- /**
- * @param rmqConnectionConfig The RabbitMQ connection configuration {@link RMQConnectionConfig}.
- * @param queueName The queue to publish messages to.
- * @param schema A {@link SerializationSchema} for turning the Java objects received into bytes
- */
- @PublicEvolving
- public RMQSink(
- RMQConnectionConfig rmqConnectionConfig,
- String queueName,
- SerializationSchema<IN> schema) {
- this(rmqConnectionConfig, queueName, schema, null, null);
- }
-
- /**
- * @param rmqConnectionConfig The RabbitMQ connection configuration {@link RMQConnectionConfig}.
- * @param schema A {@link SerializationSchema} for turning the Java objects received into bytes
- * @param publishOptions A {@link RMQSinkPublishOptions} for providing message's routing key
- * and/or properties In this case the computeMandatoy or computeImmediate MUST return false
- * otherwise an IllegalStateException is raised during runtime.
- */
- @PublicEvolving
- public RMQSink(
- RMQConnectionConfig rmqConnectionConfig,
- SerializationSchema<IN> schema,
- RMQSinkPublishOptions<IN> publishOptions) {
- this(rmqConnectionConfig, null, schema, publishOptions, null);
- }
-
- /**
- * @param rmqConnectionConfig The RabbitMQ connection configuration {@link RMQConnectionConfig}.
- * @param schema A {@link SerializationSchema} for turning the Java objects received into bytes
- * @param publishOptions A {@link RMQSinkPublishOptions} for providing message's routing key
- * and/or properties
- * @param returnListener A SerializableReturnListener implementation object to handle returned
- * message event
- */
- @PublicEvolving
- public RMQSink(
- RMQConnectionConfig rmqConnectionConfig,
- SerializationSchema<IN> schema,
- RMQSinkPublishOptions<IN> publishOptions,
- SerializableReturnListener returnListener) {
- this(rmqConnectionConfig, null, schema, publishOptions, returnListener);
- }
-
- /**
- * Sets up the queue. The default implementation just declares the queue. The user may override
- * this method to have a custom setup for the queue (i.e. binding the queue to an exchange or
- * defining custom queue parameters)
- */
- protected void setupQueue() throws IOException {
- if (queueName != null) {
- Util.declareQueueDefaults(channel, queueName);
- }
- }
-
- /**
- * Defines whether the producer should fail on errors, or only log them. If this is set to true,
- * then exceptions will be only logged, if set to false, exceptions will be eventually thrown
- * and cause the streaming program to fail (and enter recovery).
- *
- * @param logFailuresOnly The flag to indicate logging-only on exceptions.
- */
- public void setLogFailuresOnly(boolean logFailuresOnly) {
- this.logFailuresOnly = logFailuresOnly;
- }
-
- /**
- * Initializes the connection to RMQ with a default connection factory. The user may override
- * this method to setup and configure their own {@link ConnectionFactory}.
- */
- protected ConnectionFactory setupConnectionFactory() throws Exception {
- return rmqConnectionConfig.getConnectionFactory();
- }
-
- /**
- * Initializes the connection to RMQ using the default connection factory from {@link
- * #setupConnectionFactory()}. The user may override this method to setup and configure their
- * own {@link Connection}.
- */
- protected Connection setupConnection() throws Exception {
- return setupConnectionFactory().newConnection();
- }
-
- @Override
- public void open(Configuration config) throws Exception {
- schema.open(
- RuntimeContextInitializationContextAdapters.serializationAdapter(
- getRuntimeContext(), metricGroup -> metricGroup.addGroup("user")));
-
- try {
- connection = setupConnection();
- channel = connection.createChannel();
- if (channel == null) {
- throw new RuntimeException("None of RabbitMQ channels are available");
- }
- setupQueue();
- if (returnListener != null) {
- channel.addReturnListener(returnListener);
- }
- } catch (IOException e) {
- throw new RuntimeException("Error while creating the channel", e);
- }
- }
-
- /**
- * Called when new data arrives to the sink, and forwards it to RMQ.
- *
- * @param value The incoming data
- */
- @Override
- public void invoke(IN value) {
- try {
- byte[] msg = schema.serialize(value);
-
- if (publishOptions == null) {
- channel.basicPublish("", queueName, null, msg);
- } else {
- boolean mandatory = publishOptions.computeMandatory(value);
- boolean immediate = publishOptions.computeImmediate(value);
-
- Preconditions.checkState(
- !(returnListener == null && (mandatory || immediate)),
- "Setting mandatory and/or immediate flags to true requires a ReturnListener.");
-
- String rk = publishOptions.computeRoutingKey(value);
- String exchange = publishOptions.computeExchange(value);
-
- channel.basicPublish(
- exchange,
- rk,
- mandatory,
- immediate,
- publishOptions.computeProperties(value),
- msg);
- }
- } catch (IOException e) {
- if (logFailuresOnly) {
- LOG.error(
- "Cannot send RMQ message {} at {}",
- queueName,
- rmqConnectionConfig.getHost(),
- e);
- } else {
- throw new RuntimeException(
- "Cannot send RMQ message "
- + queueName
- + " at "
- + rmqConnectionConfig.getHost(),
- e);
- }
- }
- }
-
- @Override
- public void close() {
- Exception t = null;
- try {
- if (channel != null) {
- channel.close();
- }
- } catch (IOException | TimeoutException e) {
- t = e;
- }
-
- try {
- if (connection != null) {
- connection.close();
- }
- } catch (IOException e) {
- if (t != null) {
- LOG.warn(
- "Both channel and connection closing failed. Logging channel exception and failing with connection exception",
- t);
- }
- t = e;
- }
- if (t != null) {
- throw new RuntimeException(
- "Error while closing RMQ connection with "
- + queueName
- + " at "
- + rmqConnectionConfig.getHost(),
- t);
- }
- }
-}
diff --git a/flink-connectors/flink-connector-rabbitmq/src/main/java/org/apache/flink/streaming/connectors/rabbitmq/RMQSinkPublishOptions.java b/flink-connectors/flink-connector-rabbitmq/src/main/java/org/apache/flink/streaming/connectors/rabbitmq/RMQSinkPublishOptions.java
deleted file mode 100644
index 57c5d103804..00000000000
--- a/flink-connectors/flink-connector-rabbitmq/src/main/java/org/apache/flink/streaming/connectors/rabbitmq/RMQSinkPublishOptions.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.flink.streaming.connectors.rabbitmq;
-
-import org.apache.flink.annotation.PublicEvolving;
-
-import com.rabbitmq.client.AMQP.BasicProperties;
-
-/**
- * The message computation provides methods to compute the message routing key and/or the
- * properties.
- *
- * @param <IN> The type of the data used by the sink.
- */
-@PublicEvolving
-public interface RMQSinkPublishOptions<IN> extends java.io.Serializable {
-
- /**
- * Compute the message's routing key from the data.
- *
- * @param a The data used by the sink
- * @return The routing key of the message null will raise a NullPointerException
- */
- String computeRoutingKey(IN a);
-
- /**
- * Compute the message's properties from the data.
- *
- * @param a The data used by the sink
- * @return The message's properties (can be null)
- */
- BasicProperties computeProperties(IN a);
-
- /**
- * Compute the exchange from the data.
- *
- * @param a The data used by the sink
- * @return The exchange to publish the message to null will raise a NullPointerException
- */
- String computeExchange(IN a);
-
- /**
- * Compute the mandatory flag passed to method {@link
- * com.rabbitmq.client.Channel#basicPublish(String, String, boolean, boolean, BasicProperties,
- * byte[])}. A {@link SerializableReturnListener} is mandatory if this flag can be true.
- *
- * @param a The data used by the sink
- * @return The mandatory flag
- */
- default boolean computeMandatory(IN a) {
- return false;
- }
-
- /**
- * Compute the immediate flag passed to method {@link
- * com.rabbitmq.client.Channel#basicPublish(String, String, boolean, boolean, BasicProperties,
- * byte[])}. A {@link SerializableReturnListener} is mandatory if this flag can be true.
- *
- * @param a The data used by the sink
- * @return The mandatory flag
- */
- default boolean computeImmediate(IN a) {
- return false;
- }
-}
diff --git a/flink-connectors/flink-connector-rabbitmq/src/main/java/org/apache/flink/streaming/connectors/rabbitmq/RMQSource.java b/flink-connectors/flink-connector-rabbitmq/src/main/java/org/apache/flink/streaming/connectors/rabbitmq/RMQSource.java
deleted file mode 100644
index 017bc7c9ce7..00000000000
--- a/flink-connectors/flink-connector-rabbitmq/src/main/java/org/apache/flink/streaming/connectors/rabbitmq/RMQSource.java
+++ /dev/null
@@ -1,442 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.flink.streaming.connectors.rabbitmq;
-
-import org.apache.flink.annotation.VisibleForTesting;
-import org.apache.flink.api.common.functions.RuntimeContext;
-import org.apache.flink.api.common.serialization.DeserializationSchema;
-import org.apache.flink.api.common.serialization.RuntimeContextInitializationContextAdapters;
-import org.apache.flink.api.common.typeinfo.TypeInformation;
-import org.apache.flink.api.java.typeutils.ResultTypeQueryable;
-import org.apache.flink.configuration.Configuration;
-import org.apache.flink.streaming.api.functions.source.MessageAcknowledgingSourceBase;
-import org.apache.flink.streaming.api.functions.source.MultipleIdsMessageAcknowledgingSourceBase;
-import org.apache.flink.streaming.api.operators.StreamingRuntimeContext;
-import org.apache.flink.streaming.connectors.rabbitmq.common.RMQConnectionConfig;
-import org.apache.flink.util.ExceptionUtils;
-import org.apache.flink.util.IOUtils;
-import org.apache.flink.util.Preconditions;
-
-import com.rabbitmq.client.AMQP;
-import com.rabbitmq.client.Channel;
-import com.rabbitmq.client.Connection;
-import com.rabbitmq.client.ConnectionFactory;
-import com.rabbitmq.client.Delivery;
-import com.rabbitmq.client.Envelope;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.util.List;
-
-/**
- * RabbitMQ source (consumer) which reads from a queue and acknowledges messages on checkpoints.
- * When checkpointing is enabled, it guarantees exactly-once processing semantics.
- *
- * <p>RabbitMQ requires messages to be acknowledged. On failures, RabbitMQ will re-resend all
- * messages which have not been acknowledged previously. When a failure occurs directly after a
- * completed checkpoint, all messages part of this checkpoint might be processed again because they
- * couldn't be acknowledged before failure. This case is handled by the {@link
- * MessageAcknowledgingSourceBase} base class which deduplicates the messages using the correlation
- * id.
- *
- * <p>RabbitMQ's Delivery Tags do NOT represent unique ids / offsets. That's why the source uses the
- * Correlation ID in the message properties to check for duplicate messages. Note that the
- * correlation id has to be set at the producer. If the correlation id is not set, messages may be
- * produced more than once in corner cases.
- *
- * <p>This source can be operated in three different modes:
- *
- * <p>1) Exactly-once (when checkpointed) with RabbitMQ transactions and messages with unique
- * correlation IDs. 2) At-least-once (when checkpointed) with RabbitMQ transactions but no
- * deduplication mechanism (correlation id is not set). 3) No strong delivery guarantees (without
- * checkpointing) with RabbitMQ auto-commit mode.
- *
- * <p>Users may overwrite the setupConnectionFactory() method to pass their setup their own
- * ConnectionFactory in case the constructor parameters are not sufficient.
- *
- * @param <OUT> The type of the data read from RabbitMQ.
- */
-public class RMQSource<OUT> extends MultipleIdsMessageAcknowledgingSourceBase<OUT, String, Long>
- implements ResultTypeQueryable<OUT> {
-
- private static final long serialVersionUID = 1L;
-
- private static final Logger LOG = LoggerFactory.getLogger(RMQSource.class);
-
- private final RMQConnectionConfig rmqConnectionConfig;
- protected final String queueName;
- private final boolean usesCorrelationId;
- protected RMQDeserializationSchema<OUT> deliveryDeserializer;
-
- protected transient Connection connection;
- protected transient Channel channel;
- protected transient QueueingConsumer consumer;
-
- protected transient boolean autoAck;
-
- private transient volatile boolean running;
-
- /**
- * Creates a new RabbitMQ source with at-least-once message processing guarantee when
- * checkpointing is enabled. No strong delivery guarantees when checkpointing is disabled.
- *
- * <p>For exactly-once, please use the constructor {@link
- * RMQSource#RMQSource(RMQConnectionConfig, String, boolean, DeserializationSchema)}.
- *
- * @param rmqConnectionConfig The RabbiMQ connection configuration {@link RMQConnectionConfig}.
- * @param queueName The queue to receive messages from.
- * @param deserializationSchema A {@link DeserializationSchema} for turning the bytes received
- * into Java objects.
- */
- public RMQSource(
- RMQConnectionConfig rmqConnectionConfig,
- String queueName,
- DeserializationSchema<OUT> deserializationSchema) {
- this(rmqConnectionConfig, queueName, false, deserializationSchema);
- }
-
- /**
- * Creates a new RabbitMQ source. For exactly-once, you must set the correlation ids of messages
- * at the producer. The correlation id must be unique. Otherwise the behavior of the source is
- * undefined. If in doubt, set usesCorrelationId to false. When correlation ids are not used,
- * this source has at-least-once processing semantics when checkpointing is enabled.
- *
- * @param rmqConnectionConfig The RabbiMQ connection configuration {@link RMQConnectionConfig}.
- * @param queueName The queue to receive messages from.
- * @param usesCorrelationId Whether the messages received are supplied with a <b>unique</b> id
- * to deduplicate messages (in case of failed acknowledgments). Only used when checkpointing
- * is enabled.
- * @param deserializationSchema A {@link DeserializationSchema} for turning the bytes received
- * into Java objects.
- */
- public RMQSource(
- RMQConnectionConfig rmqConnectionConfig,
- String queueName,
- boolean usesCorrelationId,
- DeserializationSchema<OUT> deserializationSchema) {
- super(String.class);
- this.rmqConnectionConfig = rmqConnectionConfig;
- this.queueName = queueName;
- this.usesCorrelationId = usesCorrelationId;
- this.deliveryDeserializer = new RMQDeserializationSchemaWrapper<>(deserializationSchema);
- }
-
- /**
- * Creates a new RabbitMQ source with at-least-once message processing guarantee when
- * checkpointing is enabled. No strong delivery guarantees when checkpointing is disabled.
- *
- * <p>For exactly-once, please use the constructor {@link
- * RMQSource#RMQSource(RMQConnectionConfig, String, boolean, RMQDeserializationSchema)}.
- *
- * <p>It also uses the provided {@link RMQDeserializationSchema} to parse both the correlationID
- * and the message.
- *
- * @param rmqConnectionConfig The RabbiMQ connection configuration {@link RMQConnectionConfig}.
- * @param queueName The queue to receive messages from.
- * @param deliveryDeserializer A {@link RMQDeserializationSchema} for parsing the RMQDelivery.
- */
- public RMQSource(
- RMQConnectionConfig rmqConnectionConfig,
- String queueName,
- RMQDeserializationSchema<OUT> deliveryDeserializer) {
- this(rmqConnectionConfig, queueName, false, deliveryDeserializer);
- }
-
- /**
- * Creates a new RabbitMQ source. For exactly-once, you must set the correlation ids of messages
- * at the producer. The correlation id must be unique. Otherwise the behavior of the source is
- * undefined. If in doubt, set usesCorrelationId to false. When correlation ids are not used,
- * this source has at-least-once processing semantics when checkpointing is enabled.
- *
- * <p>It also uses the provided {@link RMQDeserializationSchema} to parse both the correlationID
- * and the message.
- *
- * @param rmqConnectionConfig The RabbiMQ connection configuration {@link RMQConnectionConfig}.
- * @param queueName The queue to receive messages from.
- * @param usesCorrelationId Whether the messages received are supplied with a <b>unique</b> id
- * to deduplicate messages (in case of failed acknowledgments). Only used when checkpointing
- * is enabled.
- * @param deliveryDeserializer A {@link RMQDeserializationSchema} for parsing the RMQDelivery.
- */
- public RMQSource(
- RMQConnectionConfig rmqConnectionConfig,
- String queueName,
- boolean usesCorrelationId,
- RMQDeserializationSchema<OUT> deliveryDeserializer) {
- super(String.class);
- this.rmqConnectionConfig = rmqConnectionConfig;
- this.queueName = queueName;
- this.usesCorrelationId = usesCorrelationId;
- this.deliveryDeserializer = deliveryDeserializer;
- }
-
- /**
- * Initializes the connection to RMQ with a default connection factory. The user may override
- * this method to setup and configure their own {@link ConnectionFactory}.
- */
- protected ConnectionFactory setupConnectionFactory() throws Exception {
- return rmqConnectionConfig.getConnectionFactory();
- }
-
- /**
- * Initializes the connection to RMQ using the default connection factory from {@link
- * #setupConnectionFactory()}. The user may override this method to setup and configure their
- * own {@link Connection}.
- */
- @VisibleForTesting
- protected Connection setupConnection() throws Exception {
- return setupConnectionFactory().newConnection();
- }
-
- /**
- * Initializes the consumer's {@link Channel}. If a prefetch count has been set in {@link
- * RMQConnectionConfig}, the new channel will be use it for {@link Channel#basicQos(int)}.
- *
- * @param connection the consumer's {@link Connection}.
- * @return the channel.
- * @throws Exception if there is an issue creating or configuring the channel.
- */
- private Channel setupChannel(Connection connection) throws Exception {
- Channel chan = connection.createChannel();
- if (rmqConnectionConfig.getPrefetchCount().isPresent()) {
- // set the global flag for the entire channel, though shouldn't make a difference
- // since there is only one consumer, and each parallel instance of the source will
- // create a new connection (and channel)
- chan.basicQos(rmqConnectionConfig.getPrefetchCount().get(), true);
- }
- return chan;
- }
-
- /**
- * Sets up the queue. The default implementation just declares the queue. The user may override
- * this method to have a custom setup for the queue (i.e. binding the queue to an exchange or
- * defining custom queue parameters)
- */
- @VisibleForTesting
- protected void setupQueue() throws IOException {
- Util.declareQueueDefaults(channel, queueName);
- }
-
- @Override
- public void open(Configuration config) throws Exception {
- super.open(config);
- try {
- connection = setupConnection();
- channel = setupChannel(connection);
- if (channel == null) {
- throw new RuntimeException("None of RabbitMQ channels are available");
- }
- setupQueue();
- consumer = new QueueingConsumer(channel);
-
- RuntimeContext runtimeContext = getRuntimeContext();
- if (runtimeContext instanceof StreamingRuntimeContext
- && ((StreamingRuntimeContext) runtimeContext).isCheckpointingEnabled()) {
- autoAck = false;
- // enables transaction mode
- channel.txSelect();
- } else {
- autoAck = true;
- }
-
- LOG.debug("Starting RabbitMQ source with autoAck status: " + autoAck);
- channel.basicConsume(queueName, autoAck, consumer);
-
- } catch (IOException e) {
- IOUtils.closeAllQuietly(channel, connection);
- throw new RuntimeException(
- "Cannot create RMQ connection with "
- + queueName
- + " at "
- + rmqConnectionConfig.getHost(),
- e);
- }
- this.deliveryDeserializer.open(
- RuntimeContextInitializationContextAdapters.deserializationAdapter(
- getRuntimeContext(), metricGroup -> metricGroup.addGroup("user")));
- running = true;
- }
-
- @Override
- public void close() throws Exception {
- super.close();
- Exception exception = null;
-
- try {
- if (consumer != null && channel != null) {
- channel.basicCancel(consumer.getConsumerTag());
- }
- } catch (IOException e) {
- exception =
- new RuntimeException(
- "Error while cancelling RMQ consumer on "
- + queueName
- + " at "
- + rmqConnectionConfig.getHost(),
- e);
- }
-
- try {
- IOUtils.closeAll(channel, connection);
- } catch (IOException e) {
- exception =
- ExceptionUtils.firstOrSuppressed(
- new RuntimeException(
- "Error while closing RMQ source with "
- + queueName
- + " at "
- + rmqConnectionConfig.getHost(),
- e),
- exception);
- }
-
- if (exception != null) {
- throw exception;
- }
- }
-
- private void processMessage(Delivery delivery, RMQCollectorImpl collector) throws IOException {
- AMQP.BasicProperties properties = delivery.getProperties();
- byte[] body = delivery.getBody();
- Envelope envelope = delivery.getEnvelope();
- collector.setFallBackIdentifiers(properties.getCorrelationId(), envelope.getDeliveryTag());
- deliveryDeserializer.deserialize(envelope, properties, body, collector);
- }
-
- @Override
- public void run(SourceContext<OUT> ctx) throws Exception {
- final RMQCollectorImpl collector = new RMQCollectorImpl(ctx);
- final long timeout = rmqConnectionConfig.getDeliveryTimeout();
- while (running) {
- Delivery delivery = consumer.nextDelivery(timeout);
-
- synchronized (ctx.getCheckpointLock()) {
- if (delivery != null) {
- processMessage(delivery, collector);
- }
- if (collector.isEndOfStreamSignalled()) {
- this.running = false;
- return;
- }
- }
- }
- }
-
- @Override
- public void cancel() {
- running = false;
- }
-
- @Override
- protected void acknowledgeSessionIDs(List<Long> sessionIds) {
- try {
- for (long id : sessionIds) {
- channel.basicAck(id, false);
- }
- channel.txCommit();
- } catch (IOException e) {
- throw new RuntimeException(
- "Messages could not be acknowledged during checkpoint creation.", e);
- }
- }
-
- @Override
- public TypeInformation<OUT> getProducedType() {
- return deliveryDeserializer.getProducedType();
- }
-
- /**
- * Special collector for RMQ messages. Captures the correlation ID and delivery tag also does
- * the filtering logic for weather a message has been processed or not.
- */
- private class RMQCollectorImpl implements RMQDeserializationSchema.RMQCollector<OUT> {
- private final SourceContext<OUT> ctx;
- private boolean endOfStreamSignalled = false;
- private String correlationId;
- private long deliveryTag;
- private boolean customIdentifiersSet = false;
-
- private RMQCollectorImpl(SourceContext<OUT> ctx) {
- this.ctx = ctx;
- }
-
- @Override
- public void collect(OUT record) {
- if (!customIdentifiersSet) {
- boolean newMessage = setMessageIdentifiers(correlationId, deliveryTag);
- if (!newMessage) {
- return;
- }
- }
-
- if (isEndOfStream(record)) {
- this.endOfStreamSignalled = true;
- return;
- }
- ctx.collect(record);
- }
-
- public void setFallBackIdentifiers(String correlationId, long deliveryTag) {
- this.correlationId = correlationId;
- this.deliveryTag = deliveryTag;
- this.customIdentifiersSet = false;
- }
-
- @Override
- public boolean setMessageIdentifiers(String correlationId, long deliveryTag) {
- if (customIdentifiersSet) {
- throw new IllegalStateException(
- "You can set only a single set of identifiers for a block of messages.");
- }
-
- this.customIdentifiersSet = true;
- if (!autoAck) {
- if (usesCorrelationId) {
- Preconditions.checkNotNull(
- correlationId,
- "RabbitMQ source was instantiated with usesCorrelationId set to "
- + "true yet we couldn't extract the correlation id from it!");
- if (!addId(correlationId)) {
- // we have already processed this message
- try {
- channel.basicReject(deliveryTag, false);
- } catch (IOException e) {
- throw new RuntimeException(
- "Message could not be acknowledged with basicReject.", e);
- }
- return false;
- }
- }
- sessionIds.add(deliveryTag);
- }
- return true;
- }
-
- boolean isEndOfStream(OUT record) {
- return endOfStreamSignalled || deliveryDeserializer.isEndOfStream(record);
- }
-
- public boolean isEndOfStreamSignalled() {
- return endOfStreamSignalled;
- }
-
- @Override
- public void close() {}
- }
-}
diff --git a/flink-connectors/flink-connector-rabbitmq/src/main/java/org/apache/flink/streaming/connectors/rabbitmq/SerializableReturnListener.java b/flink-connectors/flink-connector-rabbitmq/src/main/java/org/apache/flink/streaming/connectors/rabbitmq/SerializableReturnListener.java
deleted file mode 100644
index 416fa16c96f..00000000000
--- a/flink-connectors/flink-connector-rabbitmq/src/main/java/org/apache/flink/streaming/connectors/rabbitmq/SerializableReturnListener.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.flink.streaming.connectors.rabbitmq;
-
-import com.rabbitmq.client.ReturnListener;
-
-import java.io.Serializable;
-
-/** A serializable {@link ReturnListener}. */
-public interface SerializableReturnListener extends Serializable, ReturnListener {}
diff --git a/flink-connectors/flink-connector-rabbitmq/src/main/java/org/apache/flink/streaming/connectors/rabbitmq/Util.java b/flink-connectors/flink-connector-rabbitmq/src/main/java/org/apache/flink/streaming/connectors/rabbitmq/Util.java
deleted file mode 100644
index ff443c373ca..00000000000
--- a/flink-connectors/flink-connector-rabbitmq/src/main/java/org/apache/flink/streaming/connectors/rabbitmq/Util.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.flink.streaming.connectors.rabbitmq;
-
-import com.rabbitmq.client.Channel;
-
-import java.io.IOException;
-
-class Util {
- /**
- * Declares a queue with sensible defaults: durable, non-exclusive, non-autoDelete, and no
- * arguments.
- *
- * @param channel the open RMQ channel.
- * @param queueName the name of the queue.
- * @throws IOException if an error is encountered setting up the queue.
- */
- static void declareQueueDefaults(Channel channel, String queueName) throws IOException {
- channel.queueDeclare(queueName, true, false, false, null);
- }
-}
diff --git a/flink-connectors/flink-connector-rabbitmq/src/main/java/org/apache/flink/streaming/connectors/rabbitmq/common/RMQConnectionConfig.java b/flink-connectors/flink-connector-rabbitmq/src/main/java/org/apache/flink/streaming/connectors/rabbitmq/common/RMQConnectionConfig.java
deleted file mode 100644
index c93adaa8eb3..00000000000
--- a/flink-connectors/flink-connector-rabbitmq/src/main/java/org/apache/flink/streaming/connectors/rabbitmq/common/RMQConnectionConfig.java
+++ /dev/null
@@ -1,608 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.flink.streaming.connectors.rabbitmq.common;
-
-import org.apache.flink.streaming.connectors.rabbitmq.RMQSource;
-import org.apache.flink.util.Preconditions;
-
-import com.rabbitmq.client.ConnectionFactory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.Serializable;
-import java.net.URISyntaxException;
-import java.security.KeyManagementException;
-import java.security.NoSuchAlgorithmException;
-import java.util.Optional;
-import java.util.concurrent.TimeUnit;
-
-/**
- * Connection Configuration for RMQ. If {@link Builder#setUri(String)} has been set then {@link
- * RMQConnectionConfig#RMQConnectionConfig(String, Integer, Boolean, Boolean, Integer, Integer,
- * Integer, Integer, Integer, Long)} will be used for initialize the RMQ connection or {@link
- * RMQConnectionConfig#RMQConnectionConfig(String, Integer, String, String, String, Integer,
- * Boolean, Boolean, Integer, Integer, Integer, Integer, Integer, Long)} will be used for initialize
- * the RMQ connection
- */
-public class RMQConnectionConfig implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- private static final Logger LOG = LoggerFactory.getLogger(RMQConnectionConfig.class);
-
- private static final long DEFAULT_DELIVERY_TIMEOUT = 30000;
-
- private String host;
- private Integer port;
- private String virtualHost;
- private String username;
- private String password;
- private String uri;
-
- private Integer networkRecoveryInterval;
- private Boolean automaticRecovery;
- private Boolean topologyRecovery;
-
- private Integer connectionTimeout;
- private Integer requestedChannelMax;
- private Integer requestedFrameMax;
- private Integer requestedHeartbeat;
-
- private Integer prefetchCount;
- private final long deliveryTimeout;
-
- /**
- * @param host host name
- * @param port port
- * @param virtualHost virtual host
- * @param username username
- * @param password password
- * @param networkRecoveryInterval connection recovery interval in milliseconds
- * @param automaticRecovery if automatic connection recovery
- * @param topologyRecovery if topology recovery
- * @param connectionTimeout connection timeout
- * @param requestedChannelMax requested maximum channel number
- * @param requestedFrameMax requested maximum frame size
- * @param requestedHeartbeat requested heartbeat interval
- * @param deliveryTimeout message delivery timeout in the queueing consumer
- * @throws NullPointerException if host or virtual host or username or password is null
- */
- private RMQConnectionConfig(
- String host,
- Integer port,
- String virtualHost,
- String username,
- String password,
- Integer networkRecoveryInterval,
- Boolean automaticRecovery,
- Boolean topologyRecovery,
- Integer connectionTimeout,
- Integer requestedChannelMax,
- Integer requestedFrameMax,
- Integer requestedHeartbeat,
- Integer prefetchCount,
- Long deliveryTimeout) {
- Preconditions.checkNotNull(host, "host can not be null");
- Preconditions.checkNotNull(port, "port can not be null");
- Preconditions.checkNotNull(virtualHost, "virtualHost can not be null");
- Preconditions.checkNotNull(username, "username can not be null");
- Preconditions.checkNotNull(password, "password can not be null");
- Preconditions.checkArgument(
- deliveryTimeout == null || deliveryTimeout > 0, "deliveryTimeout must be positive");
- this.host = host;
- this.port = port;
- this.virtualHost = virtualHost;
- this.username = username;
- this.password = password;
-
- this.networkRecoveryInterval = networkRecoveryInterval;
- this.automaticRecovery = automaticRecovery;
- this.topologyRecovery = topologyRecovery;
- this.connectionTimeout = connectionTimeout;
- this.requestedChannelMax = requestedChannelMax;
- this.requestedFrameMax = requestedFrameMax;
- this.requestedHeartbeat = requestedHeartbeat;
- this.prefetchCount = prefetchCount;
- this.deliveryTimeout =
- Optional.ofNullable(deliveryTimeout).orElse(DEFAULT_DELIVERY_TIMEOUT);
- }
-
- /**
- * @param uri the connection URI
- * @param networkRecoveryInterval connection recovery interval in milliseconds
- * @param automaticRecovery if automatic connection recovery
- * @param topologyRecovery if topology recovery
- * @param connectionTimeout connection timeout
- * @param requestedChannelMax requested maximum channel number
- * @param requestedFrameMax requested maximum frame size
- * @param requestedHeartbeat requested heartbeat interval
- * @param deliveryTimeout message delivery timeout in the queueing consumer
- * @throws NullPointerException if URI is null
- */
- private RMQConnectionConfig(
- String uri,
- Integer networkRecoveryInterval,
- Boolean automaticRecovery,
- Boolean topologyRecovery,
- Integer connectionTimeout,
- Integer requestedChannelMax,
- Integer requestedFrameMax,
- Integer requestedHeartbeat,
- Integer prefetchCount,
- Long deliveryTimeout) {
- Preconditions.checkNotNull(uri, "Uri can not be null");
- Preconditions.checkArgument(
- deliveryTimeout == null || deliveryTimeout > 0, "deliveryTimeout must be positive");
- this.uri = uri;
-
- this.networkRecoveryInterval = networkRecoveryInterval;
- this.automaticRecovery = automaticRecovery;
- this.topologyRecovery = topologyRecovery;
- this.connectionTimeout = connectionTimeout;
- this.requestedChannelMax = requestedChannelMax;
- this.requestedFrameMax = requestedFrameMax;
- this.requestedHeartbeat = requestedHeartbeat;
- this.prefetchCount = prefetchCount;
- this.deliveryTimeout =
- Optional.ofNullable(deliveryTimeout).orElse(DEFAULT_DELIVERY_TIMEOUT);
- }
-
- /** @return the host to use for connections */
- public String getHost() {
- return host;
- }
-
- /** @return the port to use for connections */
- public int getPort() {
- return port;
- }
-
- /**
- * Retrieve the virtual host.
- *
- * @return the virtual host to use when connecting to the broker
- */
- public String getVirtualHost() {
- return virtualHost;
- }
-
- /**
- * Retrieve the user name.
- *
- * @return the AMQP user name to use when connecting to the broker
- */
- public String getUsername() {
- return username;
- }
-
- /**
- * Retrieve the password.
- *
- * @return the password to use when connecting to the broker
- */
- public String getPassword() {
- return password;
- }
-
- /**
- * Retrieve the URI.
- *
- * @return the connection URI when connecting to the broker
- */
- public String getUri() {
- return uri;
- }
-
- /**
- * Returns automatic connection recovery interval in milliseconds.
- *
- * @return how long will automatic recovery wait before attempting to reconnect, in ms; default
- * is 5000
- */
- public Integer getNetworkRecoveryInterval() {
- return networkRecoveryInterval;
- }
-
- /**
- * Returns true if automatic connection recovery is enabled, false otherwise.
- *
- * @return true if automatic connection recovery is enabled, false otherwise
- */
- public Boolean isAutomaticRecovery() {
- return automaticRecovery;
- }
-
- /**
- * Returns true if topology recovery is enabled, false otherwise.
- *
- * @return true if topology recovery is enabled, false otherwise
- */
- public Boolean isTopologyRecovery() {
- return topologyRecovery;
- }
-
- /**
- * Retrieve the connection timeout.
- *
- * @return the connection timeout, in milliseconds; zero for infinite
- */
- public Integer getConnectionTimeout() {
- return connectionTimeout;
- }
-
- /**
- * Retrieve the requested maximum channel number.
- *
- * @return the initially requested maximum channel number; zero for unlimited
- */
- public Integer getRequestedChannelMax() {
- return requestedChannelMax;
- }
-
- /**
- * Retrieve the requested maximum frame size.
- *
- * @return the initially requested maximum frame size, in octets; zero for unlimited
- */
- public Integer getRequestedFrameMax() {
- return requestedFrameMax;
- }
-
- /**
- * Retrieve the requested heartbeat interval.
- *
- * @return the initially requested heartbeat interval, in seconds; zero for none
- */
- public Integer getRequestedHeartbeat() {
- return requestedHeartbeat;
- }
-
- /**
- * Retrieve the channel prefetch count.
- *
- * @return an Optional of the prefetch count, if set, for the consumer channel
- */
- public Optional<Integer> getPrefetchCount() {
- return Optional.ofNullable(prefetchCount);
- }
-
- /**
- * Retrieve the message delivery timeout used in the queueing consumer. If not specified
- * explicitly, the default value of 30000 milliseconds will be returned.
- *
- * @return the message delivery timeout, in milliseconds
- */
- public long getDeliveryTimeout() {
- return deliveryTimeout;
- }
-
- /**
- * @return Connection Factory for RMQ
- * @throws URISyntaxException if Malformed URI has been passed
- * @throws NoSuchAlgorithmException if the ssl factory could not be created
- * @throws KeyManagementException if the ssl context could not be initialized
- */
- public ConnectionFactory getConnectionFactory()
- throws URISyntaxException, NoSuchAlgorithmException, KeyManagementException {
- ConnectionFactory factory = new ConnectionFactory();
- if (this.uri != null && !this.uri.isEmpty()) {
- try {
- factory.setUri(this.uri);
- } catch (URISyntaxException e) {
- LOG.error("Failed to parse uri", e);
- throw e;
- } catch (KeyManagementException e) {
- // this should never happen
- LOG.error("Failed to initialize ssl context.", e);
- throw e;
- } catch (NoSuchAlgorithmException e) {
- // this should never happen
- LOG.error("Failed to setup ssl factory.", e);
- throw e;
- }
- } else {
- factory.setHost(this.host);
- factory.setPort(this.port);
- factory.setVirtualHost(this.virtualHost);
- factory.setUsername(this.username);
- factory.setPassword(this.password);
- }
-
- if (this.automaticRecovery != null) {
- factory.setAutomaticRecoveryEnabled(this.automaticRecovery);
- }
- if (this.connectionTimeout != null) {
- factory.setConnectionTimeout(this.connectionTimeout);
- }
- if (this.networkRecoveryInterval != null) {
- factory.setNetworkRecoveryInterval(this.networkRecoveryInterval);
- }
- if (this.requestedHeartbeat != null) {
- factory.setRequestedHeartbeat(this.requestedHeartbeat);
- }
- if (this.topologyRecovery != null) {
- factory.setTopologyRecoveryEnabled(this.topologyRecovery);
- }
- if (this.requestedChannelMax != null) {
- factory.setRequestedChannelMax(this.requestedChannelMax);
- }
- if (this.requestedFrameMax != null) {
- factory.setRequestedFrameMax(this.requestedFrameMax);
- }
-
- return factory;
- }
-
- /** The Builder Class for {@link RMQConnectionConfig}. */
- public static class Builder {
-
- private String host;
- private Integer port;
- private String virtualHost;
- private String username;
- private String password;
-
- private Integer networkRecoveryInterval;
- private Boolean automaticRecovery;
- private Boolean topologyRecovery;
-
- private Integer connectionTimeout;
- private Integer requestedChannelMax;
- private Integer requestedFrameMax;
- private Integer requestedHeartbeat;
-
- // basicQos options for consumers
- private Integer prefetchCount;
-
- private Long deliveryTimeout;
-
- private String uri;
-
- /**
- * Set the target port.
- *
- * @param port the default port to use for connections
- * @return the Builder
- */
- public Builder setPort(int port) {
- this.port = port;
- return this;
- }
-
- /**
- * @param host the default host to use for connections
- * @return the Builder
- */
- public Builder setHost(String host) {
- this.host = host;
- return this;
- }
-
- /**
- * Set the virtual host.
- *
- * @param virtualHost the virtual host to use when connecting to the broker
- * @return the Builder
- */
- public Builder setVirtualHost(String virtualHost) {
- this.virtualHost = virtualHost;
- return this;
- }
-
- /**
- * Set the user name.
- *
- * @param username the AMQP user name to use when connecting to the broker
- * @return the Builder
- */
- public Builder setUserName(String username) {
- this.username = username;
- return this;
- }
-
- /**
- * Set the password.
- *
- * @param password the password to use when connecting to the broker
- * @return the Builder
- */
- public Builder setPassword(String password) {
- this.password = password;
- return this;
- }
-
- /**
- * Convenience method for setting the fields in an AMQP URI: host, port, username, password
- * and virtual host. If any part of the URI is omitted, the ConnectionFactory's
- * corresponding variable is left unchanged.
- *
- * @param uri is the AMQP URI containing the data
- * @return the Builder
- */
- public Builder setUri(String uri) {
- this.uri = uri;
- return this;
- }
-
- /**
- * Enables or disables topology recovery.
- *
- * @param topologyRecovery if true, enables topology recovery
- * @return the Builder
- */
- public Builder setTopologyRecoveryEnabled(boolean topologyRecovery) {
- this.topologyRecovery = topologyRecovery;
- return this;
- }
-
- /**
- * Set the requested heartbeat.
- *
- * @param requestedHeartbeat the initially requested heartbeat interval, in seconds; zero
- * for none
- * @return the Builder
- */
- public Builder setRequestedHeartbeat(int requestedHeartbeat) {
- this.requestedHeartbeat = requestedHeartbeat;
- return this;
- }
-
- /**
- * Set the requested maximum frame size.
- *
- * @param requestedFrameMax initially requested maximum frame size, in octets; zero for
- * unlimited
- * @return the Builder
- */
- public Builder setRequestedFrameMax(int requestedFrameMax) {
- this.requestedFrameMax = requestedFrameMax;
- return this;
- }
-
- /**
- * Set the requested maximum channel number.
- *
- * @param requestedChannelMax initially requested maximum channel number; zero for unlimited
- */
- public Builder setRequestedChannelMax(int requestedChannelMax) {
- this.requestedChannelMax = requestedChannelMax;
- return this;
- }
-
- /**
- * Sets connection recovery interval. Default is 5000.
- *
- * @param networkRecoveryInterval how long will automatic recovery wait before attempting to
- * reconnect, in ms
- * @return the Builder
- */
- public Builder setNetworkRecoveryInterval(int networkRecoveryInterval) {
- this.networkRecoveryInterval = networkRecoveryInterval;
- return this;
- }
-
- /**
- * Set the connection timeout.
- *
- * @param connectionTimeout connection establishment timeout in milliseconds; zero for
- * infinite
- * @return the Builder
- */
- public Builder setConnectionTimeout(int connectionTimeout) {
- this.connectionTimeout = connectionTimeout;
- return this;
- }
-
- /**
- * Enables or disables automatic connection recovery.
- *
- * @param automaticRecovery if true, enables connection recovery
- * @return the Builder
- */
- public Builder setAutomaticRecovery(boolean automaticRecovery) {
- this.automaticRecovery = automaticRecovery;
- return this;
- }
-
- /**
- * Enables setting basicQos for the consumer channel. Only applicable to the {@link
- * RMQSource}. Set to 0 for unlimited, which is the default.
- *
- * @see <a href="https://www.rabbitmq.com/consumer-prefetch.html">Consumer Prefetch</a>
- * @see <a href="https://www.rabbitmq.com/confirms.html#channel-qos-prefetch">Channel
- * Prefetch (QoS)</a>
- * @param prefetchCount the max number of messages to receive without acknowledgement.
- * @return the Builder
- */
- public Builder setPrefetchCount(int prefetchCount) {
- this.prefetchCount = prefetchCount;
- return this;
- }
-
- /**
- * Enables setting the message delivery timeout in the queueing consumer. Only applicable to
- * the {@link RMQSource}. If not set it will default to 30000.
- *
- * @param deliveryTimeout maximum wait time, in milliseconds, for the next message delivery
- * @return the Builder
- */
- public Builder setDeliveryTimeout(long deliveryTimeout) {
- Preconditions.checkArgument(deliveryTimeout > 0, "deliveryTimeout must be positive");
- this.deliveryTimeout = deliveryTimeout;
- return this;
- }
-
- /**
- * Enables setting the message delivery timeout in the queueing consumer. Only applicable to
- * the {@link RMQSource}. If not set it will default to 30 seconds.
- *
- * @param deliveryTimeout maximum wait time for the next message delivery
- * @param unit deliveryTimeout unit
- * @return the Builder
- */
- public Builder setDeliveryTimeout(long deliveryTimeout, TimeUnit unit) {
- return setDeliveryTimeout(unit.toMillis(deliveryTimeout));
- }
-
- /**
- * The Builder method.
- *
- * <p>If URI is NULL we use host, port, vHost, username, password combination to initialize
- * connection. using {@link RMQConnectionConfig#RMQConnectionConfig(String, Integer, String,
- * String, String, Integer, Boolean, Boolean, Integer, Integer, Integer, Integer, Integer,
- * Long)}.
- *
- * <p>Otherwise the URI will be used to initialize the client connection {@link
- * RMQConnectionConfig#RMQConnectionConfig(String, Integer, Boolean, Boolean, Integer,
- * Integer, Integer, Integer, Integer, Long)}
- *
- * @return RMQConnectionConfig
- */
- public RMQConnectionConfig build() {
- if (this.uri != null) {
- return new RMQConnectionConfig(
- this.uri,
- this.networkRecoveryInterval,
- this.automaticRecovery,
- this.topologyRecovery,
- this.connectionTimeout,
- this.requestedChannelMax,
- this.requestedFrameMax,
- this.requestedHeartbeat,
- this.prefetchCount,
- this.deliveryTimeout);
- } else {
- return new RMQConnectionConfig(
- this.host,
- this.port,
- this.virtualHost,
- this.username,
- this.password,
- this.networkRecoveryInterval,
- this.automaticRecovery,
- this.topologyRecovery,
- this.connectionTimeout,
- this.requestedChannelMax,
- this.requestedFrameMax,
- this.requestedHeartbeat,
- this.prefetchCount,
- this.deliveryTimeout);
- }
- }
- }
-}
diff --git a/flink-connectors/flink-connector-rabbitmq/src/test/java/org/apache/flink/architecture/TestCodeArchitectureTest.java b/flink-connectors/flink-connector-rabbitmq/src/test/java/org/apache/flink/architecture/TestCodeArchitectureTest.java
deleted file mode 100644
index 00fafb999a8..00000000000
--- a/flink-connectors/flink-connector-rabbitmq/src/test/java/org/apache/flink/architecture/TestCodeArchitectureTest.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.flink.architecture;
-
-import org.apache.flink.architecture.common.ImportOptions;
-
-import com.tngtech.archunit.core.importer.ImportOption;
-import com.tngtech.archunit.junit.AnalyzeClasses;
-import com.tngtech.archunit.junit.ArchTest;
-import com.tngtech.archunit.junit.ArchTests;
-
-/** Architecture tests for test code. */
-@AnalyzeClasses(
- packages = "org.apache.flink.streaming.connectors.rabbitmq",
- importOptions = {
- ImportOption.OnlyIncludeTests.class,
- ImportOptions.ExcludeScalaImportOption.class,
- ImportOptions.ExcludeShadedImportOption.class
- })
-public class TestCodeArchitectureTest {
-
- @ArchTest
- public static final ArchTests COMMON_TESTS = ArchTests.in(TestCodeArchitectureTestBase.class);
-}
diff --git a/flink-connectors/flink-connector-rabbitmq/src/test/java/org/apache/flink/streaming/connectors/rabbitmq/RMQSinkTest.java b/flink-connectors/flink-connector-rabbitmq/src/test/java/org/apache/flink/streaming/connectors/rabbitmq/RMQSinkTest.java
deleted file mode 100644
index 402a23375aa..00000000000
--- a/flink-connectors/flink-connector-rabbitmq/src/test/java/org/apache/flink/streaming/connectors/rabbitmq/RMQSinkTest.java
+++ /dev/null
@@ -1,364 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.flink.streaming.connectors.rabbitmq;
-
-import org.apache.flink.api.common.serialization.SerializationSchema;
-import org.apache.flink.configuration.Configuration;
-import org.apache.flink.streaming.api.functions.sink.SinkContextUtil;
-import org.apache.flink.streaming.api.operators.StreamSink;
-import org.apache.flink.streaming.connectors.rabbitmq.common.RMQConnectionConfig;
-import org.apache.flink.streaming.util.AbstractStreamOperatorTestHarness;
-import org.apache.flink.streaming.util.MockSerializationSchema;
-import org.apache.flink.streaming.util.MockStreamingRuntimeContext;
-
-import com.rabbitmq.client.AMQP;
-import com.rabbitmq.client.AMQP.BasicProperties;
-import com.rabbitmq.client.Channel;
-import com.rabbitmq.client.Connection;
-import com.rabbitmq.client.ConnectionFactory;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-import java.io.IOException;
-import java.util.Collections;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.mockito.Mockito.doThrow;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-/** Tests for the {@link RMQSink}. */
-class RMQSinkTest {
-
- private static final String QUEUE_NAME = "queue";
- private static final String EXCHANGE = "exchange";
- private static final String ROUTING_KEY = "application.component.error";
- private static final String EXPIRATION = "10000";
- private static final String MESSAGE_STR = "msg";
- private static final byte[] MESSAGE = new byte[1];
- private static AMQP.BasicProperties props =
- new AMQP.BasicProperties.Builder()
- .headers(Collections.singletonMap("Test", "My Value"))
- .expiration(EXPIRATION)
- .build();
-
- private RMQConnectionConfig rmqConnectionConfig;
- private ConnectionFactory connectionFactory;
- private Connection connection;
- private Channel channel;
- private SerializationSchema<String> serializationSchema;
- private DummyPublishOptions publishOptions;
- private DummyReturnHandler returnListener;
-
- @BeforeEach
- void before() throws Exception {
- serializationSchema = spy(new DummySerializationSchema());
- rmqConnectionConfig = mock(RMQConnectionConfig.class);
- connectionFactory = mock(ConnectionFactory.class);
- connection = mock(Connection.class);
- channel = mock(Channel.class);
-
- when(rmqConnectionConfig.getConnectionFactory()).thenReturn(connectionFactory);
- when(connectionFactory.newConnection()).thenReturn(connection);
- when(connection.createChannel()).thenReturn(channel);
- }
-
- @Test
- void openCallDeclaresQueueInStandardMode() throws Exception {
- createRMQSink();
-
- verify(channel).queueDeclare(QUEUE_NAME, true, false, false, null);
- }
-
- @Test
- void openCallDontDeclaresQueueInWithOptionsMode() throws Exception {
- createRMQSinkWithOptions(false, false);
-
- verify(channel, never()).queueDeclare(null, true, false, false, null);
- }
-
- @Test
- void testOverrideConnection() throws Exception {
- final Connection mockConnection = mock(Connection.class);
- Channel channel = mock(Channel.class);
- when(mockConnection.createChannel()).thenReturn(channel);
-
- RMQSink<String> rmqSink =
- new RMQSink<String>(rmqConnectionConfig, QUEUE_NAME, serializationSchema) {
- @Override
- protected Connection setupConnection() throws Exception {
- return mockConnection;
- }
- };
-
- rmqSink.setRuntimeContext(new MockStreamingRuntimeContext(false, 1, 0));
- rmqSink.open(new Configuration());
-
- verify(mockConnection, times(1)).createChannel();
- }
-
- @Test
- void throwExceptionIfChannelIsNull() throws Exception {
- when(connection.createChannel()).thenReturn(null);
- assertThatThrownBy(() -> createRMQSink())
- .isInstanceOf(RuntimeException.class)
- .hasMessage("None of RabbitMQ channels are available");
- }
-
- @Test
- void testOpen() throws Exception {
- MockSerializationSchema<String> serializationSchema = new MockSerializationSchema<>();
-
- RMQSink<String> producer =
- new RMQSink<>(rmqConnectionConfig, serializationSchema, publishOptions);
- AbstractStreamOperatorTestHarness<Object> testHarness =
- new AbstractStreamOperatorTestHarness<>(new StreamSink<>(producer), 1, 1, 0);
-
- testHarness.open();
- assertThat(serializationSchema.isOpenCalled()).as("Open method was not called").isTrue();
- }
-
- private RMQSink<String> createRMQSink() throws Exception {
- RMQSink<String> rmqSink =
- new RMQSink<>(rmqConnectionConfig, QUEUE_NAME, serializationSchema);
- rmqSink.setRuntimeContext(new MockStreamingRuntimeContext(false, 1, 0));
- rmqSink.open(new Configuration());
- return rmqSink;
- }
-
- private RMQSink<String> createRMQSinkWithOptions(boolean mandatory, boolean immediate)
- throws Exception {
- publishOptions = new DummyPublishOptions(mandatory, immediate);
- RMQSink<String> rmqSink =
- new RMQSink<>(rmqConnectionConfig, serializationSchema, publishOptions);
- rmqSink.setRuntimeContext(new MockStreamingRuntimeContext(false, 1, 0));
- rmqSink.open(new Configuration());
- return rmqSink;
- }
-
- private RMQSink<String> createRMQSinkWithOptionsAndReturnHandler(
- boolean mandatory, boolean immediate) throws Exception {
- publishOptions = new DummyPublishOptions(mandatory, immediate);
- returnListener = new DummyReturnHandler();
- RMQSink<String> rmqSink =
- new RMQSink<>(
- rmqConnectionConfig, serializationSchema, publishOptions, returnListener);
- rmqSink.setRuntimeContext(new MockStreamingRuntimeContext(false, 1, 0));
- rmqSink.open(new Configuration());
- return rmqSink;
- }
-
- @Test
- void invokePublishBytesToQueue() throws Exception {
- RMQSink<String> rmqSink = createRMQSink();
-
- rmqSink.invoke(MESSAGE_STR, SinkContextUtil.forTimestamp(0));
- verify(serializationSchema).serialize(MESSAGE_STR);
- verify(channel).basicPublish("", QUEUE_NAME, null, MESSAGE);
- }
-
- @Test
- void exceptionDuringPublishingIsNotIgnored() throws Exception {
- RMQSink<String> rmqSink = createRMQSink();
-
- doThrow(IOException.class).when(channel).basicPublish("", QUEUE_NAME, null, MESSAGE);
- assertThatThrownBy(() -> rmqSink.invoke("msg", SinkContextUtil.forTimestamp(0)))
- .isInstanceOf(RuntimeException.class);
- }
-
- @Test
- void exceptionDuringPublishingIsIgnoredIfLogFailuresOnly() throws Exception {
- RMQSink<String> rmqSink = createRMQSink();
- rmqSink.setLogFailuresOnly(true);
-
- doThrow(IOException.class).when(channel).basicPublish("", QUEUE_NAME, null, MESSAGE);
- rmqSink.invoke("msg", SinkContextUtil.forTimestamp(0));
- }
-
- @Test
- void closeAllResources() throws Exception {
- RMQSink<String> rmqSink = createRMQSink();
-
- rmqSink.close();
-
- verify(channel).close();
- verify(connection).close();
- }
-
- @Test
- void invokePublishBytesToQueueWithOptions() throws Exception {
- RMQSink<String> rmqSink = createRMQSinkWithOptions(false, false);
-
- rmqSink.invoke(MESSAGE_STR, SinkContextUtil.forTimestamp(0));
- verify(serializationSchema).serialize(MESSAGE_STR);
- verify(channel)
- .basicPublish(
- EXCHANGE,
- ROUTING_KEY,
- false,
- false,
- publishOptions.computeProperties(""),
- MESSAGE);
- }
-
- @Test
- void invokePublishBytesToQueueWithOptionsMandatory() throws Exception {
- RMQSink<String> rmqSink = createRMQSinkWithOptions(true, false);
-
- assertThatThrownBy(() -> rmqSink.invoke(MESSAGE_STR, SinkContextUtil.forTimestamp(0)))
- .isInstanceOf(IllegalStateException.class);
- }
-
- @Test
- void invokePublishBytesToQueueWithOptionsImmediate() throws Exception {
- RMQSink<String> rmqSink = createRMQSinkWithOptions(false, true);
-
- assertThatThrownBy(() -> rmqSink.invoke(MESSAGE_STR, SinkContextUtil.forTimestamp(0)))
- .isInstanceOf(IllegalStateException.class);
- }
-
- @Test
- void invokePublishBytesToQueueWithOptionsMandatoryReturnHandler() throws Exception {
- RMQSink<String> rmqSink = createRMQSinkWithOptionsAndReturnHandler(true, false);
-
- rmqSink.invoke(MESSAGE_STR, SinkContextUtil.forTimestamp(0));
- verify(serializationSchema).serialize(MESSAGE_STR);
- verify(channel)
- .basicPublish(
- EXCHANGE,
- ROUTING_KEY,
- true,
- false,
- publishOptions.computeProperties(""),
- MESSAGE);
- }
-
- @Test
- void invokePublishBytesToQueueWithOptionsImmediateReturnHandler() throws Exception {
- RMQSink<String> rmqSink = createRMQSinkWithOptionsAndReturnHandler(false, true);
-
- rmqSink.invoke(MESSAGE_STR, SinkContextUtil.forTimestamp(0));
- verify(serializationSchema).serialize(MESSAGE_STR);
- verify(channel)
- .basicPublish(
- EXCHANGE,
- ROUTING_KEY,
- false,
- true,
- publishOptions.computeProperties(""),
- MESSAGE);
- }
-
- @Test
- void exceptionDuringWithOptionsPublishingIsNotIgnored() throws Exception {
- RMQSink<String> rmqSink = createRMQSinkWithOptions(false, false);
-
- doThrow(IOException.class)
- .when(channel)
- .basicPublish(
- EXCHANGE,
- ROUTING_KEY,
- false,
- false,
- publishOptions.computeProperties(""),
- MESSAGE);
- assertThatThrownBy(() -> rmqSink.invoke("msg", SinkContextUtil.forTimestamp(0)))
- .isInstanceOf(RuntimeException.class);
- }
-
- @Test
- void exceptionDuringWithOptionsPublishingIsIgnoredIfLogFailuresOnly() throws Exception {
- RMQSink<String> rmqSink = createRMQSinkWithOptions(false, false);
- rmqSink.setLogFailuresOnly(true);
-
- doThrow(IOException.class)
- .when(channel)
- .basicPublish(
- EXCHANGE,
- ROUTING_KEY,
- false,
- false,
- publishOptions.computeProperties(""),
- MESSAGE);
- rmqSink.invoke("msg", SinkContextUtil.forTimestamp(0));
- }
-
- private class DummyPublishOptions implements RMQSinkPublishOptions<String> {
- private static final long serialVersionUID = 1L;
- private boolean mandatory = false;
- private boolean immediate = false;
-
- public DummyPublishOptions(boolean mandatory, boolean immediate) {
- this.mandatory = mandatory;
- this.immediate = immediate;
- }
-
- @Override
- public String computeRoutingKey(String a) {
- return ROUTING_KEY;
- }
-
- @Override
- public BasicProperties computeProperties(String a) {
- return props;
- }
-
- @Override
- public String computeExchange(String a) {
- return EXCHANGE;
- }
-
- @Override
- public boolean computeMandatory(String a) {
- return mandatory;
- }
-
- @Override
- public boolean computeImmediate(String a) {
- return immediate;
- }
- }
-
- private class DummyReturnHandler implements SerializableReturnListener {
-
- private static final long serialVersionUID = 1L;
-
- @Override
- public void handleReturn(
- final int replyCode,
- final String replyText,
- final String exchange,
- final String routingKey,
- final BasicProperties properties,
- final byte[] body) {}
- }
-
- private class DummySerializationSchema implements SerializationSchema<String> {
- private static final long serialVersionUID = 1L;
-
- @Override
- public byte[] serialize(String element) {
- return MESSAGE;
- }
- }
-}
diff --git a/flink-connectors/flink-connector-rabbitmq/src/test/java/org/apache/flink/streaming/connectors/rabbitmq/RMQSourceITCase.java b/flink-connectors/flink-connector-rabbitmq/src/test/java/org/apache/flink/streaming/connectors/rabbitmq/RMQSourceITCase.java
deleted file mode 100644
index 6090b4c3220..00000000000
--- a/flink-connectors/flink-connector-rabbitmq/src/test/java/org/apache/flink/streaming/connectors/rabbitmq/RMQSourceITCase.java
+++ /dev/null
@@ -1,242 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.flink.streaming.connectors.rabbitmq;
-
-import org.apache.flink.api.common.JobID;
-import org.apache.flink.api.common.JobStatus;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
-import org.apache.flink.api.common.serialization.SimpleStringSchema;
-import org.apache.flink.client.program.ClusterClient;
-import org.apache.flink.client.program.rest.RestClusterClient;
-import org.apache.flink.configuration.Configuration;
-import org.apache.flink.core.execution.SavepointFormatType;
-import org.apache.flink.runtime.execution.ExecutionState;
-import org.apache.flink.runtime.jobgraph.JobGraph;
-import org.apache.flink.runtime.testutils.CommonTestUtils;
-import org.apache.flink.runtime.testutils.MiniClusterResourceConfiguration;
-import org.apache.flink.streaming.api.datastream.DataStreamSource;
-import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
-import org.apache.flink.streaming.api.functions.sink.DiscardingSink;
-import org.apache.flink.streaming.api.functions.sink.SinkFunction;
-import org.apache.flink.streaming.connectors.rabbitmq.common.RMQConnectionConfig;
-import org.apache.flink.test.junit5.InjectClusterClient;
-import org.apache.flink.test.junit5.MiniClusterExtension;
-import org.apache.flink.util.DockerImageVersions;
-
-import com.rabbitmq.client.AMQP;
-import com.rabbitmq.client.Channel;
-import com.rabbitmq.client.Connection;
-import com.rabbitmq.client.ConnectionFactory;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.RegisterExtension;
-import org.junit.jupiter.api.io.TempDir;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testcontainers.containers.RabbitMQContainer;
-import org.testcontainers.containers.output.Slf4jLogConsumer;
-import org.testcontainers.junit.jupiter.Container;
-import org.testcontainers.junit.jupiter.Testcontainers;
-import org.testcontainers.utility.DockerImageName;
-
-import java.io.IOException;
-import java.nio.file.Path;
-import java.util.List;
-import java.util.concurrent.TimeoutException;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.stream.Collectors;
-import java.util.stream.IntStream;
-
-/** A class containing RabbitMQ source tests against a real RabbiMQ cluster. */
-@Testcontainers
-class RMQSourceITCase {
-
- private static final Logger LOG = LoggerFactory.getLogger(RMQSourceITCase.class);
- private static final Slf4jLogConsumer LOG_CONSUMER = new Slf4jLogConsumer(LOG);
-
- private static final int HANDSHAKE_TIMEOUT = 30000;
- private static final int RABBITMQ_PORT = 5672;
- private static final String QUEUE_NAME = "test-queue";
- private static final JobID JOB_ID = new JobID();
- private static final SimpleStringSchema SCHEMA = new SimpleStringSchema();
-
- private RMQConnectionConfig config;
-
- @TempDir Path tmp;
-
- @RegisterExtension
- private static final MiniClusterExtension MINI_CLUSTER_RESOURCE =
- new MiniClusterExtension(
- new MiniClusterResourceConfiguration.Builder()
- .setConfiguration(new Configuration())
- .setNumberSlotsPerTaskManager(1)
- .setNumberTaskManagers(1)
- .build());
-
- @Container
- static final RabbitMQContainer RMQ_CONTAINER =
- new RabbitMQContainer(DockerImageName.parse(DockerImageVersions.RABBITMQ))
- .withExposedPorts(RABBITMQ_PORT)
- .withLogConsumer(LOG_CONSUMER);
-
- @BeforeEach
- void setUp() throws Exception {
- final Connection connection = getRMQConnection();
- final Channel channel = connection.createChannel();
- channel.queueDeclare(QUEUE_NAME, true, false, false, null);
- channel.queuePurge(QUEUE_NAME);
- channel.txSelect();
- config =
- new RMQConnectionConfig.Builder()
- .setHost(RMQ_CONTAINER.getHost())
- .setDeliveryTimeout(500)
- .setPrefetchCount(5)
- .setVirtualHost("/")
- .setUserName(RMQ_CONTAINER.getAdminUsername())
- .setPassword(RMQ_CONTAINER.getAdminPassword())
- .setPort(RMQ_CONTAINER.getMappedPort(RABBITMQ_PORT))
- .build();
- CountingSink.reset();
- }
-
- @Test
- void testStopWithSavepoint(
- @InjectClusterClient RestClusterClient<?> clusterClient, @TempDir Path tmp)
- throws Exception {
- final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
- final DataStreamSource<String> source =
- env.addSource(new RMQSource<>(config, QUEUE_NAME, SCHEMA));
- source.addSink(new DiscardingSink<>());
- env.enableCheckpointing(500);
- final JobGraph jobGraph = env.getStreamGraph().getJobGraph();
- jobGraph.setJobID(JOB_ID);
- clusterClient.submitJob(jobGraph).get();
- CommonTestUtils.waitUntilCondition(
- () ->
- clusterClient.getJobStatus(JOB_ID).get() == JobStatus.RUNNING
- && clusterClient.getJobDetails(JOB_ID).get().getJobVertexInfos()
- .stream()
- .allMatch(
- info ->
- info.getExecutionState()
- == ExecutionState.RUNNING),
- 5L);
-
- clusterClient
- .stopWithSavepoint(
- JOB_ID,
- false,
- tmp.toAbsolutePath().toString(),
- SavepointFormatType.CANONICAL)
- .get();
- }
-
- @Test
- void testMessageDelivery(@InjectClusterClient ClusterClient<?> clusterClient) throws Exception {
- final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
- List<String> msgs =
- IntStream.range(0, 10).mapToObj(String::valueOf).collect(Collectors.toList());
- publishToRMQ(msgs);
-
- final DataStreamSource<String> source =
- env.addSource(new RMQSource<>(config, QUEUE_NAME, SCHEMA));
- source.addSink(CountingSink.getInstance());
- final JobGraph jobGraph = env.getStreamGraph().getJobGraph();
- JobID jobId = clusterClient.submitJob(jobGraph).get();
- CommonTestUtils.waitUntilCondition(() -> CountingSink.getCount() == msgs.size(), 5L);
- clusterClient.cancel(jobId);
- }
-
- @Test
- void testAckFailure(@InjectClusterClient ClusterClient<?> clusterClient) throws Exception {
- final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
- env.setRestartStrategy(RestartStrategies.fixedDelayRestart(Integer.MAX_VALUE, 500));
- env.enableCheckpointing(500);
- List<String> msgs =
- IntStream.range(0, 10).mapToObj(String::valueOf).collect(Collectors.toList());
- publishToRMQ(msgs);
-
- RMQSource<String> rmqSource =
- new RMQSource<String>(config, QUEUE_NAME, true, SCHEMA) {
- @Override
- protected void acknowledgeSessionIDs(List<Long> sessionIds) {
- try {
- if (!sessionIds.isEmpty()) {
- throw new RuntimeException("Test acknowledge failure");
- }
- channel.txCommit();
- } catch (IOException e) {
- throw new RuntimeException("Error while committing transaction", e);
- }
- }
- };
- final DataStreamSource<String> source = env.addSource(rmqSource);
- source.addSink(CountingSink.getInstance());
- final JobGraph jobGraph = env.getStreamGraph().getJobGraph();
- JobID jobId = clusterClient.submitJob(jobGraph).get();
- CommonTestUtils.waitUntilCondition(() -> CountingSink.getCount() == msgs.size(), 5L);
- clusterClient.cancel(jobId);
- }
-
- private static Connection getRMQConnection() throws IOException, TimeoutException {
- ConnectionFactory factory = new ConnectionFactory();
- factory.setUsername(RMQ_CONTAINER.getAdminUsername());
- factory.setPassword(RMQ_CONTAINER.getAdminPassword());
- factory.setHandshakeTimeout(HANDSHAKE_TIMEOUT);
- factory.setVirtualHost("/");
- factory.setHost(RMQ_CONTAINER.getHost());
- factory.setPort(RMQ_CONTAINER.getAmqpPort());
- return factory.newConnection();
- }
-
- private static void publishToRMQ(Iterable<String> messages)
- throws IOException, TimeoutException {
- AMQP.BasicProperties.Builder propertiesBuilder = new AMQP.BasicProperties.Builder();
- try (Connection rmqConnection = getRMQConnection();
- Channel channel = rmqConnection.createChannel()) {
- for (String msg : messages) {
- AMQP.BasicProperties properties = propertiesBuilder.correlationId(msg).build();
- channel.basicPublish("", QUEUE_NAME, properties, SCHEMA.serialize(msg));
- }
- }
- }
-
- private static class CountingSink implements SinkFunction<String> {
-
- private static final AtomicInteger count = new AtomicInteger();
-
- public static CountingSink getInstance() {
- return new CountingSink();
- }
-
- public static void reset() {
- count.set(0);
- }
-
- public static int getCount() {
- return count.get();
- }
-
- @Override
- public void invoke(String value, SinkFunction.Context context) {
- count.incrementAndGet();
- }
- }
-}
diff --git a/flink-connectors/flink-connector-rabbitmq/src/test/java/org/apache/flink/streaming/connectors/rabbitmq/RMQSourceTest.java b/flink-connectors/flink-connector-rabbitmq/src/test/java/org/apache/flink/streaming/connectors/rabbitmq/RMQSourceTest.java
deleted file mode 100644
index 986d23b75d2..00000000000
--- a/flink-connectors/flink-connector-rabbitmq/src/test/java/org/apache/flink/streaming/connectors/rabbitmq/RMQSourceTest.java
+++ /dev/null
@@ -1,852 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.flink.streaming.connectors.rabbitmq;
-
-import org.apache.flink.api.common.functions.RuntimeContext;
-import org.apache.flink.api.common.serialization.DeserializationSchema;
-import org.apache.flink.api.common.state.ListStateDescriptor;
-import org.apache.flink.api.common.state.OperatorStateStore;
-import org.apache.flink.api.common.typeinfo.TypeInformation;
-import org.apache.flink.api.java.tuple.Tuple2;
-import org.apache.flink.api.java.typeutils.TypeExtractor;
-import org.apache.flink.configuration.ConfigConstants;
-import org.apache.flink.configuration.Configuration;
-import org.apache.flink.runtime.checkpoint.OperatorSubtaskState;
-import org.apache.flink.runtime.state.FunctionInitializationContext;
-import org.apache.flink.streaming.api.functions.source.SourceFunction;
-import org.apache.flink.streaming.api.operators.StreamSource;
-import org.apache.flink.streaming.api.operators.StreamingRuntimeContext;
-import org.apache.flink.streaming.api.watermark.Watermark;
-import org.apache.flink.streaming.connectors.rabbitmq.common.RMQConnectionConfig;
-import org.apache.flink.streaming.util.AbstractStreamOperatorTestHarness;
-import org.apache.flink.streaming.util.MockDeserializationSchema;
-
-import com.rabbitmq.client.AMQP;
-import com.rabbitmq.client.Channel;
-import com.rabbitmq.client.Connection;
-import com.rabbitmq.client.ConnectionFactory;
-import com.rabbitmq.client.Delivery;
-import com.rabbitmq.client.Envelope;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.Timeout;
-import org.mockito.Mockito;
-import org.mockito.internal.stubbing.answers.CallsRealMethods;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
-
-import java.io.IOException;
-import java.util.ArrayDeque;
-import java.util.Random;
-import java.util.Set;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.assertj.core.api.Assertions.fail;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyInt;
-
-/**
- * Tests for the RMQSource. The source supports two operation modes. 1) Exactly-once (when
- * checkpointed) with RabbitMQ transactions and the deduplication mechanism in {@link
- * org.apache.flink.streaming.api.functions.source.MessageAcknowledgingSourceBase}. 2) At-least-once
- * (when checkpointed) with RabbitMQ transactions but not deduplication. 3) No strong delivery
- * guarantees (without checkpointing) with RabbitMQ auto-commit mode.
- *
- * <p>This tests assumes that the message ids are increasing monotonously. That doesn't have to be
- * the case. The correlation id is used to uniquely identify messages.
- */
-class RMQSourceTest {
-
- private RMQSource<String> source;
-
- private Configuration config = new Configuration();
-
- private Thread sourceThread;
-
- private volatile long messageId;
-
- private boolean generateCorrelationIds;
-
- private volatile Exception exception;
-
- /**
- * Gets a mock context for initializing the source's state via {@link
- * org.apache.flink.streaming.api.checkpoint.CheckpointedFunction#initializeState}.
- *
- * @throws Exception
- */
- FunctionInitializationContext getMockContext() throws Exception {
- OperatorStateStore mockStore = Mockito.mock(OperatorStateStore.class);
- FunctionInitializationContext mockContext =
- Mockito.mock(FunctionInitializationContext.class);
- Mockito.when(mockContext.getOperatorStateStore()).thenReturn(mockStore);
- Mockito.when(mockStore.getListState(any(ListStateDescriptor.class))).thenReturn(null);
- return mockContext;
- }
-
- @BeforeEach
- void beforeTest() throws Exception {
- FunctionInitializationContext mockContext = getMockContext();
-
- source = new RMQTestSource();
- source.initializeState(mockContext);
- source.open(config);
-
- DummySourceContext.numElementsCollected = 0;
- messageId = 0;
- generateCorrelationIds = true;
-
- sourceThread =
- new Thread(
- new Runnable() {
- @Override
- public void run() {
- try {
- source.run(new DummySourceContext());
- } catch (Exception e) {
- exception = e;
- }
- }
- });
- }
-
- @AfterEach
- void afterTest() throws Exception {
- source.cancel();
- sourceThread.join();
- }
-
- @Test
- void throwExceptionIfConnectionFactoryReturnNull() throws Exception {
- RMQConnectionConfig connectionConfig = Mockito.mock(RMQConnectionConfig.class);
- ConnectionFactory connectionFactory = Mockito.mock(ConnectionFactory.class);
- Connection connection = Mockito.mock(Connection.class);
- Mockito.when(connectionConfig.getConnectionFactory()).thenReturn(connectionFactory);
- Mockito.when(connectionFactory.newConnection()).thenReturn(connection);
- Mockito.when(connection.createChannel()).thenReturn(null);
-
- RMQSource<String> rmqSource =
- new RMQSource<>(
- connectionConfig, "queueDummy", true, new StringDeserializationScheme());
- assertThatThrownBy(() -> rmqSource.open(new Configuration()))
- .isInstanceOf(RuntimeException.class)
- .hasMessage("None of RabbitMQ channels are available");
- }
-
- @Test
- void testResourceCleanupOnOpenFailure() throws Exception {
- RMQConnectionConfig connectionConfig = Mockito.mock(RMQConnectionConfig.class);
- ConnectionFactory connectionFactory = Mockito.mock(ConnectionFactory.class);
- Connection connection = Mockito.mock(Connection.class);
- Mockito.when(connectionConfig.getConnectionFactory()).thenReturn(connectionFactory);
- Mockito.when(connectionConfig.getHost()).thenReturn("hostDummy");
- Mockito.when(connectionFactory.newConnection()).thenReturn(connection);
- Mockito.when(connection.createChannel()).thenThrow(new IOException());
-
- RMQSource<String> rmqSource =
- new RMQSource<>(
- connectionConfig, "queueDummy", true, new StringDeserializationScheme());
- assertThatThrownBy(() -> rmqSource.open(new Configuration()))
- .isInstanceOf(RuntimeException.class)
- .hasMessage("Cannot create RMQ connection with queueDummy at hostDummy");
- Mockito.verify(rmqSource.connection, Mockito.atLeastOnce()).close();
- }
-
- @Test
- void testOpenCallDeclaresQueueInStandardMode() throws Exception {
- FunctionInitializationContext mockContext = getMockContext();
-
- RMQConnectionConfig connectionConfig = Mockito.mock(RMQConnectionConfig.class);
- ConnectionFactory connectionFactory = Mockito.mock(ConnectionFactory.class);
- Connection connection = Mockito.mock(Connection.class);
- Channel channel = Mockito.mock(Channel.class);
-
- Mockito.when(connectionConfig.getConnectionFactory()).thenReturn(connectionFactory);
- Mockito.when(connectionFactory.newConnection()).thenReturn(connection);
- Mockito.when(connection.createChannel()).thenReturn(channel);
-
- RMQSource<String> rmqSource = new RMQMockedRuntimeTestSource(connectionConfig);
- rmqSource.initializeState(mockContext);
- rmqSource.open(new Configuration());
-
- Mockito.verify(channel).queueDeclare(RMQTestSource.QUEUE_NAME, true, false, false, null);
- }
-
- @Test
- void testResourceCleanupOnClose() throws Exception {
- FunctionInitializationContext mockContext = getMockContext();
-
- RMQConnectionConfig connectionConfig = Mockito.mock(RMQConnectionConfig.class);
- ConnectionFactory connectionFactory = Mockito.mock(ConnectionFactory.class);
- Connection connection = Mockito.mock(Connection.class);
- Channel channel = Mockito.mock(Channel.class);
-
- Mockito.when(connectionConfig.getConnectionFactory()).thenReturn(connectionFactory);
- Mockito.when(connectionFactory.newConnection()).thenReturn(connection);
- Mockito.when(connectionConfig.getHost()).thenReturn("hostDummy");
- Mockito.when(connection.createChannel()).thenReturn(channel);
- Mockito.doThrow(new IOException("Consumer cancel error")).when(channel).basicCancel(any());
- Mockito.doThrow(new IOException("Channel error")).when(channel).close();
- Mockito.doThrow(new IOException("Connection error")).when(connection).close();
-
- RMQSource<String> rmqSource = new RMQMockedRuntimeTestSource(connectionConfig);
- rmqSource.initializeState(mockContext);
- rmqSource.open(new Configuration());
-
- assertThatThrownBy(rmqSource::close)
- .isInstanceOf(RuntimeException.class)
- .hasMessage("Error while cancelling RMQ consumer on queueDummy at hostDummy")
- .extracting(Throwable::getSuppressed)
- .satisfies(t -> assertThat(t).hasSize(1))
- .satisfies(
- t ->
- assertThat(t[0])
- .hasMessage(
- "Error while closing RMQ source with queueDummy at hostDummy"));
- Mockito.verify(rmqSource.channel, Mockito.atLeastOnce()).basicCancel(any());
- Mockito.verify(rmqSource.channel, Mockito.atLeastOnce()).close();
- Mockito.verify(rmqSource.connection, Mockito.atLeastOnce()).close();
- }
-
- @Test
- void testCheckpointing() throws Exception {
- source.autoAck = false;
-
- StreamSource<String, RMQSource<String>> src = new StreamSource<>(source);
- AbstractStreamOperatorTestHarness<String> testHarness =
- new AbstractStreamOperatorTestHarness<>(src, 1, 1, 0);
- testHarness.open();
-
- sourceThread.start();
-
- Thread.sleep(5);
-
- final Random random = new Random(System.currentTimeMillis());
- int numSnapshots = 50;
- long previousSnapshotId;
- long lastSnapshotId = 0;
-
- long totalNumberOfAcks = 0;
-
- for (int i = 0; i < numSnapshots; i++) {
- long snapshotId = random.nextLong();
- OperatorSubtaskState data;
-
- synchronized (DummySourceContext.lock) {
- data = testHarness.snapshot(snapshotId, System.currentTimeMillis());
- previousSnapshotId = lastSnapshotId;
- lastSnapshotId = messageId;
- }
- // let some time pass
- Thread.sleep(5);
-
- // check if the correct number of messages have been snapshotted
- final long numIds = lastSnapshotId - previousSnapshotId;
-
- RMQTestSource sourceCopy = new RMQTestSource();
- StreamSource<String, RMQTestSource> srcCopy = new StreamSource<>(sourceCopy);
- AbstractStreamOperatorTestHarness<String> testHarnessCopy =
- new AbstractStreamOperatorTestHarness<>(srcCopy, 1, 1, 0);
-
- testHarnessCopy.setup();
- testHarnessCopy.initializeState(data);
- testHarnessCopy.open();
-
- ArrayDeque<Tuple2<Long, Set<String>>> deque = sourceCopy.getRestoredState();
- Set<String> messageIds = deque.getLast().f1;
-
- assertThat(messageIds).hasSize((int) numIds);
- if (messageIds.size() > 0) {
- assertThat(messageIds).contains(Long.toString(lastSnapshotId - 1));
- }
-
- // check if the messages are being acknowledged and the transaction committed
- synchronized (DummySourceContext.lock) {
- source.notifyCheckpointComplete(snapshotId);
- }
- totalNumberOfAcks += numIds;
- }
-
- Mockito.verify(source.channel, Mockito.times((int) totalNumberOfAcks))
- .basicAck(Mockito.anyLong(), Mockito.eq(false));
- Mockito.verify(source.channel, Mockito.times(numSnapshots)).txCommit();
- }
-
- /** Checks whether recurring ids are processed again (they shouldn't be). */
- @Test
- void testDuplicateId() throws Exception {
- source.autoAck = false;
- sourceThread.start();
-
- while (messageId < 10) {
- // wait until messages have been processed
- Thread.sleep(5);
- }
-
- long oldMessageId;
- synchronized (DummySourceContext.lock) {
- oldMessageId = messageId;
- messageId = 0;
- }
-
- while (messageId < 10) {
- // process again
- Thread.sleep(5);
- }
-
- synchronized (DummySourceContext.lock) {
- assertThat(Math.max(messageId, oldMessageId))
- .isEqualTo(DummySourceContext.numElementsCollected);
- }
- }
-
- /**
- * The source should not acknowledge ids in auto-commit mode or check for previously
- * acknowledged ids.
- */
- @Test
- void testCheckpointingDisabled() throws Exception {
- source.autoAck = true;
- sourceThread.start();
-
- while (DummySourceContext.numElementsCollected < 50) {
- // wait until messages have been processed
- Thread.sleep(5);
- }
-
- // verify if RMQTestSource#addId was never called
- assertThat(((RMQTestSource) source).addIdCalls).isEqualTo(0);
- }
-
- /** Tests error reporting in case of invalid correlation ids. */
- @Test
- void testCorrelationIdNotSet() throws InterruptedException {
- generateCorrelationIds = false;
- source.autoAck = false;
- sourceThread.start();
-
- sourceThread.join();
-
- assertThat(exception).isInstanceOf(NullPointerException.class);
- }
-
- /** Tests whether redelivered messages are acknowledged properly. */
- @Test
- void testRedeliveredSessionIDsAck() throws Exception {
- source.autoAck = false;
-
- StreamSource<String, RMQSource<String>> src = new StreamSource<>(source);
- AbstractStreamOperatorTestHarness<String> testHarness =
- new AbstractStreamOperatorTestHarness<>(src, 1, 1, 0);
- testHarness.open();
- sourceThread.start();
-
- while (DummySourceContext.numElementsCollected < 10) {
- // wait until messages have been processed
- Thread.sleep(5);
- }
-
- // mock message redelivery by resetting the message ID
- long numMsgRedelivered;
- synchronized (DummySourceContext.lock) {
- numMsgRedelivered = DummySourceContext.numElementsCollected;
- messageId = 0;
- }
- while (DummySourceContext.numElementsCollected < numMsgRedelivered + 10) {
- // wait until some messages will be redelivered
- Thread.sleep(5);
- }
-
- // ack the messages by snapshotting the state
- final Random random = new Random(System.currentTimeMillis());
- long lastMessageId;
- long snapshotId = random.nextLong();
- synchronized (DummySourceContext.lock) {
- testHarness.snapshot(snapshotId, System.currentTimeMillis());
- source.notifyCheckpointComplete(snapshotId);
- lastMessageId = messageId;
-
- // check if all the messages are being collected and acknowledged
- long totalNumberOfAcks = numMsgRedelivered + lastMessageId;
- assertThat(lastMessageId).isEqualTo(DummySourceContext.numElementsCollected);
- assertThat(totalNumberOfAcks).isEqualTo(((RMQTestSource) source).addIdCalls);
- }
-
- // check if all the acks are being sent
- Mockito.verify(source.channel, Mockito.times((int) lastMessageId))
- .basicAck(Mockito.anyLong(), Mockito.eq(false));
- Mockito.verify(source.channel, Mockito.times((int) numMsgRedelivered))
- .basicReject(Mockito.anyLong(), Mockito.eq(false));
- }
-
- /** Tests whether constructor params are passed correctly. */
- @Test
- void testConstructorParams() throws Exception {
- // verify construction params
- RMQConnectionConfig.Builder builder = new RMQConnectionConfig.Builder();
- builder.setHost("hostTest")
- .setPort(999)
- .setUserName("userTest")
- .setPassword("passTest")
- .setVirtualHost("/");
- ConstructorTestClass testObj =
- new ConstructorTestClass(
- builder.build(), "queueTest", false, new StringDeserializationScheme());
-
- try {
- testObj.open(new Configuration());
- } catch (Exception e) {
- // connection fails but check if args have been passed correctly
- }
-
- assertThat(testObj.getFactory().getHost()).isEqualTo("hostTest");
- assertThat(testObj.getFactory().getPort()).isEqualTo(999);
- assertThat(testObj.getFactory().getUsername()).isEqualTo("userTest");
- assertThat(testObj.getFactory().getPassword()).isEqualTo("passTest");
- }
-
- @Test
- @Timeout(value = 30_000, unit = TimeUnit.MILLISECONDS)
- void testCustomIdentifiers() throws Exception {
- source = new RMQTestSource(new CustomDeserializationSchema());
- source.initializeState(getMockContext());
- source.open(config);
- sourceThread.start();
- sourceThread.join();
-
- assertThat(DummySourceContext.numElementsCollected).isEqualTo(2L);
- }
-
- @Test
- void testOpen() throws Exception {
- MockDeserializationSchema<String> deserializationSchema = new MockDeserializationSchema<>();
-
- RMQSource<String> consumer = new RMQTestSource(deserializationSchema);
- AbstractStreamOperatorTestHarness<String> testHarness =
- new AbstractStreamOperatorTestHarness<>(new StreamSource<>(consumer), 1, 1, 0);
-
- testHarness.open();
- assertThat(deserializationSchema.isOpenCalled()).as("Open method was not called").isTrue();
- }
-
- @Test
- void testOverrideConnection() throws Exception {
- final Connection mockConnection = Mockito.mock(Connection.class);
- Channel channel = Mockito.mock(Channel.class);
- Mockito.when(mockConnection.createChannel()).thenReturn(channel);
-
- RMQMockedRuntimeTestSource source =
- new RMQMockedRuntimeTestSource() {
- @Override
- protected Connection setupConnection() throws Exception {
- return mockConnection;
- }
- };
-
- FunctionInitializationContext mockContext = getMockContext();
- source.initializeState(mockContext);
- source.open(new Configuration());
-
- Mockito.verify(mockConnection, Mockito.times(1)).createChannel();
- }
-
- @Test
- void testSetPrefetchCount() throws Exception {
- RMQConnectionConfig connectionConfig =
- new RMQConnectionConfig.Builder()
- .setHost("localhost")
- .setPort(5000)
- .setUserName("guest")
- .setPassword("guest")
- .setVirtualHost("/")
- .setPrefetchCount(1000)
- .build();
- final Connection mockConnection = Mockito.mock(Connection.class);
- Channel channel = Mockito.mock(Channel.class);
- Mockito.when(mockConnection.createChannel()).thenReturn(channel);
-
- RMQMockedRuntimeTestSource source =
- new RMQMockedRuntimeTestSource(connectionConfig) {
- @Override
- protected Connection setupConnection() throws Exception {
- return mockConnection;
- }
- };
-
- FunctionInitializationContext mockContext = getMockContext();
- source.initializeState(mockContext);
- source.open(new Configuration());
-
- Mockito.verify(mockConnection, Mockito.times(1)).createChannel();
- Mockito.verify(channel, Mockito.times(1)).basicQos(1000, true);
- }
-
- @Test
- void testUnsetPrefetchCount() throws Exception {
- final Connection mockConnection = Mockito.mock(Connection.class);
- Channel channel = Mockito.mock(Channel.class);
- Mockito.when(mockConnection.createChannel()).thenReturn(channel);
-
- RMQMockedRuntimeTestSource source =
- new RMQMockedRuntimeTestSource() {
- @Override
- protected Connection setupConnection() throws Exception {
- return mockConnection;
- }
- };
-
- FunctionInitializationContext mockContext = getMockContext();
- source.initializeState(mockContext);
- source.open(new Configuration());
-
- Mockito.verify(mockConnection, Mockito.times(1)).createChannel();
- Mockito.verify(channel, Mockito.times(0)).basicQos(anyInt());
- }
-
- @Test
- void testDeliveryTimeout() throws Exception {
- source.autoAck = false;
- // mock not delivering messages
- CallsRealMethodsWithLatch delivery = new CallsRealMethodsWithLatch();
- Mockito.when(source.consumer.nextDelivery(any(Long.class))).then(delivery);
-
- sourceThread.start();
- // wait until message delivery starts
- delivery.awaitInvoke();
-
- source.cancel();
- sourceThread.join();
- Mockito.verify(source.consumer, Mockito.never()).nextDelivery();
- Mockito.verify(source.consumer, Mockito.atLeastOnce()).nextDelivery(any(Long.class));
- assertThat(exception).isNull();
- }
-
- private static class CallsRealMethodsWithLatch extends CallsRealMethods {
-
- private final CountDownLatch latch = new CountDownLatch(1);
-
- public void awaitInvoke() throws InterruptedException {
- latch.await();
- }
-
- public Object answer(InvocationOnMock invocation) throws Throwable {
- latch.countDown();
- return super.answer(invocation);
- }
- }
-
- private static class ConstructorTestClass extends RMQSource<String> {
-
- private ConnectionFactory factory;
-
- public ConstructorTestClass(
- RMQConnectionConfig rmqConnectionConfig,
- String queueName,
- boolean usesCorrelationId,
- DeserializationSchema<String> deserializationSchema)
- throws Exception {
- super(rmqConnectionConfig, queueName, usesCorrelationId, deserializationSchema);
- RMQConnectionConfig.Builder builder = new RMQConnectionConfig.Builder();
- builder.setHost("hostTest")
- .setPort(999)
- .setUserName("userTest")
- .setPassword("passTest")
- .setVirtualHost("/");
- factory = Mockito.spy(builder.build().getConnectionFactory());
- try {
- Mockito.doThrow(new RuntimeException()).when(factory).newConnection();
- } catch (IOException e) {
- fail("Failed to stub connection method");
- }
- }
-
- @Override
- protected ConnectionFactory setupConnectionFactory() {
- return factory;
- }
-
- public ConnectionFactory getFactory() {
- return factory;
- }
- }
-
- private static class StringDeserializationScheme implements DeserializationSchema<String> {
-
- @Override
- public String deserialize(byte[] message) throws IOException {
- try {
- // wait a bit to not cause too much cpu load
- Thread.sleep(1);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- return new String(message, ConfigConstants.DEFAULT_CHARSET);
- }
-
- @Override
- public boolean isEndOfStream(String nextElement) {
- return false;
- }
-
- @Override
- public TypeInformation<String> getProducedType() {
- return TypeExtractor.getForClass(String.class);
- }
- }
-
- private static class CustomDeserializationSchema implements RMQDeserializationSchema<String> {
- @Override
- public TypeInformation<String> getProducedType() {
- return TypeExtractor.getForClass(String.class);
- }
-
- @Override
- public void deserialize(
- Envelope envelope,
- AMQP.BasicProperties properties,
- byte[] body,
- RMQCollector<String> collector) {
- String correlationId = properties.getCorrelationId();
- if (correlationId.equals("1")) {
- collector.setMessageIdentifiers("1", envelope.getDeliveryTag());
- collector.collect("I Love Turtles");
- collector.collect("Brush your teeth");
- } else if (correlationId.equals("2")) {
- // should not be emitted, because it has the same correlationId as the previous one
- collector.setMessageIdentifiers("1", envelope.getDeliveryTag());
- collector.collect("Brush your teeth");
- } else {
- // should end the stream, should not be emitted
- collector.setMessageIdentifiers("2", envelope.getDeliveryTag());
- collector.collect("FINISH");
- }
- }
-
- @Override
- public boolean isEndOfStream(String record) {
- return record.equals("FINISH");
- }
- }
-
- /**
- * A base class of {@link RMQTestSource} for testing functions that rely on the {@link
- * RuntimeContext}.
- */
- private static class RMQMockedRuntimeTestSource extends RMQSource<String> {
- static final String QUEUE_NAME = "queueDummy";
-
- static final RMQConnectionConfig CONNECTION_CONFIG =
- new RMQConnectionConfig.Builder()
- .setHost("hostTest")
- .setPort(999)
- .setUserName("userTest")
- .setPassword("passTest")
- .setVirtualHost("/")
- .setDeliveryTimeout(100)
- .build();
-
- protected RuntimeContext runtimeContext = Mockito.mock(StreamingRuntimeContext.class);
-
- public RMQMockedRuntimeTestSource(
- RMQConnectionConfig connectionConfig,
- DeserializationSchema<String> deserializationSchema) {
- super(connectionConfig, QUEUE_NAME, true, deserializationSchema);
- }
-
- public RMQMockedRuntimeTestSource(
- RMQConnectionConfig connectionConfig,
- RMQDeserializationSchema<String> deliveryParser) {
- super(connectionConfig, QUEUE_NAME, true, deliveryParser);
- }
-
- public RMQMockedRuntimeTestSource(DeserializationSchema<String> deserializationSchema) {
- this(CONNECTION_CONFIG, deserializationSchema);
- }
-
- public RMQMockedRuntimeTestSource(RMQDeserializationSchema<String> deliveryParser) {
- this(CONNECTION_CONFIG, deliveryParser);
- }
-
- public RMQMockedRuntimeTestSource(RMQConnectionConfig connectionConfig) {
- this(connectionConfig, new StringDeserializationScheme());
- }
-
- public RMQMockedRuntimeTestSource() {
- this(new StringDeserializationScheme());
- }
-
- @Override
- public RuntimeContext getRuntimeContext() {
- return runtimeContext;
- }
- }
-
- private class RMQTestSource extends RMQMockedRuntimeTestSource {
- private ArrayDeque<Tuple2<Long, Set<String>>> restoredState;
-
- private Delivery mockedDelivery;
- public Envelope mockedAMQPEnvelope;
- public AMQP.BasicProperties mockedAMQPProperties;
- public int addIdCalls = 0;
-
- public RMQTestSource() {
- super();
- }
-
- public RMQTestSource(DeserializationSchema<String> deserializationSchema) {
- super(deserializationSchema);
- }
-
- public RMQTestSource(RMQDeserializationSchema<String> deliveryParser) {
- super(deliveryParser);
- }
-
- @Override
- public void initializeState(FunctionInitializationContext context) throws Exception {
- super.initializeState(context);
- this.restoredState = this.pendingCheckpoints;
- }
-
- public ArrayDeque<Tuple2<Long, Set<String>>> getRestoredState() {
- return this.restoredState;
- }
-
- public void initAMQPMocks() {
- consumer = Mockito.mock(QueueingConsumer.class);
-
- // Mock for delivery
- mockedDelivery = Mockito.mock(Delivery.class);
- Mockito.when(mockedDelivery.getBody())
- .thenReturn("test".getBytes(ConfigConstants.DEFAULT_CHARSET));
-
- try {
- Mockito.when(consumer.nextDelivery(any(Long.class))).thenReturn(mockedDelivery);
- } catch (InterruptedException e) {
- fail("Couldn't setup up deliveryMock");
- }
-
- // Mock for envelope
- mockedAMQPEnvelope = Mockito.mock(Envelope.class);
- Mockito.when(mockedDelivery.getEnvelope()).thenReturn(mockedAMQPEnvelope);
-
- Mockito.when(mockedAMQPEnvelope.getDeliveryTag())
- .thenAnswer(
- new Answer<Long>() {
- @Override
- public Long answer(InvocationOnMock invocation) throws Throwable {
- return ++messageId;
- }
- });
-
- // Mock for properties
- mockedAMQPProperties = Mockito.mock(AMQP.BasicProperties.class);
- Mockito.when(mockedDelivery.getProperties()).thenReturn(mockedAMQPProperties);
-
- Mockito.when(mockedAMQPProperties.getCorrelationId())
- .thenAnswer(
- new Answer<String>() {
- @Override
- public String answer(InvocationOnMock invocation) throws Throwable {
- return generateCorrelationIds ? "" + messageId : null;
- }
- });
-
- Mockito.when(mockedAMQPProperties.getMessageId())
- .thenAnswer(
- new Answer<String>() {
- @Override
- public String answer(InvocationOnMock invocation) throws Throwable {
- return messageId + "-MESSAGE_ID";
- }
- });
- }
-
- @Override
- public void open(Configuration config) throws Exception {
- super.open(config);
- initAMQPMocks();
- }
-
- @Override
- protected ConnectionFactory setupConnectionFactory() {
- ConnectionFactory connectionFactory = Mockito.mock(ConnectionFactory.class);
- Connection connection = Mockito.mock(Connection.class);
- try {
- Mockito.when(connectionFactory.newConnection()).thenReturn(connection);
- Mockito.when(connection.createChannel()).thenReturn(Mockito.mock(Channel.class));
- } catch (IOException | TimeoutException e) {
- fail("Test environment couldn't be created.");
- }
- return connectionFactory;
- }
-
- @Override
- public void setRuntimeContext(RuntimeContext t) {
- this.runtimeContext = t;
- }
-
- @Override
- protected boolean addId(String uid) {
- addIdCalls++;
- assertThat(autoAck).isFalse();
- return super.addId(uid);
- }
- }
-
- private static class DummySourceContext implements SourceFunction.SourceContext<String> {
-
- private static final Object lock = new Object();
-
- private static long numElementsCollected;
-
- public DummySourceContext() {
- numElementsCollected = 0;
- }
-
- @Override
- public void collect(String element) {
- numElementsCollected++;
- }
-
- @Override
- public void collectWithTimestamp(java.lang.String element, long timestamp) {}
-
- @Override
- public void emitWatermark(Watermark mark) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void markAsTemporarilyIdle() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Object getCheckpointLock() {
- return lock;
- }
-
- @Override
- public void close() {}
- }
-}
diff --git a/flink-connectors/flink-connector-rabbitmq/src/test/java/org/apache/flink/streaming/connectors/rabbitmq/common/RMQConnectionConfigTest.java b/flink-connectors/flink-connector-rabbitmq/src/test/java/org/apache/flink/streaming/connectors/rabbitmq/common/RMQConnectionConfigTest.java
deleted file mode 100644
index 9cdf20b22f3..00000000000
--- a/flink-connectors/flink-connector-rabbitmq/src/test/java/org/apache/flink/streaming/connectors/rabbitmq/common/RMQConnectionConfigTest.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.flink.streaming.connectors.rabbitmq.common;
-
-import com.rabbitmq.client.ConnectionFactory;
-import org.junit.jupiter.api.Test;
-
-import java.net.URISyntaxException;
-import java.security.KeyManagementException;
-import java.security.NoSuchAlgorithmException;
-import java.util.Optional;
-import java.util.concurrent.TimeUnit;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy;
-
-/** Tests for the {@link RMQConnectionConfig}. */
-class RMQConnectionConfigTest {
-
- @Test
- void shouldThrowNullPointExceptionIfHostIsNull() {
- assertThatThrownBy(
- () -> {
- RMQConnectionConfig connectionConfig =
- new RMQConnectionConfig.Builder()
- .setPort(1000)
- .setUserName("guest")
- .setPassword("guest")
- .setVirtualHost("/")
- .build();
- connectionConfig.getConnectionFactory();
- })
- .isInstanceOf(NullPointerException.class);
- }
-
- @Test
- void shouldThrowNullPointExceptionIfPortIsNull() {
- assertThatThrownBy(
- () -> {
- RMQConnectionConfig connectionConfig =
- new RMQConnectionConfig.Builder()
- .setHost("localhost")
- .setUserName("guest")
- .setPassword("guest")
- .setVirtualHost("/")
- .build();
- connectionConfig.getConnectionFactory();
- })
- .isInstanceOf(NullPointerException.class);
- }
-
- @Test
- void shouldSetDefaultValueIfConnectionTimeoutNotGiven() {
- assertThatThrownBy(
- () -> {
- RMQConnectionConfig connectionConfig =
- new RMQConnectionConfig.Builder()
- .setHost("localhost")
- .setUserName("guest")
- .setPassword("guest")
- .setVirtualHost("/")
- .build();
- ConnectionFactory factory = connectionConfig.getConnectionFactory();
- assertThat(factory.getConnectionTimeout())
- .isEqualTo(ConnectionFactory.DEFAULT_CONNECTION_TIMEOUT);
- })
- .isInstanceOf(NullPointerException.class);
- }
-
- @Test
- void shouldSetProvidedValueIfConnectionTimeoutNotGiven()
- throws NoSuchAlgorithmException, KeyManagementException, URISyntaxException {
- RMQConnectionConfig connectionConfig =
- new RMQConnectionConfig.Builder()
- .setHost("localhost")
- .setPort(5000)
- .setUserName("guest")
- .setPassword("guest")
- .setVirtualHost("/")
- .setConnectionTimeout(5000)
- .build();
- ConnectionFactory factory = connectionConfig.getConnectionFactory();
- assertThat(factory.getConnectionTimeout()).isEqualTo(5000);
- }
-
- @Test
- void shouldSetOptionalPrefetchCount() {
- RMQConnectionConfig connectionConfig =
- new RMQConnectionConfig.Builder()
- .setHost("localhost")
- .setPort(5000)
- .setUserName("guest")
- .setPassword("guest")
- .setVirtualHost("/")
- .setPrefetchCount(500)
- .build();
- Optional<Integer> prefetch = connectionConfig.getPrefetchCount();
- assertThat(prefetch).isPresent();
- assertThat((int) prefetch.get()).isEqualTo(500);
- }
-
- @Test
- void shouldReturnEmptyOptionalPrefetchCount() {
- RMQConnectionConfig connectionConfig =
- new RMQConnectionConfig.Builder()
- .setHost("localhost")
- .setPort(5000)
- .setUserName("guest")
- .setPassword("guest")
- .setVirtualHost("/")
- .build();
- Optional<Integer> prefetch = connectionConfig.getPrefetchCount();
- assertThat(prefetch).isNotPresent();
- }
-
- @Test
- void shouldSetDeliveryTimeout() {
- RMQConnectionConfig.Builder builder =
- new RMQConnectionConfig.Builder()
- .setHost("localhost")
- .setPort(5000)
- .setUserName("guest")
- .setPassword("guest")
- .setVirtualHost("/");
- RMQConnectionConfig connectionConfig = builder.setDeliveryTimeout(10000).build();
- assertThat(connectionConfig.getDeliveryTimeout()).isEqualTo(10000);
-
- connectionConfig = builder.setDeliveryTimeout(10, TimeUnit.SECONDS).build();
- assertThat(connectionConfig.getDeliveryTimeout()).isEqualTo(10000);
- }
-
- @Test
- void shouldReturnDefaultDeliveryTimeout() {
- RMQConnectionConfig connectionConfig =
- new RMQConnectionConfig.Builder()
- .setHost("localhost")
- .setPort(5000)
- .setUserName("guest")
- .setPassword("guest")
- .setVirtualHost("/")
- .build();
- assertThat(connectionConfig.getDeliveryTimeout()).isEqualTo(30000);
- }
-
- @Test
- void shouldThrowIllegalArgumentExceptionIfDeliveryTimeoutIsNegative() {
- assertThatThrownBy(
- () ->
- new RMQConnectionConfig.Builder()
- .setHost("localhost")
- .setPort(1000)
- .setUserName("guest")
- .setPassword("guest")
- .setVirtualHost("/")
- .setDeliveryTimeout(-1)
- .build())
- .isInstanceOf(IllegalArgumentException.class);
- }
-
- @Test
- void shouldThrowIllegalArgumentExceptionIfDeliveryTimeoutWithUnitIsNegative() {
- assertThatThrownBy(
- () ->
- new RMQConnectionConfig.Builder()
- .setHost("localhost")
- .setPort(1000)
- .setUserName("guest")
- .setPassword("guest")
- .setVirtualHost("/")
- .setDeliveryTimeout(-1, TimeUnit.SECONDS)
- .build())
- .isInstanceOf(IllegalArgumentException.class);
- }
-}
diff --git a/flink-connectors/flink-connector-rabbitmq/src/test/resources/META-INF/services/org.junit.jupiter.api.extension.Extension b/flink-connectors/flink-connector-rabbitmq/src/test/resources/META-INF/services/org.junit.jupiter.api.extension.Extension
deleted file mode 100644
index 28999133c2b..00000000000
--- a/flink-connectors/flink-connector-rabbitmq/src/test/resources/META-INF/services/org.junit.jupiter.api.extension.Extension
+++ /dev/null
@@ -1,16 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-org.apache.flink.util.TestLoggerExtension
\ No newline at end of file
diff --git a/flink-connectors/flink-connector-rabbitmq/src/test/resources/archunit.properties b/flink-connectors/flink-connector-rabbitmq/src/test/resources/archunit.properties
deleted file mode 100644
index 15be88c95ba..00000000000
--- a/flink-connectors/flink-connector-rabbitmq/src/test/resources/archunit.properties
+++ /dev/null
@@ -1,31 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-# By default we allow removing existing violations, but fail when new violations are added.
-freeze.store.default.allowStoreUpdate=true
-
-# Enable this if a new (frozen) rule has been added in order to create the initial store and record the existing violations.
-#freeze.store.default.allowStoreCreation=true
-
-# Enable this to add allow new violations to be recorded.
-# NOTE: Adding new violations should be avoided when possible. If the rule was correct to flag a new
-# violation, please try to avoid creating the violation. If the violation was created due to a
-# shortcoming of the rule, file a JIRA issue so the rule can be improved.
-#freeze.refreeze=true
-
-freeze.store.default.path=archunit-violations
diff --git a/flink-connectors/flink-connector-rabbitmq/src/test/resources/log4j2-test.properties b/flink-connectors/flink-connector-rabbitmq/src/test/resources/log4j2-test.properties
deleted file mode 100644
index 835c2ec9a3d..00000000000
--- a/flink-connectors/flink-connector-rabbitmq/src/test/resources/log4j2-test.properties
+++ /dev/null
@@ -1,28 +0,0 @@
-################################################################################
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-################################################################################
-
-# Set root logger level to OFF to not flood build logs
-# set manually to INFO for debugging purposes
-rootLogger.level = OFF
-rootLogger.appenderRef.test.ref = TestLogger
-
-appender.testlogger.name = TestLogger
-appender.testlogger.type = CONSOLE
-appender.testlogger.target = SYSTEM_ERR
-appender.testlogger.layout.type = PatternLayout
-appender.testlogger.layout.pattern = %-4r [%t] %-5p %c %x - %m%n
diff --git a/flink-connectors/flink-sql-connector-rabbitmq/pom.xml b/flink-connectors/flink-sql-connector-rabbitmq/pom.xml
deleted file mode 100644
index 85949f4eefa..00000000000
--- a/flink-connectors/flink-sql-connector-rabbitmq/pom.xml
+++ /dev/null
@@ -1,82 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <artifactId>flink-connectors</artifactId>
- <groupId>org.apache.flink</groupId>
- <version>1.17-SNAPSHOT</version>
- </parent>
-
- <artifactId>flink-sql-connector-rabbitmq</artifactId>
- <name>Flink : Connectors : SQL : RabbitMQ</name>
-
- <packaging>jar</packaging>
-
- <properties>
- <japicmp.skip>true</japicmp.skip>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.flink</groupId>
- <artifactId>flink-connector-rabbitmq</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-shade-plugin</artifactId>
- <executions>
- <execution>
- <id>shade-flink</id>
- <phase>package</phase>
- <goals>
- <goal>shade</goal>
- </goals>
- <configuration>
- <artifactSet>
- <includes>
- <include>org.apache.flink:flink-connector-base</include>
- <include>org.apache.flink:flink-connector-rabbitmq</include>
- <include>com.rabbitmq:amqp-client</include>
- </includes>
- </artifactSet>
- <relocations>
- <relocation>
- <pattern>com.rabbitmq</pattern>
- <shadedPattern>org.apache.flink.rabbitmq.shaded.com.rabbitmq</shadedPattern>
- </relocation>
- </relocations>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
-</project>
diff --git a/flink-connectors/flink-sql-connector-rabbitmq/src/main/resources/META-INF/NOTICE b/flink-connectors/flink-sql-connector-rabbitmq/src/main/resources/META-INF/NOTICE
deleted file mode 100644
index b88b7391712..00000000000
--- a/flink-connectors/flink-sql-connector-rabbitmq/src/main/resources/META-INF/NOTICE
+++ /dev/null
@@ -1,9 +0,0 @@
-flink-sql-connector-rabbitmq
-Copyright 2014-2022 The Apache Software Foundation
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
-
-This project bundles the following dependencies under the Apache Software License 2.0 (http://www.apache.org/licenses/LICENSE-2.0.txt)
-
-- com.rabbitmq:amqp-client:5.13.1
diff --git a/flink-connectors/pom.xml b/flink-connectors/pom.xml
index ab3cdd68c80..57ca985d3cc 100644
--- a/flink-connectors/pom.xml
+++ b/flink-connectors/pom.xml
@@ -40,7 +40,6 @@ under the License.
<module>flink-connector-hbase-1.4</module>
<module>flink-connector-hbase-2.2</module>
<module>flink-connector-hive</module>
- <module>flink-connector-rabbitmq</module>
<module>flink-connector-kafka</module>
<module>flink-connector-gcp-pubsub</module>
<module>flink-connector-aws-base</module>
@@ -89,7 +88,6 @@ under the License.
<module>flink-sql-connector-hive-2.3.9</module>
<module>flink-sql-connector-hive-3.1.3</module>
<module>flink-sql-connector-kafka</module>
- <module>flink-sql-connector-rabbitmq</module>
</modules>
</profile>
</profiles>
diff --git a/flink-python/pom.xml b/flink-python/pom.xml
index a88016af12d..d0e3a691daa 100644
--- a/flink-python/pom.xml
+++ b/flink-python/pom.xml
@@ -298,7 +298,7 @@ under the License.
<!-- Indirectly accessed in pyflink_gateway_server -->
<groupId>org.apache.flink</groupId>
<artifactId>flink-sql-connector-rabbitmq</artifactId>
- <version>${project.version}</version>
+ <version>3.0.0-1.16</version>
<scope>test</scope>
</dependency>
diff --git a/flink-test-utils-parent/flink-test-utils-junit/src/main/java/org/apache/flink/util/DockerImageVersions.java b/flink-test-utils-parent/flink-test-utils-junit/src/main/java/org/apache/flink/util/DockerImageVersions.java
index 7a403a7fe44..88f21575203 100644
--- a/flink-test-utils-parent/flink-test-utils-junit/src/main/java/org/apache/flink/util/DockerImageVersions.java
+++ b/flink-test-utils-parent/flink-test-utils-junit/src/main/java/org/apache/flink/util/DockerImageVersions.java
@@ -32,8 +32,6 @@ public class DockerImageVersions {
public static final String SCHEMA_REGISTRY = "confluentinc/cp-schema-registry:7.2.2";
- public static final String RABBITMQ = "rabbitmq:3.9.8-management-alpine";
-
public static final String KINESALITE = "instructure/kinesalite:latest";
public static final String LOCALSTACK = "localstack/localstack:0.13.3";
diff --git a/tools/ci/stage.sh b/tools/ci/stage.sh
index e3bb51c88b8..9592bbc8ad4 100755
--- a/tools/ci/stage.sh
+++ b/tools/ci/stage.sh
@@ -140,8 +140,6 @@ flink-connectors/flink-connector-base,\
flink-connectors/flink-connector-kafka,\
flink-connectors/flink-sql-connector-kafka,\
flink-connectors/flink-connector-gcp-pubsub,\
-flink-connectors/flink-connector-rabbitmq,\
-flink-connectors/flink-sql-connector-rabbitmq,\
flink-connectors/flink-connector-aws-base,\
"