gpt4 book ai didi

java - 如果服务器突然宕机,Java代码会中途终止吗

转载 作者:行者123 更新时间:2023-12-02 01:16:21 24 4
gpt4 key购买 nike

假设我有一个包含 1000 行代码的 java 函数,并将其部署在 weblogic 上。

如果PC或Weblogic突然关闭(即强制关闭),代码是否有可能在1000行中的第X行运行并终止?

如果是,是否有任何可能的方法在服务器恢复时“运行”其余代码(从 X+1 到 1000)。

谢谢。

最佳答案

Will there be a chance that code is running & terminated at line X of 1000 lines if the PC or Weblogic is shutdown suddenly (i.e force shutdown)?

If yes, is there any possible way to "run" the rest of the code (from X+1 to 1000) when the server is resumed.

您必须实现这样的机制,然后需要“重置”到X之前的某个点,然后恢复事务。不过,您的实现可以是具有持久消息的 Rabbit MQ 主题。更典型的配置(根据我的经验)涉及在集群中运行多个 Weblogic 服务器,并在这种情况下故障转移到该集群的另一个成员(并与持久队列结合使用)。

关于java - 如果服务器突然宕机,Java代码会中途终止吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58479008/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com