public void MethodTestBatch() { Exception _ex = null; for (int i = 0; i < 128; i++) { RpcClientProxy proxy = RpcProxyFactory.GetProxy <IRpcTestService>(CurrentTestUrl); proxy.BeginInvoke( "TestBatch", "Hello", delegate(RpcClientContext ctx) { try { var s = ctx.EndInvoke <string>(); if (s != "Hello:OK") { throw new Exception("Response Failed:" + s); } } catch (Exception ex) { _ex = ex; } } ); } Thread.Sleep(5000); if (_ex != null) { throw _ex; } }
public int TestException(string serverUrl, string param, RpcErrorCode exceptedCode, string errMsg) { Stopwatch watch = new Stopwatch(); watch.Start(); try { RpcClientProxy proxy = RpcProxyFactory.GetProxy <IRpcTestService>(serverUrl); proxy.Invoke <string, string>("TestException", param); Assert.Fail("Should Failed..."); } catch (RpcException ex) { Console.WriteLine(ex.ToString()); Assert.AreEqual(exceptedCode, ex.RpcCode); if (!string.IsNullOrEmpty(errMsg)) { Assert.IsTrue(ex.ToString().Contains(errMsg)); } } int ms = (int)watch.ElapsedMilliseconds; Console.WriteLine("Cost Ms: {0}", ms); return(ms); }
public void SendCommand(string from, string command) { lock (_syncRoot) { DuplexDemoSession session = _agents[from]; RpcClientProxy proxy = session.Connection.GetCallbackProxy <IDuplexDemoCallbackService>(); proxy.Invoke <string, string>("CallCommand", command); } }
public int TestMethod2 <TArgs, TResults>(string serverUrl, string method, TArgs args, Action <TResults> assertCallback) { Stopwatch watch = new Stopwatch(); watch.Start(); RpcClientProxy proxy = RpcProxyFactory.GetProxy <IRpcTestService>(serverUrl); TResults r = proxy.Invoke <TArgs, TResults>(method, args, 30000); assertCallback(r); return((int)watch.ElapsedMilliseconds); }
public TracingSniffer(string url, TracingLevel level, string from, string to) { _url = url; _level = level; _from = from; _to = to; _enabled = true; _queueTracing = new LazyQueue <TracingEvent>("TracingSniffer.Tracing", 32, 50, DequeueActionTracing); _queueSystemLog = new LazyQueue <SystemLogEvent>("TracingSniffer.SystemLog", 32, 50, DequeueActionSystemLog); _proxy = RpcProxyFactory.GetProxy <ITracingSniffer>(_url); // _proxy.ShutUp = true; }
public void MethodTestAddBulk() { TracingManager.Level = TracingLevel.Warn; int failed = 0; int succ = 0; Exception lastEx; int total = 1500000; for (int i = 0; i < total; i++) { if (i % 1000 == 0) { Thread.Sleep(10); } RpcClientProxy proxy = RpcProxyFactory.GetProxy <IRpcTestService>(CurrentTestUrl); proxy.BeginInvoke( "Add", new RpcClass <int, int>(120, 120), ctx => { try { var s = ctx.EndInvoke <RpcClass <int> >(); if (s.Value != 240) { throw new Exception("Response Failed:" + s); } Interlocked.Increment(ref succ); } catch (Exception ex) { Interlocked.Increment(ref failed); lastEx = ex; } } ); } Thread.Sleep(5000); Assert.AreEqual(0, failed); Assert.AreEqual(total, succ); TracingManager.Level = TracingLevel.Info; }
public void MethodTestException_Timeout() { Stopwatch watch = new Stopwatch(); watch.Start(); try { RpcClientProxy proxy = RpcProxyFactory.GetProxy <IRpcTestService>(CurrentTestUrl); proxy.Timeout = 3000; proxy.Invoke <string, string>("TestTimeout", null); Assert.Fail("Should Failed..."); } catch (RpcException ex) { Assert.AreEqual(RpcErrorCode.TransactionTimeout, ex.RpcCode); Console.WriteLine(ex.ToString()); int ms = (int)watch.ElapsedMilliseconds; } }
private void InvokeAction(string prefix, TccWorkUnitContext <TContext> ctx, bool convertResults) { var uri = GetUri(ctx.Value); RpcClientProxy proxy = RpcProxyFactory.GetProxy <ITccRpcHostService>(uri); proxy.BeginInvoke <TArgs>( prefix + WorkName, ConvertArgs(ctx.Value), delegate(RpcClientContext context) { try { var rets = context.EndInvoke <TResults>(); if (convertResults) { ConvertResults(rets, ctx.Value); } ctx.Return(); } catch (Exception ex) { ctx.ThrowException(ex); } } ); }
public HAConfigurationLoader(string serviceName, string computerName, string centerUrl) { _computerName = computerName; _serviceName = serviceName; _proxy = RpcProxyFactory.GetProxy<IHACenterConfigService>(centerUrl); }
public RpcClientProxy GetProxy <T>() { RpcClientProxy proxy = new RpcClientProxy(this, RpcClientInterfaceFactory <T> .GetOne(), null); return(proxy); }
public HAConfigurationLoader(string serviceName, string computerName, string centerUrl) { _computerName = computerName; _serviceName = serviceName; _proxy = RpcProxyFactory.GetProxy <IHACenterConfigService>(centerUrl); }