public void Should_throw_exception_if_provide_null_route_finder() { // Arrange IRpcRouteFinder routeFinder = null; new BurrowRpcServerCoordinator <ISomeService>(NSubstitute.Substitute.For <ISomeService>(), routeFinder, "queue-connnection-string"); }
/// <summary> /// Create Rpc server using a realImplementation which will handle rpc request /// </summary> /// <typeparam name="T">the interface which we use for RPC call</typeparam> /// <param name="realImplementation">an instance of the class implemented the generic interface, it will eventually handle the rpc method call from the client</param> /// <param name="routeFinder">If null, the DefaultRpcRouteFinder will be used and client/server will contact to each other directly through default built-in exchange</param> /// <param name="rabbitMqConnectionString"></param> /// <param name="serverId">will be used to determine whether the request queue is durable. It is also used as the subscription name when the server subscribe to request queue</param> /// <returns></returns> public static IRpcServerCoordinator CreateServer <T>(T realImplementation, IRpcRouteFinder routeFinder = null, string rabbitMqConnectionString = null, string serverId = null) where T : class { return(new BurrowRpcServerCoordinator <T>(realImplementation, routeFinder ?? new DefaultRpcRouteFinder <T>(), rabbitMqConnectionString, serverId)); }
public void Init() { _routeFinder = Substitute.For <IRpcRouteFinder>(); _routeFinder.RequestExchangeName.Returns("RequestExchange"); _routeFinder.RequestQueue.Returns("RequestQueue"); _routeFinder.UniqueResponseQueue.Returns("ResposeQueue"); }
public void Init() { _routeFinder = Substitute.For<IRpcRouteFinder>(); _routeFinder.RequestExchangeName.Returns("RequestExchange"); _routeFinder.RequestQueue.Returns("RequestQueue"); _routeFinder.UniqueResponseQueue.Returns("ResposeQueue"); }
public BurrowRpcClientCoordinator(string rabbitMqConnectionString = null, IRpcRouteFinder routeFinder = null) { _rabbitMqConnectionString = InternalDependencies.RpcQueueHelper.TryGetValidConnectionString(rabbitMqConnectionString); _routeFinder = routeFinder ?? new DefaultRpcRouteFinder <T>(); _tunnel = RabbitTunnel.Factory.Create(_rabbitMqConnectionString); _tunnel.SetRouteFinder(new RpcRouteFinderAdapter(_routeFinder)); _tunnel.SetSerializer(Global.DefaultSerializer); var subscriptionName = typeof(T).Name; Init(subscriptionName); }
public BurrowRpcServerCoordinator(T realInstance, IRpcRouteFinder routeFinder, string rabbitMqConnectionString = null, string serverId = null) { _rabbitMqConnectionString = InternalDependencies.RpcQueueHelper.TryGetValidConnectionString(rabbitMqConnectionString); if (realInstance == null) { throw new ArgumentNullException("realInstance"); } if (routeFinder == null) { throw new ArgumentNullException("routeFinder"); } _realInstance = realInstance; _routeFinder = routeFinder; _serverId = serverId; }
public RpcRouteFinderAdapter(IRpcRouteFinder routeFinder) { _routeFinder = routeFinder; }
/// <summary> /// Create Rpc client using dynamic proxy without providing a real implementatin of generic interface /// </summary> /// <typeparam name="T">the interface which we use for RPC call</typeparam> /// <param name="routeFinder">Provide a valid route finder to route your request to correct targets, default will be DefaultRpcRouteFinder</param> /// <param name="rabbitMqConnectionString"></param> /// <param name="filters">custom filters to determine whether a method is valid/async for RPC call</param> /// <returns></returns> public static T CreateClient <T>(IRpcRouteFinder routeFinder = null, string rabbitMqConnectionString = null, params IMethodFilter[] filters) where T : class { return(CreateClient <T>(new RpcClientInterceptor(new BurrowRpcClientCoordinator <T>(rabbitMqConnectionString, routeFinder ?? new DefaultRpcRouteFinder <T>()), filters))); }