给定服务器配置:
<camel:camelContext id="reporting_shoppingCard"
xmlns="http://camel.apache.org/schema/spring">
<camel:contextScan />
<camel:export uri="activemq:queue:bshop.reports.shoppingCard"
serviceRef="reportingService"
serviceInterface="bshop.reporting.shoppingcard.ReportingService" />
</camel:camelContext>
...客户端配置:
<camelContext id="reporting_shoppingCard" xmlns="http://camel.apache.org/schema/spring">
<camel:contextScan />
<camel:proxy id="reportingServiceProxy"
serviceInterface="bshop.reporting.ReportingService"
serviceUrl="activemq:queue:bshop.reports.shoppingCard" />
</camelContext>
...具有一种方法的接口:
package bshop.reporting;
public interface ReportingService {
public byte[] createShoppingCardReport(Long aShoppingCardId);
}
..和服务的实现:
package bshop.reporting.shoppingcard;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import bshop.reporting.ReportingService;
@Service("reportingService")
public class ReportingServiceImpl implements ReportingService {
private static final Logger logger = LoggerFactory.getLogger(ReportingServiceImpl.class);
/**
* @see bshop.reporting.ReportingService#createShoppingCardReport(java.lang.Long)
*/
@Override
public byte[] createShoppingCardReport(Long aShoppingCardId) {
logger.info("Creating shoppingCard report for shoppingCard ID {}", aShoppingCardId);
return new byte[20];
}
}
调用代理时..
getReportingServiceProxy().createShoppingCardReport(shoppingCardId);
BeanIvocation 将被路由到ActiveMQ.DLQ队列而不是bshop.reports.shoppingCard和 Service impl。不会被调用。
那么,我做错了什么?
骆驼:2.11.1 ActiveMQ:5.5.1-fuse-03-06
我的客户 jms 代理配置:
<!-- ######### JMS Broker configuration -->
<bean id="jmsConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="${brokerURL}"></property>
</bean>
<bean id="pooledConnectionFactory" class="org.apache.activemq.pool.PooledConnectionFactory">
<property name="maxConnections" value="8" />
<property name="maximumActive" value="500" />
<property name="connectionFactory" ref="jmsConnectionFactory" />
</bean>
<bean id="jmsConfig" class="org.apache.camel.component.jms.JmsConfiguration">
<property name="connectionFactory" ref="pooledConnectionFactory" />
<property name="transacted" value="false" />
<property name="concurrentConsumers" value="10" />
</bean>
<bean id="jms" class="org.apache.activemq.camel.component.ActiveMQComponent">
<property name="configuration" ref="jmsConfig" />
</bean>
<!-- ######### -->
我的服务器 jms 代理配置:
<bean id="jmsConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="${brokerURL}" />
</bean>
<bean id="pooledConnectionFactory" class="org.apache.activemq.pool.PooledConnectionFactory">
<property name="maxConnections" value="8" />
<property name="maximumActive" value="500" />
<property name="connectionFactory" ref="jmsConnectionFactory" />
</bean>
<bean id="jmsConfig" class="org.apache.camel.component.jms.JmsConfiguration">
<property name="connectionFactory" ref="pooledConnectionFactory" />
<property name="transacted" value="false" />
<property name="concurrentConsumers" value="10" />
</bean>
<bean id="jms" class="org.apache.activemq.camel.component.ActiveMQComponent">
<property name="configuration" ref="jmsConfig" />
</bean>
ActiveMQ 日志显示:
2014-08-22 16:07:27,067 | DEBUG | localhost adding destination: queue://bshop.reports.shoppingCard | org.apache.activemq.broker.region.AbstractRegion | ActiveMQ Transport: tcp:///172.23.26.29:58206
2014-08-22 16:07:27,071 | DEBUG | bshop.reports.shoppingCard toPageIn: 0, Inflight: 0, pagedInMessages.size 0, enqueueCount: 0, dequeueCount: 0 | org.apache.activemq.broker.region.Queue | ActiveMQ Transport: tcp:///172.23.26.29:58206
2014-08-22 16:07:27,071 | DEBUG | queue://bshop.reports.shoppingCard add sub: QueueSubscription: consumer=ID:edc-derasu220-37838-1408540697354-0:158:1:1, destinations=0, dispatched=0, delivered=0, pending=0, dequeues: 0, dispatched: 0, inflight: 0 | org.apache.activemq.broker.region.Queue | ActiveMQ Transport: tcp:///172.23.26.29:58206
2014-08-22 16:07:27,073 | DEBUG | localhost adding destination: topic://ActiveMQ.Advisory.Producer.Queue.bshop.reports.shoppingCard | org.apache.activemq.broker.region.AbstractRegion | ActiveMQ Transport: tcp:///172.23.26.29:58206
2014-08-22 16:07:27,122 | DEBUG | Message expired ActiveMQObjectMessage {commandId = 5, responseRequired = true, messageId = ID:M3-55082-1408711759949-0:141:1:1:1, originalDestination = null, originalTransactionId = null, producerId = ID:M3-55082-1408711759949-0:141:1:1, destination = queue://bshop.reports.shoppingCard, transactionId = null, expiration = 1408716051506, timestamp = 1408716031506, arrival = 0, brokerInTime = 1408716447076, brokerOutTime = 0, correlationId = Camel-ID-M3-54934-1408711481855-0-7, replyTo = temp-queue://ID:M3-55082-1408711759949-0:139:1, persistent = true, type = null, priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null, compressed = false, userID = null, content = org.apache.activemq.util.ByteSequence@a30589, marshalledProperties = null, dataStructure = null, redeliveryCounter = 0, size = 0, properties = null, readOnlyProperties = false, readOnlyBody = false, droppable = false} | org.apache.activemq.broker.region.RegionBroker | ActiveMQ Transport: tcp:///172.23.26.29:58206
2014-08-22 16:07:27,122 | DEBUG | localhost adding destination: queue://ActiveMQ.DLQ | org.apache.activemq.broker.region.AbstractRegion | ActiveMQ Transport: tcp:///172.23.26.29:58206
2014-08-22 16:07:27,125 | DEBUG | ActiveMQ.DLQ toPageIn: 0, Inflight: 0, pagedInMessages.size 0, enqueueCount: 0, dequeueCount: 0 | org.apache.activemq.broker.region.Queue | ActiveMQ Transport: tcp:///172.23.26.29:58206
2014-08-22 16:07:27,128 | DEBUG | localhost Message ID:M3-55082-1408711759949-0:141:1:1:1 sent to queue://ActiveMQ.DLQ | org.apache.activemq.broker.region.Queue | ActiveMQ Transport: tcp:///172.23.26.29:58206
2014-08-22 16:07:27,128 | DEBUG | ActiveMQ.DLQ toPageIn: 1, Inflight: 0, pagedInMessages.size 0, enqueueCount: 1, dequeueCount: 0 | org.apache.activemq.broker.region.Queue | Queue:ActiveMQ.DLQ
2014-08-22 16:07:27,141 | DEBUG | localhost adding destination: topic://ActiveMQ.Advisory.MessageDLQd.Queue.bshop.reports.shoppingCard | org.apache.activemq.broker.region.AbstractRegion | ActiveMQ Transport: tcp:///172.23.26.29:58206
2014-08-22 16:07:27,142 | DEBUG | localhost adding destination: topic://ActiveMQ.Advisory.Expired.Queue.bshop.reports.shoppingCard | org.apache.activemq.broker.region.AbstractRegion | ActiveMQ Transport: tcp:///172.23.26.29:58206
2014-08-22 16:07:27,145 | DEBUG | localhost removing consumer: ID:M3-55082-1408711759949-0:141:-1:1 for destination: topic://ActiveMQ.Advisory.TempQueue,topic://ActiveMQ.Advisory.TempTopic | org.apache.activemq.broker.region.AbstractRegion | ActiveMQ Transport: tcp:///172.23.26.29:58206