public async Task <bool> ShovelDeclareAsync(string virtualHostName, string shovelName, ShovelConfiguration shovelConfiguration) { var response = await _httpClient.PutAsync($"/api/parameters/shovel/{virtualHostName}/{shovelName}", new StringContent( JsonConvert.SerializeObject(shovelConfiguration, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }), Encoding.UTF8, "application/json")) .ConfigureAwait(false); return(response.IsSuccessStatusCode); }
static async Task Start() { var senderConfig = new EndpointConfiguration("Sender"); senderConfig.UsePersistence <InMemoryPersistence>(); var routing = senderConfig.UseTransport <SqlServerTransport>() .ConnectionString(SenderConnectionString) .UseCatalogForEndpoint("Receiver", "nservicebus2") .UseOutgoingQueueForCatalog("nservicebus2", "Outgoing@dbo@nservicebus1") .Routing(); routing.RouteToEndpoint(typeof(MyRequest), "Receiver"); senderConfig.SendFailedMessagesTo("error"); var receiverConfig = new EndpointConfiguration("Receiver"); receiverConfig.UsePersistence <InMemoryPersistence>(); receiverConfig.UseTransport <SqlServerTransport>() .ConnectionString(ReceiverConnectionString) .UseOutgoingQueueForCatalog("nservicebus1", "Outgoing@dbo@nservicebus2"); receiverConfig.SendFailedMessagesTo("error"); var sender = await Endpoint.Start(senderConfig); var receiver = await Endpoint.Start(receiverConfig); var shovelConfig = new ShovelConfiguration(); shovelConfig.AddQueue("Sender", SenderConnectionString, new List <string> { "nservicebus1" }); shovelConfig.AddQueue("Receiver", ReceiverConnectionString, new List <string> { "nservicebus2" }); var shovel = await shovelConfig.Start(); while (true) { Console.WriteLine("Press <enter> to send a message"); Console.ReadLine(); await sender.Send(new MyRequest()); } }