简体   繁体   English

多个连接可用时,如何处理连接问题(数据库或外部系统)

[英]How to handle issues with Connections cannot be made(either DB or external systems) when multiple connections are available

I have question regarding handling the multiple connections. 我对处理多个连接有疑问。 These connections can be either DB connection, SOA connection, EMS connection etc..... 这些连接可以是DB连接,SOA连接,EMS连接等。

Lets say I have 1 database connection where I pull data and I have 2 EMS connections both having different data and independent. 可以说我有1个数据库连接用于提取数据,而我有2个EMS连接具有不同的数据且独立。 The data is sent to EMS and update the status whether the data is successfully sent or not. 数据将发送到EMS,并更新状态,无论数据是否成功发送。

1) If the database connection is down or any other issues when we cannot access database 2) Any 1 EMS connection is down, the application should continue processing the other EMS connection. 1)如果数据库连接断开或我们无法访问数据库时出现任何其他问题2)任何1 EMS连接断开,应用程序应继续处理其他EMS连接。 3) What happens if we are able to send data to EMS, but cannot update the DB status bcos of database issues, what are we suppose to do with all the messages that are in memory and we need to send to EMS. 3)如果我们能够将数据发送到EMS,但无法更新数据库问题的数据库状态,那么会发生什么情况,我们应该如何处理内存中所有需要发送到EMS的消息。 4) Cannot establish connection to 1 EMS, but the other were are able to establish and therefore the application should process that EMS messages. 4)无法建立与1个EMS的连接,但另一个能够建立,因此应用程序应处理该EMS消息。

These are some of the -ve test cases which I have to handle. 这些是我必须处理的一些-ve测试用例。 Please feel free to let me know if any other issues I have to tackle 如果需要解决其他问题,请随时告诉我

Multiple connections to different sources, sounds like a good solution for System.Transactions (if EMS supports this). 到不同来源的多个连接,听起来像是System.Transactions的一个很好的解决方案(如果EMS支持)。

Try something like this, this way all 3 operation eithr succeed or fail as a unit of work. 尝试类似的操作,这样,所有三个操作都作为一个工作单元成功或失败。

        try
        {
            using (TransactionScope tran = new TransactionScope())
            {
                Method1Save(); //DB
                Method2Save(); //EMS1
                Method3Save(); //EMS2
                tran.Complete();
            }
        }
        catch (Exception ex)
        {
            MessageBox.Show("Problem " + ex.ToString());
        }

If EMS does't support a TransactionScope, then you will have to handle it manaully, probably by putting the transaction on the connection itself and then committing all the transactions once the operations succeed, which means keeping the connections open longer for each data source. 如果EMS不支持TransactionScope,则可能必须手动处理它,方法可能是将事务放在连接本身上,然后在操作成功后提交所有事务,这意味着使每个数据源的连接打开时间更长。

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

相关问题 应该如何实现DbContext和与数据库的连接以处理负载测试? - How DbContext and connections to DB should be implemented to handle load testing? 使用linq时具有多个数据库连接的最简单方法是什么 - what is the easiest way to have multiple db connections when using linq 如何处理TCP C#套接字服务器中的多个活动连接? - How to handle multiple active connections in a TCP C# socket server? 运行IIS 5.0的Web服务器将如何处理多个dbserver连接? - how will webserver running IIS 5.0 handle multiple dbserver connections? 使用SqlQuery时,Entity Framework如何处理连接<T> - How does Entity Framework handle connections when using SqlQuery<T> 在C#中处理多个数据库连接 - Handle multiple database connections in c# 多个连接到同一 TransactionScope 中的同一 DB - Multiple connections to the same DB in the same TransactionScope Azure SQL-单个或多个数据库连接? - Azure SQL - Single or multiple DB connections? ASP.NET 管理多个数据库连接 - ASP.NET manage multiple DB connections 处理nservicebus消息时如何使用ADO打开多个SQL连接 - How to open multiple sql connections with ADO when handling an nservicebus message
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM