简体   繁体   English

使用IBM MQ正确停止Java应用程序

[英]Correct stop java application with IBM mq

I use java application with IBM mq websphere. 我将Java应用程序与IBM mq websphere一起使用。 When i am killing the application in mq is remained some information about channels. 当我杀死mq中的应用程序时,仍然保留一些有关渠道的信息。 I don't know way to correct stopping of application. 我不知道纠正应用程序停止的方法。

Simply put, i need kill application with mq channels. 简单地说,我需要使用mq通道终止应用程序。 Because when i restart application, it can't start and throw exception: 因为当我重新启动应用程序时,它无法启动并引发异常:

ERROR Failed to initialize Queue Channel.
com.ibm.msg.client.jms.DetailedJMSException: JMSWMQ0018: Failed to connect to queue manager 'TL4UZ8T' with connection mode '1' and host name 'mq4u-TL4UZ8T.lb.com(64424)'.

Thanks for helping! 感谢您的帮助!

Boy! 男孩! why you have to kill application? 为什么您必须终止应用程序? Do you mean abnormal termination of application? 您的意思是申请异常终止吗?

The application must call Disconnect() to inform the queue manager to do clean up it's end. 应用程序必须调用Disconnect()来通知队列管理器进行清理。 It's a best practice, please read other best practices here . 这是最佳做法,请在此处阅读其他最佳做法。 If Disconnect is not called, queue manager does not immediately clean up resources allocated for a client connection. 如果未调用Disconnect,则队列管理器不会立即清除为客户端连接分配的资源。

So check your application code and ensure it has code to close any queues/topics/connections opened. 因此,请检查您的应用程序代码,并确保它具有关闭打开的所有队列/主题/连接的代码。

To expand on Shashi's excellent answer, there are lots of things you can consider here. 为了扩展Shashi的出色答案,您可以在这里考虑很多事情。 For example: 例如:

  • Stop the channel before killing the application. 终止应用程序之前,请停止该通道。 Even if you have dozens of running channel instances, you can stop the ones associated with that particular IP address. 即使您有数十个正在运行的通道实例,也可以停止与该特定IP地址关联的实例。 Use MODE(INACTIVE) so the app can reconnect. 使用MODE(INACTIVE)以便应用程序可以重新连接。
  • Stop the channel after killing the application. 终止应用程序停止频道。 As before, you can stop the ones associated with that particular IP address. 和以前一样,您可以停止与该特定IP地址关联的地址。
  • Instrument the application to accept shutdown commands on a queue, then shut itself down gracefully. 检测应用程序以接受队列上的关闭命令,然后正常关闭自身。
  • Disable the application's queue(s). 禁用应用程序的队列。 When an application isn't instrumented well, chances are it perceives disabling its queues as fatal and will shut itself down when you do so. 当一个应用程序的检测不正确时,它很可能会认为禁用其队列是致命的,并且在这样做时会自行关闭。
  • Tune the channel's HBINT , SHARECONV , KEEPALIVE and other parameters so that the channel has lots of spare instances and that the orphaned instances shut down in a timely fashion. 调整通道的HBINTSHARECONVKEEPALIVE和其他参数,以便该通道具有许多备用实例,并且孤立实例会及时关闭。 This may include bumping up the listener backlog as well. 这可能还包括增加侦听器的积压。
  • Instrument the application to accept SIGHUP or other system signal to shut itself down gracefully. 调试应用程序以接受SIGHUP或其他系统信号以正常关闭自身。

As Shashi notes, the best option is that the application communicates it's desire to shut down to the QMgr and the two cooperate to accomplish that task. 正如Shashi所指出的,最好的选择是应用程序传达它希望关闭QMgr的信息,并且两者共同完成该任务。 The app is built to cooperate with MQ on every other task, so why not this one? 该应用程序旨在与MQ合作完成其他所有任务,那么为什么不这样做呢?

However, if that isn't an option use the instrumentation built into MQ to accomplish as close as possible to the desired result. 但是,如果不是这样,则可以使用MQ内置的工具来尽可能地接近期望的结果。

Failing that, use the instrumentation built into the OS but tune MQ to minimize the impact. 失败的话,请使用操作系统内置的工具,但要调整MQ以最大程度地减少影响。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM