【问题标题】:How to integrate jms topic to feed Storm spout如何集成 jms 主题以提供 Storm spout
【发布时间】:2015-12-28 00:06:29
【问题描述】:

我有一个 ActiveMQ 主题提供程序。我需要将从该主题收到的数据提供给 Storm 主题。有什么方法可以直接做到这一点,或者我应该创建中间队列并将主题数据输入队列,然后将数据拉入 spout。哪个是最好的选择?

【问题讨论】:

    标签: java stream activemq apache-storm jms-topic


    【解决方案1】:

    我已经查看了 ptgoetz 的 Storm JMS Examples 并提出了一个解决方案,将主题数据直接提供给一个 spout。

    需要在jms-activemq.xml中指定主题

    <?xml version="1.0" encoding="UTF-8"?>
    <beans 
      xmlns="http://www.springframework.org/schema/beans" 
      xmlns:amq="http://activemq.apache.org/schema/core"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
      http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
    
        <amq:topic id="topic" physicalName="myTopic" />
    
        <amq:connectionFactory id="jmsConnectionFactory"
            brokerURL="tcp://localhost:61616" />
    </beans>
    

    然后我们可以使用 session.AUTO_ACKNOWLEDGE 中的 Jms Acknowledge Mode 来创建如下所示的 JmsSpout

    JmsProvider jmsTopicProvider = new SpringJmsProvider("jms-activemq.xml", "jmsConnectionFactory", "topic");
    
    JmsTupleProducer producer = new JsonTupleProducer();
    
    JmsSpout topicSpout = new JmsSpout();
    topicSpout.setJmsProvider(jmsTopicProvider);
    topicSpout.setJmsTupleProducer(producer);
    topicSpout.setJmsAcknowledgeMode(Session.AUTO_ACKNOWLEDGE);
    topicSpout.setDistributed(false);
    

    【讨论】:

      猜你喜欢
      • 2018-09-19
      • 1970-01-01
      • 2013-03-24
      • 2013-06-24
      • 2018-11-03
      • 2019-03-14
      • 1970-01-01
      • 1970-01-01
      • 2021-01-28
      相关资源
      最近更新 更多