【问题标题】:Shutting down JMS listener container waiting for shutdown of message listener invokers关闭 JMS 侦听器容器,等待关闭消息侦听器调用程序
【发布时间】:2021-08-02 14:09:02
【问题描述】:

在 JMS 侦听器容器上调用关闭后,它正在等待消息侦听器调用程序关闭。 我们在作业完成后在 Job 事件侦听器中调用此关闭,并且请求队列中没有要消耗的消息,因此不确定为什么这些消息侦听器没有关闭。以下是服务器关闭后调用的日志。

INFO  [org.springframework.batch.core.launch.support.SimpleJobLauncher] (aspAsyncExecutor-1) Job: [FlowJob: [name=SENEXTRACT]] completed with the following parameters: [{​​​​​​​--listId=15195, --letterId=BF2025, --randomId=99a3d764-8cbf-4dbd-81c8-a5442e6e67e5}​​​​​​​] and the following status: [COMPLETED] in 4m20s353ms
DEBUG [org.springframework.integration.channel.DirectChannel] (aspAsyncExecutor-1) preSend on channel 'bean 'controlChannel'', message: GenericMessage [payload=@senExtractInGateway.stop(), headers={​​​​​​​id=6d7cdaaa-21e5-9a2f-e2ab-d83523747837, timestamp=1620803972934}​​​​​​​]
DEBUG [org.springframework.integration.handler.ServiceActivatingHandler] (aspAsyncExecutor-1) ServiceActivator for [org.springframework.integration.handler.ExpressionCommandMessageProcessor@2decec67] (org.springframework.integration.config.ExpressionControlBusFactoryBean#0) received message: GenericMessage [payload=@senExtractInGateway.stop(), headers={​​​​​​​id=6d7cdaaa-21e5-9a2f-e2ab-d83523747837, timestamp=1620803972934}​​​​​​​]
DEBUG [org.springframework.jms.listener.DefaultMessageListenerContainer] (aspAsyncExecutor-1) Shutting down JMS listener container
DEBUG [org.springframework.jms.listener.DefaultMessageListenerContainer] (aspAsyncExecutor-1) Waiting for shutdown of message listener invokers
DEBUG [org.springframework.jms.listener.DefaultMessageListenerContainer] (aspAsyncExecutor-1) Still waiting for shutdown of 30 message listener invokers (iteration 0)

配置如下。

<int-jms:inbound-gateway
        id="senExtractInGateway" connection-factory="connectionFactory"
        correlation-key="JMSCorrelationID"
        request-channel="senExtractProcessingRequestChannel"
        request-destination-name="senExtractRequestQueue"
        reply-channel="senExtractProcessingReplyChannel"
        default-reply-queue-name="senExtractReplyQueue"
        concurrent-consumers="1" max-concurrent-consumers="30"
        max-messages-per-task="1" reply-timeout="1800000"
        receive-timeout="1800000"  auto-startup="false"/>       
   <integration:channel id="controlChannel" />

    <integration:control-bus input-channel="controlChannel" />

代码片段:

 MessageChannel controlChannel = appContext.getBean("controlChannel", MessageChannel.class); 
  controlChannel.send(new GenericMessage<String>("@senExtractInGateway.start()"));
  logger.info("Received before adapter started: ");
  //controlChannel.send(new GenericMessage<String>("@senExtractSrvActivator.start()"));
  JobExecution execution = jobLauncher.run(job, jobParameters);

   controlChannel.send(new GenericMessage<String>("@senExtractInGateway.stop()"));

Server Threads

【问题讨论】:

    标签: spring spring-batch spring-integration spring-jms


    【解决方案1】:

    你有这个配置receive-timeout="1800000"。因此,您的消费者在这 30 分钟内被阻止也就不足为奇了。查看它的 JavaDocs:

    /**
     * Actually receive a message from the given consumer.
     * @param consumer the JMS MessageConsumer to receive with
     * @param timeout the receive timeout (a negative value indicates
     * a no-wait receive; 0 indicates an indefinite wait attempt)
     * @return the JMS Message received, or {@code null} if none
     * @throws JMSException if thrown by JMS API methods
     * @since 4.3
     * @see #RECEIVE_TIMEOUT_NO_WAIT
     * @see #RECEIVE_TIMEOUT_INDEFINITE_WAIT
     */
    @Nullable
    protected Message receiveFromConsumer(MessageConsumer consumer, long timeout) throws JMSException {
    

    只要消费者在目的地等待消息时被阻塞,容器就不能将其状态声明为已停止,因此它会等待这些消费者空闲并释放资源。

    【讨论】:

    • 感谢您快速而有用的回复@Artem。这帮助我们前进。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-20
    • 1970-01-01
    • 1970-01-01
    • 2023-04-01
    • 1970-01-01
    • 2013-12-20
    相关资源
    最近更新 更多