Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FLINK-8468][RabbitMQ] Improve RabbitMQ connector
Remove text from README.md because it is covered by Javadocs. [FLINK-8468][RabbitMQ] Introduce SerializableReturnListener interface. [FLINK-8468][RabbitMQ] Update RMQSinkPublishOptions. Improve Javadocs. Add default implementation for methods computeMandatory and computeImmediate. [FLINK-8468][RabbitMQ] Replace statements with Preconditions.checkState This closes #5410.
- Loading branch information
1 parent
32dea9a
commit a161606
Showing
5 changed files
with
134 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
146 changes: 74 additions & 72 deletions
146
...q/src/main/java/org/apache/flink/streaming/connectors/rabbitmq/RMQSinkPublishOptions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,72 +1,74 @@ | |||
/* | /* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | * Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | * contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | * this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | * 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 not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | * the License. You may obtain a copy of the License at | ||
* | * | ||
* http://www.apache.org/licenses/LICENSE-2.0 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
* | * | ||
* Unless required by applicable law or agreed to in writing, software | * Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | * distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | * See the License for the specific language governing permissions and | ||
* limitations under the License. | * limitations under the License. | ||
*/ | */ | ||
|
|
||
package org.apache.flink.streaming.connectors.rabbitmq; | package org.apache.flink.streaming.connectors.rabbitmq; | ||
|
|
||
import org.apache.flink.annotation.PublicEvolving; | import org.apache.flink.annotation.PublicEvolving; | ||
|
|
||
import com.rabbitmq.client.AMQP.BasicProperties; | import com.rabbitmq.client.AMQP.BasicProperties; | ||
|
|
||
/** | /** | ||
* The message computation provides methods to compute the message routing key and/or the properties. | * 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. | * @param <IN> The type of the data used by the sink. | ||
*/ | */ | ||
@PublicEvolving | @PublicEvolving | ||
public interface RMQSinkPublishOptions<IN> extends java.io.Serializable { | public interface RMQSinkPublishOptions<IN> extends java.io.Serializable { | ||
|
|
||
/** | /** | ||
* Compute the message's routing key from the data. | * Compute the message's routing key from the data. | ||
* @param a The data used by the sink | * @param a The data used by the sink | ||
* @return The routing key of the message | * @return The routing key of the message | ||
* null will raise a NullPointerException | * null will raise a NullPointerException | ||
*/ | */ | ||
String computeRoutingKey(IN a); | String computeRoutingKey(IN a); | ||
|
|
||
/** | /** | ||
* Compute the message's properties from the data. | * Compute the message's properties from the data. | ||
* @param a The data used by the sink | * @param a The data used by the sink | ||
* @return The message's properties (can be null) | * @return The message's properties (can be null) | ||
*/ | */ | ||
BasicProperties computeProperties(IN a); | BasicProperties computeProperties(IN a); | ||
|
|
||
/** | /** | ||
* Compute the exchange from the data. | * Compute the exchange from the data. | ||
* @param a The data used by the sink | * @param a The data used by the sink | ||
* @return The exchange to publish the message to | * @return The exchange to publish the message to | ||
* null will raise a NullPointerException | * null will raise a NullPointerException | ||
*/ | */ | ||
String computeExchange(IN a); | String computeExchange(IN a); | ||
|
|
||
/** | /** | ||
* Compute the mandatory flag used in basic.publish method | * Compute the mandatory flag passed to method {@link com.rabbitmq.client.Channel#basicPublish(String, String, boolean, boolean, BasicProperties, byte[])}. | ||
* See AMQP API help for values. | * A {@link SerializableReturnListener} is mandatory if this flag can be true. | ||
* A ReturnListener is mandatory if this flag can be true (if not it is ignored and forced to false) | * @param a The data used by the sink | ||
* @param a The data used by the sink | * @return The mandatory flag | ||
* @return The mandatory flag | */ | ||
*/ | default boolean computeMandatory(IN a) { | ||
boolean computeMandatory(IN a); | return false; | ||
|
} | ||
/** |
|
||
* Compute the immediate flag | /** | ||
* See AMQP API help for values. | * Compute the immediate flag passed to method {@link com.rabbitmq.client.Channel#basicPublish(String, String, boolean, boolean, BasicProperties, byte[])}. | ||
* A ReturnListener is mandatory if this flag can be true (if not it is ignored and forced to false) | * A {@link SerializableReturnListener} is mandatory if this flag can be true. | ||
* @param a The data used by the sink | * @param a The data used by the sink | ||
* @return The mandatory flag | * @return The mandatory flag | ||
*/ | */ | ||
boolean computeImmediate(IN a); | default boolean computeImmediate(IN a) { | ||
} | return false; | ||
} | |||
} |
29 changes: 29 additions & 0 deletions
29
.../main/java/org/apache/flink/streaming/connectors/rabbitmq/SerializableReturnListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,29 @@ | |||
/* | |||
* 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 { | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters