程序问答   发布时间:2022-06-02  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了关闭 JMS 侦听器容器等待关闭消息侦听器调用程序大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

如何解决关闭 JMS 侦听器容器等待关闭消息侦听器调用程序?

开发过程中遇到关闭 JMS 侦听器容器等待关闭消息侦听器调用程序的问题如何解决?下面主要结合日常开发的经验,给出你关于关闭 JMS 侦听器容器等待关闭消息侦听器调用程序的解决方法建议,希望对你解决关闭 JMS 侦听器容器等待关闭消息侦听器调用程序有所启发或帮助;

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

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(),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"
        @R_944_10613@est-chAnnel="senExtractProcessing@R_944_10613@estChAnnel"
        @R_944_10613@est-desTination-name="senExtract@R_944_10613@estQueue"
        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" />

代码片段:@H_301_14@

 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

解决方法

您有此配置 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 {

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

大佬总结

以上是大佬教程为你收集整理的关闭 JMS 侦听器容器等待关闭消息侦听器调用程序全部内容,希望文章能够帮你解决关闭 JMS 侦听器容器等待关闭消息侦听器调用程序所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。