void ExternalTransportTransportMessageReceived(object sender, TransportMessageReceivedEventArgs e) { if (e.Message.MessageIntent == MessageIntentEnum.Publish) { if (!e.Message.Headers.ContainsKey(EnclosedMessageTypesMutator.EnclosedMessageTypes)) { throw new InvalidOperationException("Enclosed message type header was not found in message"); } var types = e.Message.Headers[EnclosedMessageTypesMutator.EnclosedMessageTypes].Split(';'); var subs = Subscribers.GetSubscriberAddressesForMessage(types.Select(s => new MessageType(s))); Logger.Debug("Received notification from " + RemoteServer + "."); foreach (var s in subs) { InternalMessageSender.Send(e.Message, s); } } else { ProxyData data = null; if (e.Message.CorrelationId != null) { data = Storage.GetAndRemove(e.Message.CorrelationId); } if (data == null) { return; } e.Message.CorrelationId = data.CorrelationId; Logger.Debug("Received response from " + RemoteServer + "."); InternalMessageSender.Send(e.Message, data.ClientAddress); } }
public void Save(ProxyData data) { storageQueue.Send( new Message {CorrelationId = data.Id, Body = data, Recoverable = true}, MessageQueueTransactionType.Automatic); }
void InternalTransportTransportMessageReceived(object sender, TransportMessageReceivedEventArgs e) { if (UnicastBus.HandledSubscriptionMessage(e.Message, Subscribers, null)) { e.Message.ReplyToAddress = ExternalAddress; ExternalMessageSender.Send(e.Message, RemoteServer); Logger.Debug("Received subscription message."); return; } var data = new ProxyData { Id = GenerateId(), ClientAddress = e.Message.ReplyToAddress, CorrelationId = e.Message.IdForCorrelation }; Storage.Save(data); Logger.Debug("Forwarding request to " + RemoteServer + "."); e.Message.IdForCorrelation = data.Id; e.Message.ReplyToAddress = ExternalAddress; ExternalMessageSender.Send(e.Message, RemoteServer); }