public static IAsbOptions UseAzureServiceBusInOneWayClientMode(this RebusTransportConfigurer configurer, string connectionString) { IAsbOptions asbOptionsToReturn; if (ShouldEmulateAzureEnvironment(connectionString)) { var sender = MsmqMessageQueue.Sender(); configurer.UseSender(sender); asbOptionsToReturn = new NoopAsbOptions(); } else { var sender = AzureServiceBusMessageQueue.Sender(connectionString); configurer.UseSender(sender); asbOptionsToReturn = new AsbOptions(sender); } var gag = new OneWayClientGag(); configurer.UseReceiver(gag); configurer.UseErrorTracker(gag); return(asbOptionsToReturn); }
public void SendMsmqMessageToUnknownRemoteQueue() { var sender = MsmqMessageQueue.Sender(); sender.Send("nonexistingQueue@DACAPPL03", new TransportMessageToSend { Label = "unknown host", Headers = new Dictionary <string, object>(), Body = Encoding.UTF8.GetBytes("muahahahahahahaha"), }, new NoTransaction()); }
public static void UseAzureServiceBusInOneWayClientMode(this RebusTransportConfigurer configurer, string connectionString) { if (ShouldEmulateAzureEnvironment(connectionString)) { var sender = MsmqMessageQueue.Sender(); configurer.UseSender(sender); } else { var sender = AzureServiceBusMessageQueue.Sender(connectionString); configurer.UseSender(sender); } var gag = new OneWayClientGag(); configurer.UseReceiver(gag); configurer.UseErrorTracker(gag); }
void HandlePost(HttpListenerResponse response, HttpListenerRequest request) { using (var reader = new BinaryReader(request.InputStream)) { var receivedTransportMessage = new ReceivedTransportMessage { Id = request.Headers[RebusHttpHeaders.Id], Body = reader.ReadBytes((int)request.ContentLength64) }; var headers = new Dictionary <string, string>(); foreach (var rebusHeaderKey in request.Headers.AllKeys.Where(k => k.StartsWith(RebusHttpHeaders.CustomHeaderPrefix))) { var value = request.Headers[rebusHeaderKey]; var key = rebusHeaderKey.Substring(RebusHttpHeaders.CustomHeaderPrefix.Length); headers.Add(key, value); } log.Info("Got headers in request: {0}", string.Join(", ", headers.Keys)); receivedTransportMessage.Headers = headers; log.Info("Received message {0}", receivedTransportMessage.Id); using (var queue = MsmqMessageQueue.Sender()) { queue.Send(destinationQueue, receivedTransportMessage.ToForwardableMessage()); } log.Info("Message was sent to {0}", destinationQueue); response.StatusCode = (int)HttpStatusCode.OK; response.Close(); } }