Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 1AF5A200B63 for ; Mon, 15 Aug 2016 23:32:41 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 1988D160A8A; Mon, 15 Aug 2016 21:32:41 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 5FD8D160AB8 for ; Mon, 15 Aug 2016 23:32:40 +0200 (CEST) Received: (qmail 10146 invoked by uid 500); 15 Aug 2016 21:32:39 -0000 Mailing-List: contact issues-help@flink.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@flink.apache.org Delivered-To: mailing list issues@flink.apache.org Received: (qmail 10137 invoked by uid 99); 15 Aug 2016 21:32:39 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 15 Aug 2016 21:32:39 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 2CA6EC189D for ; Mon, 15 Aug 2016 21:32:39 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -4.539 X-Spam-Level: X-Spam-Status: No, score=-4.539 tagged_above=-999 required=6.31 tests=[KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-0.519] autolearn=disabled Received: from mx2-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id la5_msY1tOtP for ; Mon, 15 Aug 2016 21:32:38 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx2-lw-eu.apache.org (ASF Mail Server at mx2-lw-eu.apache.org) with SMTP id 4B6D35F47A for ; Mon, 15 Aug 2016 21:32:37 +0000 (UTC) Received: (qmail 9836 invoked by uid 99); 15 Aug 2016 21:32:36 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 15 Aug 2016 21:32:36 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 0FA90E0100; Mon, 15 Aug 2016 21:32:36 +0000 (UTC) From: mushketyk To: issues@flink.incubator.apache.org Reply-To: issues@flink.incubator.apache.org References: In-Reply-To: Subject: [GitHub] flink pull request #2314: [FLINK-3298] Implement ActiveMQ streaming connecto... Content-Type: text/plain Message-Id: <20160815213236.0FA90E0100@git1-us-west.apache.org> Date: Mon, 15 Aug 2016 21:32:36 +0000 (UTC) archived-at: Mon, 15 Aug 2016 21:32:41 -0000 Github user mushketyk commented on a diff in the pull request: https://github.com/apache/flink/pull/2314#discussion_r74839402 --- Diff: flink-streaming-connectors/flink-connector-activemq/src/main/java/org/apache/flink/streaming/connectors/activemq/AMQSource.java --- @@ -0,0 +1,258 @@ +/* + * 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.activemq; + +import org.apache.activemq.ActiveMQConnectionFactory; +import org.apache.activemq.ActiveMQSession; +import org.apache.flink.api.common.functions.RuntimeContext; +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.operators.StreamingRuntimeContext; +import org.apache.flink.streaming.util.serialization.DeserializationSchema; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.jms.BytesMessage; +import javax.jms.Connection; +import javax.jms.Destination; +import javax.jms.ExceptionListener; +import javax.jms.JMSException; +import javax.jms.Message; +import javax.jms.MessageConsumer; +import javax.jms.Session; +import java.io.Serializable; +import java.util.HashMap; +import java.util.List; + +/** + * Source for reading messages from an ActiveMQ queue. + *

+ * To create an instance of AMQSink class one should initialize and configure an + * instance of a connection factory that will be used to create a connection. + * This source is waiting for incoming messages from ActiveMQ and converts them from + * an array of bytes into an instance of the output type. If an incoming + * message is not a message with an array of bytes, this message is ignored + * and warning message is logged. + * + * @param type of output messages + */ +public class AMQSource extends MessageAcknowledgingSourceBase + implements ResultTypeQueryable { + + private static final Logger LOG = LoggerFactory.getLogger(AMQSource.class); + + private final ActiveMQConnectionFactory connectionFactory; + private final String queueName; + private final DeserializationSchema deserializationSchema; + private boolean logFailuresOnly = false; + private RunningChecker runningChecker; --- End diff -- In some unit tests that I wrote need to execute "run" method exactly once. I think that it is simpler to achieve it using a separate interface that controls running of source. To avoid confusion I'll add a comment describing this, but if you have a better idea of how to achieve this, don't hesitate to suggest it. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastructure@apache.org or file a JIRA ticket with INFRA. ---