public void ProxyMainLogic_Process_SendDataToRealDistributor() { var queue = new QueueConfiguration(1, 1000); var server1 = new ServerId("localhost", 21171); var server2 = new ServerId("localhost", 21172); var server3 = new ServerId("localhost", 21173); var netconfig = new ConnectionConfiguration("testService", 10); TestHelper.OpenDistributorHost(server1, netconfig); TestHelper.OpenDistributorHost(server2, netconfig); var net = new ProxyNetModule(netconfig, new ConnectionTimeoutConfiguration(Consts.OpenTimeout, Consts.SendTimeout)); var distributor = new ProxyDistributorModule(new AsyncProxyCache(TimeSpan.FromMinutes(100)), net, queue, server1, new AsyncTasksConfiguration(TimeSpan.FromDays(1)), new AsyncTasksConfiguration(TimeSpan.FromDays(1))); net.SetDistributor(distributor); var cache = new ProxyCache(TimeSpan.FromSeconds(20)); var main = new ProxyMainLogicModule(distributor, net, cache); net.Start(); distributor.Start(); distributor.SayIAmHere(server1); distributor.SayIAmHere(server2); distributor.SayIAmHere(server3); cache.Start(); main.Start(); const string hash = ""; var ev = new InnerData(new Transaction("", "")); ev.Transaction = distributor.CreateTransaction(hash); ev.Transaction = distributor.CreateTransaction(hash); ev.Transaction = distributor.CreateTransaction(hash); ev.Transaction.Destination = new List <ServerId> { server1 }; bool res = main.Process(ev); var server = cache.Get(ev.Transaction.EventHash); Assert.IsNull(server); Assert.IsTrue(res); main.Dispose(); distributor.Dispose(); net.Dispose(); }
public UserTransaction GetTransaction(UserTransaction transaction) { var cachedData = _cache.Get(transaction.CacheKey); var server = cachedData == null || cachedData.Port == -1 ? _distributor.GetDestination(transaction):cachedData; UserTransaction result = null; var nresult = _net.GetTransaction(server, transaction, out result); if (nresult is FailNetResult) { result = new UserTransaction(transaction); result.SetError(); result.AddErrorDescription(Errors.ServerWithResultNotAvailable); } return(result); }