C# 的 TIBCO EMS 故障转移重新连接 (TIBCO.EMS.dll)

发布于 2024-07-07 04:52:48 字数 517 浏览 7 评论 0原文

我们有一个 TIBCO EMS 解决方案,该解决方案在 2-4 个服务器环境中使用内置服务器故障转移。 如果 TIBCO 管理将服务从一台 EMS 服务器故障转移到另一台服务器,则连接应在 EMS 服务级别自动转移到新服务器。 对于我们使用 EMS 服务的 C# 应用程序,这种情况不会发生 - 我们的用户连接在故障转移后没有转移到新服务器,我们不确定原因。

我们的应用程序仅在启动时连接到 EMS,因此如果 TIBCO 管理员在用户启动我们的应用程序后进行故障转移,则用户需要重新启动应用程序才能重新连接到新服务器(我们的 EMS 连接使用包括所有 4 个生产 EMS 服务器的服务器字符串) - 如果第一次尝试失败,它将移动到字符串中的下一个服务器并重试)。

我正在寻找一种自动化方法,如果检测到连接已断开,它将定期尝试重新连接到 EMS,但我不确定如何最好地做到这一点。

有任何想法吗? 我们正在使用 TIBCO.EMS.dll 版本 4.4.2 和 .Net 2.x(SmartClient 应用程序)

任何帮助将不胜感激。

We have a TIBCO EMS solution that uses built-in server failover in a 2-4 server environment. If the TIBCO admins fail-over services from one EMS server to another, connections are supposed to be transfered to the new server automatically at the EMS service level. For our C# applications using the EMS service, this is not happening - our user connections are not being transfered to the new server after failover and we're not sure why.

Our application connection to EMS at startup only so if the TIBCO admins failover after users have started our application, they users need to restart the app in order to reconnect to the new server (our EMS connection uses a server string including all 4 production EMS servers - if the first attempt fails, it moves to the next server in the string and tries again).

I'm looking for an automated approach that will attempt to reconnect to EMS periodically if it detects that the connection is dead but I'm not sure how best to do that.

Any ideas? We are using TIBCO.EMS.dll version 4.4.2 and .Net 2.x (SmartClient app)

Any help would be appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

陌伤浅笑 2024-07-14 04:52:48

首先,是的,我正在回答我自己的问题。 然而,值得注意的是,如果没有 ajmasstrean,我将一事无成。 太感谢了!

一:
应适当设置 ConnectionFactory.SetReconnAttemptCount、SetReconnAttemptDelay、SetReconnAttemptTimeout。 我认为默认值重试太快(重试之间大约 1/2 秒)。 由于网络存储等原因,我们的 EMS 服务器可能需要很长时间才能进行故障转移 - 因此以 1/2 秒的间隔重试 5 次是远远不够的。

二:
我相信启用客户端-服务器和服务器-客户端心跳很重要。 无法验证,但如果没有这些,客户端可能无法收到服务器离线或切换到故障转移模式的通知。 当然,这是 EMS 的服务器端设置。

三:
您可以通过设置 Tibems.SetExceptionOnFTSwitch(true) 来监视故障转移事件; 然后连接异常事件处理程序。 在单服务器环境中时,您将看到“连接已终止”消息。 但是,如果您处于容错多服务器环境中,您将看到以下内容:“连接已执行容错切换到”。 您并不严格需要此通知,但它可能很有用(尤其是在测试中)。

四:
显然 EMS 文档中没有明确说明,连接重新连接在单服务器环境中不起作用。 您需要处于多服务器、容错环境中。 然而,有一个技巧。 您可以将同一服务器放入连接列表中两次 - 我知道这很奇怪,但它可以工作,并且可以使内置的重新连接逻辑正常工作。

一些代码:

private void initEMS()
{
    Tibems.SetExceptionOnFTSwitch(true);
    _ConnectionFactory = new TIBCO.EMS.TopicConnectionFactory(<server>);
    _ConnectionFactory.SetReconnAttemptCount(30);       // 30retries
    _ConnectionFactory.SetReconnAttemptDelay(120000);   // 2minutes
    _ConnectionFactory.SetReconnAttemptTimeout(2000);   // 2seconds
_Connection = _ConnectionFactory.CreateTopicConnectionM(<username>, <password>);
    _Connection.ExceptionHandler += new EMSExceptionHandler(_Connection_ExceptionHandler);
}
private void _Connection_ExceptionHandler(object sender, EMSExceptionEventArgs args)
{
    EMSException e = args.Exception;
    // args.Exception = "Connection has been terminated" -- single server failure
    // args.Exception = "Connection has performed fault-tolerant switch to <server url>" -- fault-tolerant multi-server
    MessageBox.Show(e.ToString());
}

