我有以下配置
<bean id="mail.service.messaging.messageListenerContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer"
p:autoStartup="true" p:sessionTransacted="true"
p:connectionFactory-ref="mail.messaging.nonxa.jmsConnectionFactory"
p:maxConcurrentConsumers="${jms.mail.max.concurrent.consumers}"
p:destination-ref="mail.service.messaging.inboundJmsQueue"
p:concurrentConsumers="${jms.mail.concurrent.consumers}" p:receiveTimeout="${jms.mail.receive.timeout}"
p:recoveryInterval="${jms.mail.recovery.interval}" p:taskExecutor-ref="mail.service.messaging.jmsTaskExecutor"
p:cacheLevelName="${jms.listener.cache.level:CACHE_CONSUMER}"/>
<int-jms:message-driven-channel-adapter id="mail.service.messaging.inboundJmsChannelAdapter"
container="mail.service.messaging.messageListenerContainer"
message-converter="mail.messaging.marshallingMessageConverter"
error-channel="mail.service.messaging.errorHandler"
channel="mail.service.messaging.inboundMessageChannel" />
<int:service-activator input-channel="mail.service.messaging.inboundMessageChannel"
ref="mail.service.messaging.mailMessagingService"
method="processEmail"/>
<int:service-activator input-channel="mail.service.messaging.errorHandler"
ref="mail.service.messaging.mailMessagingService"
method="errorHandler"/>
我想测试processEmail
失败时,然后errorChannel
正确地带有进程异常。
我尝试模拟DefaultMessageListenerContainer
,但尚不清楚如何向该容器发送消息。我也尝试创建JmsTemplate
实例并将消息发送到队列,但这不会触发processEmail
方法(通过Mockito.verify
检查)