如何集成jms主题来馈送Storm喷口



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

我已经浏览了ptgoetz的Storm JMS示例,并制作了一个直接将主题数据提供给喷口的解决方案。

需要在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>

,然后我们可以像下面这样在会话中使用Jms确认模式创建JmsSpout。AUTO_ACKNOWLEDGE

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);

最新更新