服务激活器或监听器容器

service-activator or listener-container

我正在使用 Spring AMQP 和 Spring 集成。我目前正在使用集成的服务激活器作为我的处理程序。我也试图让 amqp 侦听器工作,但我从未收到消息。使用服务激活器是公认的做法还是我应该使用监听器?

<!-- Receive Inbound messages and process them -->
<int-amqp:inbound-channel-adapter channel="sda.text.analytics.process.channel" queue-names="${sda.text.analytics.process.queue}"
    connection-factory="sda.text.analytics.connectionFactory" prefetch-count="${sda.mule.prefetchCount}"
    concurrent-consumers="${uima.process.threads}" task-executor="analyticsExecutor" receive-timeout="5000"/>

<int:json-to-object-transformer input-channel="sda.text.analytics.process.channel" type="com.issinc.sda.ingest.impl.IngestBean"/>

<bean id="analyticsExecutor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
    <property name="corePoolSize" value="${uima.process.threads}" />
    <property name="maxPoolSize" value="${uima.process.threads}" />
    <property name="queueCapacity" value="${sda.mule.prefetchCount}" />
</bean>

<!-- Service that listens for an inbound messages, processes the text and sends the processed text back -->
<int:service-activator input-channel="sda.text.analytics.process.channel" output-channel="sda.text.analytics.response.channel"
   ref="asyncExtractionService" method="processMessage" >
</int:service-activator>
<!--<rabbit:listener-container connection-factory="sda.connectionFactory" message-converter="jsonMessageConverter">
    <rabbit:listener ref="asyncExtractionService" method="processMessage" queue-names="${sda.process.queue}" />
</rabbit:listener-container>-->

你根本不是 "using" 服务激活者;您正在调用与服务激活器相同的 bean/method。

考虑使用 AMQP 入站通道适配器通过 sda.process.channel 向服务激活器发送消息。