nifi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (NIFI-865) Add processors to Get and Put to/from AMQP-based messaging systems
Date Mon, 01 Feb 2016 16:50:40 GMT

    [ https://issues.apache.org/jira/browse/NIFI-865?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15126540#comment-15126540
] 

ASF GitHub Bot commented on NIFI-865:
-------------------------------------

Github user olegz commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/199#discussion_r51444249
  
    --- Diff: nifi-nar-bundles/nifi-amqp-bundle/nifi-amqp-processors/src/main/java/org/apache/nifi/amqp/processors/AMQPPublisher.java
---
    @@ -0,0 +1,128 @@
    +/*
    + * 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.nifi.amqp.processors;
    +
    +import java.io.IOException;
    +
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import com.rabbitmq.client.AMQP.BasicProperties;
    +import com.rabbitmq.client.Connection;
    +import com.rabbitmq.client.ReturnListener;
    +
    +/**
    + * Generic publisher of messages to AMQP-based messaging system. It is based on
    + * RabbitMQ client API (https://www.rabbitmq.com/api-guide.html)
    + */
    +final class AMQPPublisher extends AMQPWorker {
    +
    +    private final static Logger logger = LoggerFactory.getLogger(AMQPPublisher.class);
    +
    +    private final String exchangeName;
    +
    +    private final String routingKey;
    +
    +    /**
    +     * Creates an instance of this publisher
    +     *
    +     * @param connection
    +     *            instance of AMQP {@link Connection}
    +     * @param exchangeName
    +     *            the name of AMQP exchange to which messages will be published.
    +     *            If not provided 'default' exchange will be used.
    +     * @param routingKey
    +     *            (required) the name of the routingKey to be used by AMQP-based
    +     *            system to route messages to its final destination (queue).
    +     */
    +    AMQPPublisher(Connection connection, String exchangeName, String routingKey) {
    +        super(connection);
    +        this.validateStringProperty("routingKey", routingKey);
    +        this.exchangeName = exchangeName == null ? "" : exchangeName.trim();
    +        if (this.exchangeName.length() == 0) {
    +            logger.info("The 'exchangeName' is not specified. Messages will be sent to
default exchange");
    +        }
    +
    +        this.routingKey = routingKey;
    +        this.channel.addReturnListener(new UndeliverableMessageLogger());
    +        logger.info("Successfully connected AMQPPublisher to " + connection.toString()
+ " and '" + this.exchangeName
    +                + "' exchange with '" + routingKey + "' as a routing key.");
    +    }
    +
    +    /**
    +     * Publishes message without any AMQP properties (see
    +     * {@link BasicProperties}) to a pre-defined AMQP Exchange.
    +     *
    +     * @param bytes
    +     *            bytes representing a message.
    +     */
    +    void publish(byte[] bytes) {
    +        this.publish(bytes, null);
    +    }
    +
    +    /**
    +     * Publishes message with provided AMQP properties (see
    +     * {@link BasicProperties}) to a pre-defined AMQP Exchange.
    +     *
    +     * @param bytes
    +     *            bytes representing a message.
    +     * @param properties
    +     *            instance of {@link BasicProperties}
    +     */
    +    void publish(byte[] bytes, BasicProperties properties) {
    +        if (this.channel.isOpen()) {
    +            try {
    +                this.channel.basicPublish(this.exchangeName, this.routingKey, true, properties,
bytes);
    +            } catch (Exception e) {
    +                throw new IllegalStateException("Failed to publish to '" +
    +                        this.exchangeName + "' with '" + this.routingKey + "'.", e);
    +            }
    +        } else {
    +            throw new IllegalStateException("This instance of AMQPPublisher is invalid
since "
    +                    + "its publishigChannel is closed");
    --- End diff --
    
    ClosedChannelException is checked exception, needed a runtime exception


> Add processors to Get and Put to/from AMQP-based messaging systems
> ------------------------------------------------------------------
>
>                 Key: NIFI-865
>                 URL: https://issues.apache.org/jira/browse/NIFI-865
>             Project: Apache NiFi
>          Issue Type: Wish
>          Components: Extensions
>            Reporter: Joseph Witt
>            Assignee: Oleg Zhurakousky
>              Labels: beginner
>             Fix For: 0.5.0
>
>
> David Smith in the mailing list has already begun work on this.  The link to his current
set of code in Github is here:  https://github.com/helicopterman22/nifi_amqp_processors
> He is seeking help with licensing/unit testing/etc.. so that it can end up in a build.
> We have word from another user now that they too are interested in this.  They specifically
are using RabbitMQ but we should be able to implement (ideally) a pure AMQP protocol friendly
version and be good to go.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message