/* Alternate options: with lots of configuration */ /* private static void SubscribeToBus(IBus bus) * { * // 'RPC style' handler: request - response * bus.RespondAsync<GetApenRequest, GetApenResponse>(HandleGetApenRequestAsync, (config) => { * config.WithPrefetchCount(5); * config.WithQueueName("RPCqueue"); * }); * * // Subscribe to event (with or without topic) * bus.SubscribeAsync<AapCreated>("supskripsjun", HandleAapCreatedAsync, (config) => { * config.WithAutoDelete(true); * config.AsExclusive(); * config.WithQueueName("kjoeneem"); * config.WithPrefetchCount(10); * config.WithTopic("toppique"); * }); * * // Set up receive queue for handling a command * bus.Receive<CreateAap>("CreateAapQueue", HandleCreateAapAsync, (config) => { * config.AsExclusive(); * config.WithPrefetchCount(15); * config.WithPriority(5); * }); * } */ /*private static Task<GetApenResponse> HandleGetApenRequestAsync(GetApenRequest request) * { * GetApenResponse response = new GetApenResponse { CorrelationId = request.RequestId }; * * if (request.RequestId != Guid.Empty) * { * foreach (var aap in ApenProvider.GetApen()) response.Apen.Add(aap); * response.Success = true; * } * else * { * response.ErrorMessage = "Received request without correlation identifier"; * } * * return Task.FromResult(response); * }*/ private static Task <GetApenResponse> HandleGetApenRequestAsync(GetApenRequest request) { GetApenResponse response = new GetApenResponse { CorrelationId = request.RequestId, Success = request.RequestId != Guid.Empty }; if (response.Success) { foreach (var aap in ApenProvider.GetApen()) { response.Apen.Add(aap); } } return(Task.FromResult(response)); }
/* * private static GetApenResponse HandleGetApenRequest(GetApenRequest request) * { * GetApenResponse response = new GetApenResponse { CorrelationId = request.RequestId }; * * if (request.RequestId != Guid.Empty) * { * foreach (var aap in ApenProvider.GetApen()) response.Apen.Add(aap); * response.Success = true; * } * else * { * response.ErrorMessage = "Received request without correlation identifier"; * } * * return response; * } */ private static void Seed() { Console.WriteLine("Starting Seed..."); IList <Aap> apen = ApenProvider.GetApen().ToList(); if (!apen.Any()) { Console.WriteLine("Writing Seed data..."); var aap0 = ApenProvider.GetAap(0); if (aap0 == null) { ApenProvider.AddAap(new Aap { Id = 0, AapNaam = "Bokito", Soort = ApenSoort.Gorilla }); } var aap1 = ApenProvider.GetAap(1); if (aap1 == null) { ApenProvider.AddAap(new Aap { Id = 1, AapNaam = "King Kong", Soort = ApenSoort.Primaat }); } var aap2 = ApenProvider.GetAap(2); if (aap2 == null) { ApenProvider.AddAap(new Aap { Id = 2, AapNaam = "Johannes", Soort = ApenSoort.Sim }); } } else { Console.WriteLine("Seed data was already written..."); } }