-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FLINK-20628] RabbitMQ Connector using FLIP-27 Source API #1
base: main
Are you sure you want to change the base?
Conversation
This is a copy from the original PR (apache/flink#15140) against the Flink repository. |
@MartijnVisser We are not exactly sure what has to be part of the root-pom. |
@pscls I think you've done a good job already with the root-pom; it looks like the one we currently have for Elasticsearch. I've just approved the run, so we can also see how the build behaves. When I tried it locally, it complained about https://github.com/pscls/flink-connector-rabbitmq/blob/new-api-connector/flink-connector-rabbitmq/src/main/java/org/apache/flink/connector/rabbitmq/sink/RabbitMQSink.java#L124 having a whitespace, but now the tests are running for me. I'll work on finding someone who can help with the review for this. |
@pscls Can you have a look at the failing build? It's a checkstyle error. |
@MartijnVisser @pscls I noticed that the GitBox of flink-connector-rabbitmq sent emails to the [email protected]. Is it expected? |
@wanglijie95 No. Most likely this is caused because the PR was created/is not yet using the ASF config as defined in https://github.com/apache/flink-connector-rabbitmq/blob/main/.asf.yaml |
@pscls The CI fails due to spotless; can you fix that? (By running |
@MartijnVisser I've nothing to commit when running |
@pscls Weird. Could you push once more, since the logs are no longer available? |
RabbitMQ Connector using the new Source API https://issues.apache.org/jira/browse/FLINK-20628 Co-authored-by: Yannik Schroeder <[email protected]> Co-authored-by: Jan Westphal <[email protected]>
RabbitMQ Connector using the new Sink API https://issues.apache.org/jira/browse/FLINK-21373 Co-authored-by: Yannik Schroeder <[email protected]> Co-authored-by: Jan Westphal <[email protected]>
c739b58
to
77cd700
Compare
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"). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This belongs into a NOTICE, both contained in the source release and jars.
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"). | |
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 is subject to conditions declared in either the | |
Mozilla Public License 1.1 ("MPL"), the GNU General Public License version 2 ("GPL") | |
OR the Apache License version 2 ("ASL"). |
Additionally this needs clarification that users can choose which license they use for the derivative work.
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>org.apache.flink</groupId> | ||
<artifactId>flink-connectors</artifactId> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is missing a fair amount of cleanups that were later applied to the ES parent pom.
See apache/flink-connector-elasticsearch#31 and replicate the changes.
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-jar-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>test-jar</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we publishing a test-jar?
|
||
import org.apache.flink.connector.rabbitmq.common.RabbitMQConnectionConfig; | ||
|
||
import org.junit.Test; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good if we could start out with junit5 and not have to go through a migration again.
from a RabbitMQ queue in three different consistency modes: at-most-once, at-least-once, | ||
and exactly-once. | ||
|
||
## Consistency Modes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This all belongs into the documentation, not a readme.
return CompletableFuture.runAsync( | ||
() -> { | ||
while (!collector.hasUnpolledMessages()) { | ||
// supposed to be empty | ||
} | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is problematic for a few reasons.
a) It runs in a non-specified thread pool, which means it runs in the JVMs common pool which may also be in use by other components. Use a dedicated executor.
b) It hot-loops, which both blocks an entire thread from doing anything and blows through CPU cycles. Consider restructuring the collector to return a sort of availability future that is completed once a message was added, or use basic locking to at least prevent hot-looping.
|
||
@Override | ||
public List<RabbitMQSourceSplit> snapshotState(long checkpointId) { | ||
return split != null ? Collections.singletonList(split.copy()) : new ArrayList<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return split != null ? Collections.singletonList(split.copy()) : new ArrayList<>(); | |
return split != null ? Collections.singletonList(split.copy()) : Collections.emptyList(); |
if (split != null) { | ||
return; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems wrong.
*/ | ||
public RabbitMQSourceBuilder<T> setDeserializationSchema( | ||
DeserializationSchema<T> deserializationSchema) { | ||
this.deserializationSchema = deserializationSchema; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing null checks; preferable to do them here to fail as early as possible.
* provides behavior to easily add onto the stream, send message to RabbitMQ and get the messages in | ||
* RabbitMQ. | ||
*/ | ||
public abstract class RabbitMQBaseTest { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't use test bases; they've always ended up creating problems.
Model this as an extension instead.
You can avoid a lot of boilerplate by using the preliminary flink-connector-parent pom as shown here: apache/flink-connector-elasticsearch@6e30d5d |
Hi, @pscls Thank you very much for the contribution. |
@RocMarshal Do you want to take this over? |
Hi, @MartijnVisser Glad to get your attention. |
Any update to report from your end on this @RocMarshal ? |
Hi, @MartijnVisser Still in doing. I'll update in the end of this week. |
What is the purpose of the change
This pull request ports the RabbitMQ connector implementation to the new Connector’s API described in FLIP-27 and FLIP-143. It includes both source and sink with at-most-once, at-least-once, and exactly-once behavior, respectively.
This pull request closes the following issues (separated RabbitMQ connector Source and Sink tickets): FLINK-20628 and FLINK-21373
Brief change log
Verifying this change
This change added tests and can be verified as follows:
All changes are within the flink-connectors/flink-connector-rabbitmq2/ module.
Added Integration Tests can be find under org.apache.flink.connector.rabbitmq2.source and org.apache.flink.connector.rabbitmq2.sink package in the test respective directories.
Does this pull request potentially affect one of the following parts:
@Public(Evolving)
: (no)Documentation
Co-authored-by: Yannik Schroeder [email protected]
Co-authored-by: Jan Westphal [email protected]