public static void UnSubscribe <T>(MessageSubscription <T> sub) { if (!applicationIsQuitting) { Instance.StartCoroutine(Instance.InternalUnSubscribe(sub)); } }
public void SendRoutedMessage(routedMessage message, byte toCon, MessageSubscription reply) { pendingResponses.Add(reply); byte[] msg = message.toByteArray(); pcSendRoutedMessage(msg, 0, (byte)msg.Length, toCon); }
public bool SubscriptionIncludesMessage <T>(MessageSubscription <T> sub, T message) where T : Message { MessageHeader header = message.header; return((sub.from == null || sub.from == header.from) && (sub.to == null || sub.to == header.to)); }
private void CharCreation_OnMessageReceived(MessageSubscription<PlayerCreationEventArgs> s, MessageReceivedEventArgs<PlayerCreationEventArgs> args) { if (args.Message.IsDealer == false) { this.gameObject.SetActive(false); } }
public async Task Test_that_filter_can_interrupt_invocation_chain_with_state() { // Arrange var messageId = Guid.NewGuid(); const string state = "state"; const string correlationId = "correlationId"; const string exchange = "exchange"; const string routingKey = "routingKey"; const int retryCount = 123; var options = new MessageSubscriptionOptions <TestMessage, string>(routingKey); options.WithHandler <TestMessageHandlerWithState>(); options.WithState(state); var filterMock = new Mock <IMessageFilter>(); filterMock .Setup(x => x.HandleMessageAsync(It.IsNotNull <MessageFilteringContext>())) .Returns <MessageFilteringContext>(context => Task.FromResult(MessageHandlingResult.TransientFailure())); var globalFilters = new List <IMessageFilter> { filterMock.Object }; var subscription = new MessageSubscription <TestMessage, string>(options, globalFilters); // Action var result = await subscription.InvokeHandlerAsync ( _serviceProvider, new TestMessage { Id = messageId }, new MessageHeaders(correlationId), new MessageHandlingContext(exchange, retryCount, routingKey), _messagePublisherMock.Object ); // Assert Assert.AreEqual(MessageHandlingResult.TransientFailure(), result); _testHandlerWithStateImplMock.Verify ( x => x.HandleAsync ( It.IsAny <string>(), It.IsAny <TestMessage>(), It.IsAny <MessageHeaders>(), It.IsAny <IMessagePublisher>() ), times: Times.Never ); filterMock.Verify(x => x.HandleMessageAsync(It.IsNotNull <MessageFilteringContext>()), Times.Once()); }
public void Subscribe(MessageSubscription subscription) { if (subscription == null) { throw new ArgumentNullException(nameof(subscription)); } if (subscription.Id == null) { throw new ArgumentNullException(nameof(subscription.Id)); } if (subscription.Topic == null) { throw new ArgumentNullException(nameof(subscription.Topic)); } if (subscription.Callback == null) { throw new ArgumentNullException(nameof(subscription.Callback)); } lock (_syncRoot) { if (_subscriptions.ContainsKey(subscription.Id)) { throw new Exception($"Subscription '{subscription.Id}' already registered."); } _subscriptions.Add(subscription.Id, subscription); } _log.Info($"Created subscription '{subscription.Id}' for topic '{subscription.Topic}' and type '{subscription.PayloadType}'."); }
public override MessageSubscription[] GetMessageSubscriptions(string server) { List <MessageSubscription> r = new List <MessageSubscription>(); foreach (var queueName in MessageQueue.GetPrivateQueuesByMachine(server). Where(q => q.QueueName.EndsWith(".subscriptions")).Select(q => q.QueueName)) { MessageQueue q = Msmq.Create(server, queueName, QueueAccessMode.ReceiveAndAdmin); q.MessageReadPropertyFilter.Label = true; q.MessageReadPropertyFilter.Body = true; try { var publisher = q.GetDisplayName().Replace(".subscriptions", string.Empty); foreach (var msg in q.GetAllMessages()) { var itm = new MessageSubscription(); itm.FullName = GetSubscriptionType(ReadMessageStream(msg.BodyStream)); itm.Name = ParseClassName(itm.FullName); itm.Subscriber = msg.Label; itm.Publisher = publisher; r.Add(itm); } } catch (Exception e) { OnError("Error occured when getting subcriptions", e, true); } } return(r.ToArray()); }
public static MessageSubscription <T> Subscribe <T>(Action <T> receiver) { MessageSubscription <T> sub = new MessageSubscription <T>(); sub.receiver = receiver; Instance.InternalSubscribe(sub); return(sub); }
void Start() { // set up a subscription to the signal with an order _subscription = Signaler.Instance.Subscribe <OrderTest>(this, OnOrderTest, order: order); // cache the message so that we don't have to reallocate each time we need to broadcast _message = new Acknowledgement(); }
void CharCreation_OnMessageReceived(MessageSubscription<PlayerCreationEventArgs> s, MessageReceivedEventArgs<PlayerCreationEventArgs> args) { if (!args.Message.IsDealer) { this.InventoryCanvas.SetActive(false); this.gameObject.SetActive(false); } }
public async Task Test_that_handler_with_state_invoked_without_filters() { // Arrange var messageId = Guid.NewGuid(); const string state = "state"; const string correlationId = "correlationId"; const string exchange = "exchange"; const string routingKey = "routingKey"; const int retryCount = 123; var options = new MessageSubscriptionOptions <TestMessage, string>(routingKey); options.WithHandler <TestMessageHandlerWithState>(); options.WithState(state); var subscription = new MessageSubscription <TestMessage, string>(options, Array.Empty <IMessageFilter>()); _testHandlerWithStateImplMock .Setup(x => x.HandleAsync ( It.IsAny <string>(), It.IsAny <TestMessage>(), It.IsAny <MessageHeaders>(), It.IsAny <IMessagePublisher>() )) .Returns <string, TestMessage, MessageHeaders, IMessagePublisher>((s, m, h, p) => Task.FromResult(MessageHandlingResult.Success())); // Action var result = await subscription.InvokeHandlerAsync ( _serviceProvider, new TestMessage { Id = messageId }, new MessageHeaders(correlationId), new MessageHandlingContext(exchange, retryCount, routingKey), _messagePublisherMock.Object ); // Assert Assert.AreEqual(MessageHandlingResult.Success(), result); _testHandlerWithStateImplMock.Verify ( x => x.HandleAsync ( It.Is <string>(s => s == state), It.Is <TestMessage>(m => m.Id == messageId), It.IsNotNull <MessageHeaders>(), It.IsNotNull <IMessagePublisher>() ), times: Times.Once ); }
public MessageSubscription GetClientSubscription(string clientGuid) { MessageSubscription clientSubscription = null; lock (this){ clientSubscription = clientSubscriptions[clientGuid]; } return(clientSubscription); }
public IMessageSubscription Create( IChannelManagerFactory channelManagerFactory, Type[] messageHandlerTypes) { var listener = new RabbitMQMessageListener(channelManagerFactory, messageHandlerTypes, this.messageHandlerTypesIndexFactory, this.messageHandlerInvokerFactory, this.queueNameConvention, this.messageEncoder, this.messageSerialiser, this.logger, this.configuration); var subscription = new MessageSubscription(this.taskLibrary, listener); return subscription; }
public PoCSchema(IMessageService messageService) { //Query = resolver.Resolve<PoCQuery>(); //Mutation = resolver.Resolve<PoCMutation>(); //Subscription = resolver.Resolve<MessageSubscription>(); Query = new MessageQuery(messageService); Mutation = new MessageMutation(messageService); Subscription = new MessageSubscription(messageService); }
private void ExecuteCallback(MessageSubscription messageSubscription, Message <JObject> message) { try { messageSubscription.Callback(message); } catch (Exception exception) { _log.Warning(exception, $"Error while executing callback of subscription '{messageSubscription.Id}'."); } }
void InternalSubscribe <T>(MessageSubscription <T> sub) { if (subscriptionTable[typeof(T)] == null) { subscriptionTable[typeof(T)] = new List <MessageSubscription <T> >(); } ((List <MessageSubscription <T> >)subscriptionTable[typeof(T)]).Add(sub); SubCount++; gameObject.name = "[Ravens] (Subscribers: " + SubCount + ")"; }
void Start() { // subscribe to the broadcast _subscription = Signaler.Instance.Subscribe <SaySomething>(this, OnSaySomething); // set up the long filter list and set rotating _longFilter = GetFilter(); SetRotating(); messageText.text = ""; }
/// <summary> /// Subscribes to events of the specified type to execute the specified action. /// </summary> /// <typeparam name="TService">The type of the service (or -interface) to activate.</typeparam> /// <typeparam name="TMessage">The type of the message to subscribe to.</typeparam> /// <param name="methodName">Name of the method in the service, that accepts a single TMessage parameter and returns a Task. Use <c>nameof</c>.</param> /// <returns> /// The token for the subscription. /// </returns> public static Guid Subscribe <TService, TMessage>(string methodName) { // inspect the input: does the method exist and use the correct param? SubscriptionSanityCheck <TService, TMessage>(methodName); lock (Subscriptions) { var sub = new MessageSubscription <TService, TMessage>(methodName); Subscriptions.Add(sub); return(sub.Token); } }
public void On <TMessage>(Action <object> handler) where TMessage : Message { var sub = new MessageSubscription() { Type = typeof(TMessage), MessageId = typeof(TMessage).Name, Handler = handler }; _subs.Add(sub); }
public void Subscribe(string id, string topic, string payloadType, string callbackFunctionName) { var messageSubscription = new MessageSubscription { Id = id, Topic = topic, PayloadType = payloadType, Callback = m => _scriptingSession.Execute(callbackFunctionName) }; _messageBrokerService.Subscribe(messageSubscription); }
void Start() { this.InvSlots = GetComponentsInChildren<Image>(); InvDispUpdate = MessageBusManager.CreateSubscription<InventoryEventArgs>(); MessageBusManager.Subscribe(InvDispUpdate, "InventoryUpdate"); InvDispUpdate.OnMessageReceived += InvDispUpdate_OnMessageReceived; CharCreation = MessageBusManager.CreateSubscription<PlayerCreationEventArgs>(); MessageBusManager.Subscribe(CharCreation, "CharCreated"); CharCreation.OnMessageReceived += CharCreation_OnMessageReceived; }
void Start() { UsedItems = GetComponentsInChildren<UsedItem>(); defaultImage = UsedItems[0].ItemDisplay.sprite; InvDispUpdate = MessageBusManager.CreateSubscription<InventoryEventArgs>(); MessageBusManager.Subscribe(InvDispUpdate, "UsedItemsUpdate"); InvDispUpdate.OnMessageReceived += InvDispUpdate_OnMessageReceived; CharCreation = MessageBusManager.CreateSubscription<PlayerCreationEventArgs>(); MessageBusManager.Subscribe(CharCreation, "CharCreated"); CharCreation.OnMessageReceived += CharCreation_OnMessageReceived; }
public void SetupBeforeEachTest() { this.taskLibrary = A.Fake<ITaskLibrary>(); this.messageListener = A.Fake<IMessageListener>(); this.cancellationTokenSource = new CancellationTokenSource(); A.CallTo(() => this.taskLibrary.CreateCancellationTokenSource()).Returns(this.cancellationTokenSource); this.task = new Task(() => { }); A.CallTo(() => this.taskLibrary.ExecuteAsync(A<Action>._)).Returns(this.task); this.componentUnderTest = new MessageSubscription(this.taskLibrary, this.messageListener); }
public void AddClientSubscription(string clientGuid, MessageSubscription clientSubscription) { lock (this){ clientSubscriptions.Add(clientGuid, clientSubscription); clientSubscription.GetCancellation().Token.Register(() => { lock (this){ clientSubscriptions.Remove(clientGuid); } clientSubscription.Remove(); }); clientSubscription.Add((ushort opCode, MessageTransferable message) => { return(subscriber?.Invoke(opCode, clientGuid, message) ?? 0); }); } }
public void Subscribe(MessageSubscription subscription) { var eventType = subscription.EventType.Name; if (!_eventActions.ContainsKey(eventType)) { _eventActions[eventType] = new List <object>(); } if (!_ownerSubscriptions.ContainsKey(subscription.Owner)) { _ownerSubscriptions[subscription.Owner] = new List <MessageSubscription>(); } _eventActions[eventType].Add(subscription.OnEvent); _ownerSubscriptions[subscription.Owner].Add(subscription); }
public Guid Subscribe <TMessage>(Action <TMessage> callback) where TMessage : IMessage { var sub = new MessageSubscription <TMessage>(callback); if (_messageTable.TryGetValue(typeof(TMessage), out var list)) { list.Add(sub); } else { _messageTable.Add(typeof(TMessage), new List <IMessageSubscription> { sub }); } return(sub.Token); }
/// <summary> /// Sets the group of the subscription, /// creating a new subscription if necessary /// </summary> /// <param name="group">Group of the subscription</param> public void SetGroup(long?group) { _group = group; if (_subscription != null) { // subscription already exists, so we just update the group _subscription.Group = _group; } else { // create a new subscription with the group _subscription = Signaler.Instance.Subscribe <CubeUpdate>(this, OnCubeUpdate, group: _group); } // update the text to show the group number of the cube textMesh.text = FormatGroup(); }
private static bool IsMatch(Message <JObject> message, MessageSubscription subscription) { if (subscription.Topic != AnyWildcard && !string.Equals(subscription.Topic, message.Topic)) { return(false); } if (!string.Equals(subscription.PayloadType, message.Payload.Type)) { return(false); } if (subscription.Filter != null && !subscription.Filter(message)) { return(false); } return(true); }
public override MessageSubscription[] GetMessageSubscriptions(Dictionary <string, object> connectionSettings, IEnumerable <string> queues) { var server = connectionSettings[CS_SERVER] as string; List <MessageSubscription> r = new List <MessageSubscription>(); var msmqQ = MessageQueue.GetPrivateQueuesByMachine(server).Where(q => q.QueueName.EndsWith(".subscriptions")).Select(q => q.QueueName); foreach (var queueName in queues) { var queueSubscr = queueName + ".subscriptions"; if (msmqQ.Any(mq => mq.EndsWith(queueSubscr))) { MessageQueue q = Msmq.Create(server, queueSubscr, QueueAccessMode.ReceiveAndAdmin); q.MessageReadPropertyFilter.Label = true; q.MessageReadPropertyFilter.Body = true; try { foreach (var msg in q.GetAllMessages()) { var itm = new MessageSubscription(); itm.FullName = GetSubscriptionType(ReadMessageStream(msg.BodyStream)); itm.Name = ParseClassName(itm.FullName); itm.Subscriber = msg.Label; itm.Publisher = queueName; r.Add(itm); } } catch (Exception e) { OnError("Error occured when getting subcriptions", e, true); } } } return(r.ToArray()); }
public IEnumerator InternalUnSubscribe <T>(MessageSubscription <T> sub) { yield return(new WaitForEndOfFrame()); bool removed = true; if (subscriptionTable[typeof(T)] == null) { removed = false; Debug.Log("Trying to remove subscriber but none of that type found"); yield return(null); } if (!((List <MessageSubscription <T> >)subscriptionTable[typeof(T)]).Remove(sub)) { removed = false; Debug.Log("Trying to remove subscriber but it was not found"); yield return(null); } if (removed) { SubCount--; gameObject.name = "[Ravens] (Subscribers: " + SubCount + ")"; } }
public void ShouldNotDisposeOfListenerAgainDuringFinalise() { this.componentUnderTest.Dispose(); this.componentUnderTest = null; GC.Collect(); GC.WaitForPendingFinalizers(); // Only the 1 call from the Dispose method A.CallTo(() => this.messageListener.Dispose()).MustHaveHappened(Repeated.Exactly.Once); }
public override MessageSubscription[] GetMessageSubscriptions(Dictionary <string, object> connectionSettings, IEnumerable <string> queues) { var server = connectionSettings[CS_SERVER] as string; List <MessageSubscription> r = new List <MessageSubscription>(); // Raven Persistance DocumentStore db = null; try { var ravenUrl = (string)connectionSettings.GetValue(NServiceBus_MSMQ_Manager.CS_RAVEN_PERSISTANCE, null); if (!ravenUrl.IsValid()) { ravenUrl = "http://" + server + ":8080"; } db = new DocumentStore { Url = ravenUrl }; db.Initialize(); } catch { return(r.ToArray()); } // MSMQ Persistance var msmqQ = MessageQueue.GetPrivateQueuesByMachine(server).Where(q => q.QueueName.EndsWith(".subscriptions")).Select(q => q.QueueName); foreach (var queueName in queues) { var queueSubscr = queueName + ".subscriptions"; // First check MSMQ if (msmqQ.Any(mq => mq.EndsWith(queueSubscr))) { MessageQueue q = ServiceBusMQ.NServiceBus.MSMQ.Msmq.Create(server, queueSubscr, QueueAccessMode.ReceiveAndAdmin); q.MessageReadPropertyFilter.Label = true; q.MessageReadPropertyFilter.Body = true; try { foreach (var msg in q.GetAllMessages()) { var itm = new MessageSubscription(); itm.FullName = GetSubscriptionType(ReadMessageStream(msg.BodyStream)); itm.Name = ParseClassName(itm.FullName); itm.Subscriber = msg.Label; itm.Publisher = queueName; r.Add(itm); } } catch (Exception e) { OnError("Error occured when getting subcriptions", e, true); } } else // RavenDB { var headers = db.DatabaseCommands.Head("Raven/Databases/" + queueName); if (headers != null) { using (var s = db.OpenSession(queueName)) { //s.Advanced.AllowNonAuthoritativeInformation = false; //var doc = s.Load<Subscription>("subscriptions/88dc7793-0cbd-ec39-5dd2-6b982e1e3c76"); //if( doc != null ) // Console.Write("WOW"); var list = s.Advanced.LoadStartingWith <Subscription>("subscription", null, 0, 1024).ToArray(); foreach (var subr in list) //.StartsWith("Subscriptions/")) ) { { foreach (var client in subr.Clients) { var itm = new MessageSubscription(); itm.FullName = subr.MessageType.ToString(); itm.Name = ParseClassName(itm.FullName); itm.Subscriber = client.ToString(); itm.Publisher = queueName; r.Add(itm); } } } } } } //foreach( var queueName in MessageQueue.GetPrivateQueuesByMachine(server). // Where(q => q.QueueName.EndsWith(".subscriptions")).Select(q => q.QueueName) ) { //} return(r.ToArray()); }
private static void Subscribe(MessageSubscription subscription) { Msgs.Subscribe(subscription); EventSubs.Add(subscription); }
public static void Subscribe <T>(Action <T> onEvent, object owner) => Subscribe(MessageSubscription.Create(onEvent, owner));
void Start() { CharCreation = MessageBusManager.CreateSubscription<PlayerCreationEventArgs>(); MessageBusManager.Subscribe(CharCreation, "CharCreated"); CharCreation.OnMessageReceived += CharCreation_OnMessageReceived; }
private void OnGameStartEvent(MessageSubscription<OnGameStartEventArgs> s, MessageReceivedEventArgs<OnGameStartEventArgs> args) { InitPlayer(); }
void InvDispUpdate_OnMessageReceived(MessageSubscription<InventoryEventArgs> s, MessageReceivedEventArgs<InventoryEventArgs> args) { UpdateInventoryDisplay(args.Message.Inventory); }
void ShootingDamage_OnMessageReceived(MessageSubscription<ShootingEventArgs> s, MessageReceivedEventArgs<ShootingEventArgs> args) { if (isLocalPlayer) CmdTellServerWhoWasShot(args.Message.UIdentity, args.Message.Damage); }
void Start() { Name = "Player"; audioListener = GetComponentInChildren<AudioListener>(); mouseLooks = GetComponentsInChildren<MouseLook>(); mouseLooks[0].enabled = false; mouseLooks[1].enabled = false; OnGameStart = MessageBusManager.CreateSubscription<OnGameStartEventArgs>(); MessageBusManager.Subscribe(OnGameStart, "GameStart"); OnGameStart.OnMessageReceived += OnGameStartEvent; DontDestroyOnLoad(this); }
public void ShouldNotDisposeOfListenerDuringFinalise() { this.componentUnderTest = null; GC.Collect(); GC.WaitForPendingFinalizers(); A.CallTo(() => this.messageListener.Dispose()).MustNotHaveHappened(); }
public async Task Test_that_handler_invoked_with_two_filter() { // Arrange var messageId = Guid.NewGuid(); const string correlationId = "correlationId"; const string exchange = "exchange"; const string routingKey = "routingKey"; const int retryCount = 123; var options = new MessageSubscriptionOptions <TestMessage>(routingKey); options.WithHandler <TestMessageHandler>(); var filterMock = new Mock <IMessageFilter>(); filterMock .Setup(x => x.HandleMessageAsync(It.IsNotNull <MessageFilteringContext>())) .Returns <MessageFilteringContext>(context => context.InvokeNextAsync()); var globalFilters = new List <IMessageFilter> { filterMock.Object, filterMock.Object }; var subscription = new MessageSubscription <TestMessage>(options, globalFilters); _testHandlerImplMock .Setup(x => x.HandleAsync ( It.IsAny <TestMessage>(), It.IsAny <MessageHeaders>(), It.IsAny <IMessagePublisher>() )) .Returns <TestMessage, MessageHeaders, IMessagePublisher>((m, h, p) => Task.FromResult(MessageHandlingResult.Success())); // Action var result = await subscription.InvokeHandlerAsync ( _serviceProvider, new TestMessage { Id = messageId }, new MessageHeaders(correlationId), new MessageHandlingContext(exchange, retryCount, routingKey), _messagePublisherMock.Object ); // Assert Assert.AreEqual(MessageHandlingResult.Success(), result); _testHandlerImplMock.Verify ( x => x.HandleAsync ( It.Is <TestMessage>(m => m.Id == messageId), It.IsNotNull <MessageHeaders>(), It.IsNotNull <IMessagePublisher>() ), times: Times.Once ); filterMock.Verify(x => x.HandleMessageAsync(It.IsNotNull <MessageFilteringContext>()), Times.Exactly(2)); }
private void InitPlayer() { if (!isLocalPlayer) { cam = this.GetComponentInChildren<Camera>(); cam.enabled = false; } this.transforms = GetComponentsInChildren<Transform>(); this.DotRenderer = MinimapDisp.GetComponent<Renderer>(); this.MinimapCam = GameObject.Find("MinimapCam").GetComponent<Camera>(); this.healthValueDisplay = GameObject.Find("HealthText").GetComponent<Text>(); if (isLocalPlayer) { audioListener.enabled = true; this.AmmoValueDisplay = GameObject.Find("AmmoText").GetComponent<Text>(); AmmoValueDisplay.gameObject.SetActive(false); CmdSetReady(false); CmdSetDying(false); } dead = false; ShootingDamage = MessageBusManager.CreateSubscription<ShootingEventArgs>(); MessageBusManager.Subscribe(ShootingDamage, "Shooting"); ShootingDamage.OnMessageReceived += ShootingDamage_OnMessageReceived; InitChar(); }
public void Test_that_exception_propagated_through_the_filters_with_state() { // Arrange var messageId = Guid.NewGuid(); const string state = "state"; const string correlationId = "correlationId"; const string exchange = "exchange"; const string routingKey = "routingKey"; const int retryCount = 123; var options = new MessageSubscriptionOptions <TestMessage, string>(routingKey); options.WithHandler <TestMessageHandlerWithState>(); options.WithState(state); var filterMock = new Mock <IMessageFilter>(); Exception caughtException = null; filterMock .Setup(x => x.HandleMessageAsync(It.IsNotNull <MessageFilteringContext>())) .Returns <MessageFilteringContext>(async context => { try { return(await context.InvokeNextAsync()); } catch (Exception ex) { caughtException = ex; throw; } }); _testHandlerWithStateImplMock .Setup(x => x.HandleAsync ( It.IsAny <string>(), It.IsAny <TestMessage>(), It.IsAny <MessageHeaders>(), It.IsAny <IMessagePublisher>() )) .Returns <string, TestMessage, MessageHeaders, IMessagePublisher>((s, m, h, p) => throw new TestException()); var globalFilters = new List <IMessageFilter> { filterMock.Object }; var subscription = new MessageSubscription <TestMessage, string>(options, globalFilters); // Action Assert.ThrowsAsync <TestException>(async() => { await subscription.InvokeHandlerAsync ( _serviceProvider, new TestMessage { Id = messageId }, new MessageHeaders(correlationId), new MessageHandlingContext(exchange, retryCount, routingKey), _messagePublisherMock.Object ); }); // Assert Assert.IsInstanceOf <TestException>(caughtException); _testHandlerWithStateImplMock.Verify ( x => x.HandleAsync ( It.IsAny <string>(), It.IsAny <TestMessage>(), It.IsAny <MessageHeaders>(), It.IsAny <IMessagePublisher>() ), times: Times.Once ); filterMock.Verify(x => x.HandleMessageAsync(It.IsNotNull <MessageFilteringContext>()), Times.Once()); }
public NetworkMessageStream(MessageHandler send, MessageSubscription recieve) { this.Send = send; this.Recieve = recieve; }
public MessageSubscription[] GetMessageSubscriptions(Dictionary<string, object> connectionSettings, IEnumerable<string> queues) { var server = connectionSettings[CS_SERVER] as string; List<MessageSubscription> r = new List<MessageSubscription>(); foreach (var queueName in MessageQueue.GetPrivateQueuesByMachine(server). Where(q => q.QueueName.EndsWith("_subscriptions")).Select(q => q.QueueName)) { MessageQueue q = Msmq.Create(server, queueName, QueueAccessMode.ReceiveAndAdmin); q.MessageReadPropertyFilter.Label = true; q.MessageReadPropertyFilter.Body = true; try { var publisher = q.GetDisplayName().Replace("_subscriptions", string.Empty); foreach (var msg in q.GetAllMessages()) { var itm = new MessageSubscription(); itm.FullName = GetSubscriptionType(ReadMessageStream(msg.BodyStream)); itm.Name = ParseClassName(itm.FullName); itm.Subscriber = msg.Label; itm.Publisher = publisher; r.Add(itm); } } catch (Exception e) { OnError("Error occured when getting subcriptions", e, true); } } return r.ToArray(); }
public void ImplementIMessageSubscription() { var componentUnderTest = new MessageSubscription(this.taskLibrary, this.messageListener); Assert.That(componentUnderTest, Is.InstanceOf<IMessageSubscription>()); }