public async Task Try_server_and_client_together() { //can be an ioc bus too. var commandBus = new SimpleCommandBus(); commandBus.Register(Assembly.GetExecutingAssembly()); //takes care of execution var processor = new CqsMessageProcessor { CommandBus = commandBus }; //receive through HTTP var server = new CqsHttpListener(processor); server.Map(typeof(RaiseHands)); server.Start(new IPEndPoint(IPAddress.Loopback, 0)); //Our cqs HTTP client. var client = new CqsHttpClient("http://localhost:" + server.LocalPort); await client.ExecuteAsync(new RaiseHands { Reason = "all YOUR base" }); }
public async Task Try_server_and_client_together_for_queries() { //can be an ioc bus too. var bus = new SimpleQueryBus(); bus.Register(Assembly.GetExecutingAssembly()); //takes care of execution var processor = new CqsMessageProcessor { QueryBus = bus }; //receive through HTTP var server = new CqsHttpListener(processor); server.Map(typeof(GetUsers)); server.Start(new IPEndPoint(IPAddress.Loopback, 0)); //Our cqs HTTP client. var client = new CqsHttpClient("http://localhost:" + server.LocalPort); var result = await client.QueryAsync(new GetUsers { FirstName = "Jonas" }); }
public static CqsHttpClient Create() { var url = ConfigurationManager.AppSettings["CqsHttpServer"] ?? "http://127.0.0.1:8873"; var cqsClient = new CqsHttpClient(url) { CqsSerializer = new CqsJsonNetSerializer(), RequestDecorator = request => { if (HttpContext.Current.Request.Url.AbsolutePath.StartsWith("/Account/Activate")) { Debugger.Break(); } if (ClaimsPrincipal.Current.Identity.IsAuthenticated) { request.Headers.Add("X-UserName", ClaimsPrincipal.Current.Identity.Name); request.Headers.Add("X-AccountId", ClaimsPrincipal.Current.GetAccountId().ToString()); } } }; return(cqsClient); }