2016-04-30 49 views
0

我正在使用activemq和camel来消费队列中的消息并将它们发送到http服务器。我使用下面的骆驼配置: -Activemq不以HTTP启动uri

<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring"> 
    <route> 
     <from uri="activemq:queue:Consumer.A.VirtualTopic.Orders"/> 
     <to uri="http://localhost:8080/" /> 
     <!-- <to uri="file:///Users/vinod/activemq.txt"/> --> 
     <!-- <to uri="activemq:queue:sssss"/> --> 
    </route> 
</camelContext> 

<bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent" > 
    <property name="connectionFactory"> 
     <bean class="org.apache.activemq.ActiveMQConnectionFactory"> 
     <property name="brokerURL" value="vm://localhost?create=false"/> 
     </bean> 
    </property> 
</bean> 

在第一方块创建该消费者从消息队列activemq:queue:Consumer.A.VirtualTopic.Orders并将它们发送到服务器,在​​的路线。另外两个注释的目的地工作正常,但是当我启动activemq并使用上述配置通过http发送消息时,服务器停止而不会引发任何错误消息。 Activemq日志为https://gist.github.com/kumar003vinod/1e5944cb246edb74c47fef7a0b433387

请提供一些见解。

回答

1

确保在ActiveMQ lib/camel目录中包含camel-httpcamel-http-common JAR。您可能还需要在该目录中包含camel-http的传递依赖项,以便ActiveMQ在其类路径中包含所有需要的JAR。

这将是commons-httpclientcommons-codec JAR,但我认为它们已包含在lib/optional中。

+0

我已经将这些依赖关系包含在pom.xml的根目录中(请参阅diff here https://gist.github.com/kumar003vinod/5d50e9c403856ce93dec192bacfab469)。我正在从源头编译项目。如果我使用'mvn -Dtest = false -DfailIfNoTests = false install'命令来添加这些项目来创建项目,则这些jar文件不会在'lib/camel'中创建。查看完整的pom文件https://gist.github.com/kumar003vinod/f643dbfe4d6b373bfde395c607e5e945。任何提示? –

+0

我能够以某种方式通过在多pom文件中添加依赖关系来编译它,但是我没有得到'忽略转换器类型:org.apache.camel.component.http.RequestEntityConverter作为依赖类无法找到:java.lang。 NoClassDefFoundError:org/apache/commons/httpclient/methods/RequestEntity | org.apache.camel.impl.converter.AnnotationTypeConverterLoader |主要是 当activemq启动时,java.lang.NoClassDefFoundError:org/apache/commons/httpclient/methods/RequestEntity'错误。查看https://gist.github.com/kumar003vinod/ce182c4009de1998f0927a17a5e663bd了解更多信息。 –

+0

上述问题是由于我没有安装'commons-httpclient'而导致的。安装后它工作正常。 –