我有一个ActiveMQ主题提供者。我需要将从该主题收到的数据提供给Storm主题。有没有办法直接这样做,或者我应该创建中间队列并将主题数据提供到队列中,然后将数据拉入喷口。哪个是最佳选择?
答案 0 :(得分:0)
我已经完成了ptgoetz的Storm JMS Examples并提出了一个解决方案,可以直接将主题数据提供给鲸鱼喷水。
需要在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 Acknowledge模式创建类似于下面的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);