[英]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.