public CommunicationViaRabbitMQSteps() { IntegrationTestHelper.SetUpFixture(); _peerOne = new CommunicatingPeer("PeerOne"); _peerTwo = new CommunicatingPeer("PeerTwo"); _synchronizer = new CommunicationSynchronizer(); }
public void Unsubscribe(CommunicatingPeer peer, string topic) { peer.CommSvc2.Unsubscribe(new MessageDestination(topic)); }
public void Subscribe(CommunicatingPeer peer, string topic) { peer.CommSvc2.Subscribe(new MessageDestination(topic), i => Receive(i, peer)); }
public void Receive(IIncomingMessage incomingMessage, CommunicatingPeer recipient) { Logger.Debug(this, "Handling incoming message..."); lock (_syncRoot) { string incomingTopic = incomingMessage.Topic.ToString(); HasMessageBeenReceived = true; ReceivedMessageTopic = incomingTopic; ReceivedMessage = incomingMessage.Content.ToString(); ReceivedMsgCorrelationId = incomingMessage.CorrelationId; ReplyTo = incomingMessage.ReplyTo != null ? incomingMessage.ReplyTo.Address : String.Empty; Logger.Info(this, String.Format("{0} - Received message on topic {1} from {2}", recipient.PeerName, incomingMessage.Topic.Address, incomingMessage.Sender)); Monitor.Pulse(_syncRoot); } }
public void Send(CommunicatingPeer peer, string topic, string content, string correlationId="whatever", Action<IIncomingMessage> responseHandler = null) { lock (_syncRoot) { peer.CommSvc2.Send(new MessageDestination(topic), new MessageWrapper(content, correlationId),responseHandler); LastSentMessageTopic = topic; LastSentMessage = content; LastSentMsgCorrelationId = correlationId; Monitor.Wait(_syncRoot, 1000); } }