截至目前,我在java中有以下类:
public class CamelActivemqExampleUsingSpring {
public static final void main(String[] args) throws Exception {
ApplicationContext appContext = new ClassPathXmlApplicationContext("applicationContext.xml");
CamelContext camelContext = SpringCamelContext.springCamelContext(appContext, false);
try {
camelContext.start();
Thread.sleep(2000);
} finally {
camelContext.stop();
}
}
}
以及applicationContent的以下xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
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.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
">
<bean id="jmsConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="http://urlwheremyactivemqishosted" />
<property name="userName" value="un" />
<property name="password" value="pw" />
</bean>
<bean id="pooledConnectionFactory" class="org.apache.activemq.pool.PooledConnectionFactory"
init-method="start" destroy-method="stop">
<property name="maxConnections" value="8" />
<property name="connectionFactory" ref="jmsConnectionFactory" />
</bean>
<bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
<property name="connectionFactory" ref="pooledConnectionFactory" />
</bean>
<camelContext xmlns="http://camel.apache.org/schema/spring">
<route>
<from uri="file://src/test/resources/TestMessages" />
<to uri="activemq:queue:test" />
</route>
</camelContext>
</beans>
使用正确的凭据填写用户名和密码,brokerURL也是如此。但是,每当我尝试运行java代码时,都会说
无法执行GET:http:urlmyactivemqisat,因为回复是:未经授权
所以,我非常确定我正在尝试正确传递凭据,但我无法弄清楚如何做到这一点。我已经用Google搜索过,但很多结果并不相关。似乎大多数使用camel和activemq的人都有本地托管的activemq测试实例,并且正在使用vm或tcp。那或他们没有将JMS发送到队列但是正在侦听队列以消耗jms。