First off, yes, I am answering my own question. Its important to note, however, that without ajmastrean, I would be nowhere. thank you so much!

ONE:
ConnectionFactory.SetReconnAttemptCount, SetReconnAttemptDelay, SetReconnAttemptTimeout should be set appropriately. I think the default values re-try too quickly (on the order of 1/2 second between retries). Our EMS servers can take a long time to failover because of network storage, etc - so 5 retries at 1/2s intervals is nowhere near long enough.

TWO:
I believe its important to enable the client-server and server-client heartbeats. Wasn't able to verify but without those in place, the client might not get the notification that the server is offline or switching in failover mode. This, of course, is a server side setting for EMS.

THREE:
you can watch for failover event by setting Tibems.SetExceptionOnFTSwitch(true); and then wiring up a exception event handler. When in a single-server environment, you will see a "Connection has been terminated" message. However, if you are in a fault-tolerant multi-server environment, you will see this: "Connection has performed fault-tolerant switch to ". You don't strictly need this notification, but it can be useful (especially in testing).

FOUR:
Apparently not clear in the EMS documentation, connection reconnect will NOT work in a single-server environment. You need to be in a multi-server, fault tolerant environment. There is a trick, however. You can put the same server in the connection list twice - strange I know, but it works and it enables the built-in reconnect logic to work.

some code:

private void initEMS()
{
    Tibems.SetExceptionOnFTSwitch(true);
    _ConnectionFactory = new TIBCO.EMS.TopicConnectionFactory(<server>);
    _ConnectionFactory.SetReconnAttemptCount(30);       // 30retries
    _ConnectionFactory.SetReconnAttemptDelay(120000);   // 2minutes
    _ConnectionFactory.SetReconnAttemptTimeout(2000);   // 2seconds
_Connection = _ConnectionFactory.CreateTopicConnectionM(<username>, <password>);
    _Connection.ExceptionHandler += new EMSExceptionHandler(_Connection_ExceptionHandler);
}
private void _Connection_ExceptionHandler(object sender, EMSExceptionEventArgs args)
{
    EMSException e = args.Exception;
    // args.Exception = "Connection has been terminated" -- single server failure
    // args.Exception = "Connection has performed fault-tolerant switch to <server url>" -- fault-tolerant multi-server
    MessageBox.Show(e.ToString());
}
风透绣罗衣 2024-07-14 04:52:48

这篇文章应该总结我当前的评论,并更详细地解释我的方法...

TIBCO 'ConnectionFactory' 和 'Connection' 类型是重量级的、线程安全的类型。 TIBCO 建议您保持使用一个 ConnectionFactory(每个服务器配置的工厂)和每个工厂一个 连接。

服务器似乎还负责就地“连接”故障转移和重新连接,因此让我们确认它正在完成其工作,然后依靠该功能。

创建客户端解决方案比修复服务器或客户端设置问题稍微复杂一些。 您从失败的连接创建的所有会话都需要重新创建(更不用说生产者、消费者和目的地)。 这两种类型都没有“重新连接”或“刷新”方法。 会话也不维护对其父连接的引用。

您将必须管理连接/会话对象的查找,并疯狂地重新初始化每个人! 或实现某种会话失败事件处理程序,可以获取新连接并重新连接它们。

因此,现在让我们深入研究一下客户端是否设置为接收故障转移通知(tib ems 用户指南第 292 页)。 并确保引发的异常被捕获、包含故障转移 URL 并且得到正确处理。

This post should sum up my current comments and explain my approach in more detail...

The TIBCO 'ConnectionFactory' and 'Connection' types are heavyweight, thread-safe types. TIBCO suggests that you maintain the use of one ConnectionFactory (per server configured factory) and one Connection per factory.

The server also appears to be responsible for in-place 'Connection' failover and re-connection, so let's confirm it's doing its job and then lean on that feature.

Creating a client side solution is going to be slightly more involved than fixing a server or client setup problem. All sessions you have created from a failed connection need to be re-created (not to mention producers, consumers, and destinations). There are no "reconnect" or "refresh" methods on either type. The sessions do not maintain a reference to their parent connection either.

You will have to manage a lookup of connection/session objects and go nuts re-initializing everyone! or implement some sort of session failure event handler that can get the new connection and reconnect them.

So, for now, let's dig in and see if the client is setup to receive failover notification (tib ems users guide pg 292). And make sure the raised exception is caught, contains the failover URL, and is being handled properly.

杀手六號 2024-07-14 04:52:48

客户端应用程序可以通过设置 tibco.tibjms.ft.switch.exception 系统属性来接收故障转移的通知。

也许库需要它才能工作?

Client applications may receive notification of a failover by setting the tibco.tibjms.ft.switch.exception system property

Perhaps the library needs that to work?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文