westphal-jan commented on a change in pull request #15140: URL: https://github.com/apache/flink/pull/15140#discussion_r594335008
########## File path: flink-connectors/flink-connector-rabbitmq2/src/main/java/org/apache/flink/connector/rabbitmq2/source/reader/RabbitMQCollector.java ########## @@ -0,0 +1,95 @@ +/* + * 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.connector.rabbitmq2.source.reader; + +import org.apache.flink.connector.rabbitmq2.source.common.RabbitMQMessageWrapper; +import org.apache.flink.util.Collector; + +import com.rabbitmq.client.AMQP; +import com.rabbitmq.client.Envelope; + +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.LinkedBlockingQueue; + +/** + * The collector for the messages received from rabbitmq. Deserialized receive their identifiers + * through {@link #setMessageIdentifiers(String, long)} before they are collected through {@link + * #collect(Object)}. Messages can be polled in order to be processed by the output. + * + * @param <T> The output type of the source. + * @see RabbitMQMessageWrapper + */ +public class RabbitMQCollector<T> implements Collector<T> { + // Queue that holds the messages. + private final BlockingQueue<RabbitMQMessageWrapper<T>> unpolledMessageQueue; + // Identifiers of the next message that will be collected. + private long deliveryTag; + private String correlationId; + + private RabbitMQCollector(int capacity) { + this.unpolledMessageQueue = new LinkedBlockingQueue<>(capacity); + } + + public RabbitMQCollector() { + this(Integer.MAX_VALUE); Review comment: We have a streaming source which is unbounded so it made only sense for use to have a queue with infinite size. Or do you mean we should write a comment? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org