public static IMessageRouter RegisterSubscriber <T, TK>(this IMessageRouter router, string incomingRouteName, string outcomingRouteName, Func <T, TK> action) { var subscriber = Subscriber.Create(incomingRouteName, outcomingRouteName, action); router.RegisterSubscriber(subscriber); return(router); }
public void CreateSubscriberWithResponseRoute() { // arrange const string incomingRouteName = "IncomingRoute"; const string outcomingRouteName = "OutcomingRoute"; var isActionCalled = false; Func <InputClass, OutputClass> action = x => { isActionCalled = true; return(new OutputClass()); }; // act var subsriber = Subscriber.Create(incomingRouteName, outcomingRouteName, action); subsriber.Method(new InputClass()); // assert Assert.AreEqual(incomingRouteName, subsriber.Incoming.Name); Assert.AreEqual(typeof(InputClass), subsriber.Incoming.DataType); Assert.AreEqual(outcomingRouteName, subsriber.Outcoming.Name); Assert.AreEqual(typeof(OutputClass), subsriber.Outcoming.DataType); Assert.AreEqual(true, isActionCalled); }
public static IMessageRouter RegisterSubscriber <T>(this IMessageRouter router, string routeName, Action <T> action) { var subscriber = Subscriber.Create(routeName, action); router.RegisterSubscriber(subscriber); return(router); }
public void Location__() { try { try { File.Delete(PacketBufferHelper.GetBufferDbPath()); } catch { } var buffer = new RealmPacketBuffer(); string text = @"Shovel works with all types of exchanges. In this example, I've set up exchanges as direct exchanges which use routing keys. However, if you have fanout exchanges, those will work as well—but you won't indicate a routing key when setting up the shovel for the exchange. To demonstarate how you can send messages, let's look at the shovels we created for the first exchange that we set up—compose-to-messages-rmq. This shovel connects to our Compose for RabbitMQ exchange compose-exchange with our messages-rmq exchange in our Messages for RabbitMQ instance. Ive also created two queues to send messages to: compose - queue in the Compose instance and messages - queue in the Messages for RabbitMQ instance. Since the shovel is sending messages to the two exchanges, the queues have been bound to the exchanges so that the messages are received and queued up."; var __a = ChatMessageMT.Create(ProtocolVersion.v3__WeatherExtension, Subscriber.Create("*****@*****.**", SubscriberNetwork.Email), null, null, text); var __b = ChatMessageMO.Create(ProtocolVersion.v3__WeatherExtension, Subscriber.Create("79153925491", SubscriberNetwork.Mobile), null, null, text); var a = __a.Pack(56); var b = __b.Pack(56); var totalLength = a.Select(x => x.Payload.Length - 8).Sum(); var m1_ = MessageMO.Unpack(b[1].Payload, buffer) as ChatMessageMO; var m2 = MessageMT.Unpack(a[1].Payload, buffer) as ChatMessageMT; var m1 = MessageMT.Unpack(a[0].Payload, buffer) as ChatMessageMT; var m2_ = MessageMO.Unpack(b[0].Payload, buffer) as ChatMessageMO; var m3 = MessageMT.Unpack(a[2].Payload, buffer) as ChatMessageMT; var m3_ = MessageMO.Unpack(b[2].Payload, buffer) as ChatMessageMO; if (!m3.Complete) { throw new Exception(); } if (m3.Text != text) { throw new Exception(); } } catch (Exception e) { } }
public void CreateBasicSubscriber() { // arrange const string routeName = "IncomingRoute"; var isActionCalled = false; Action <InputClass> action = x => isActionCalled = true; // act var subsriber = Subscriber.Create(routeName, action); subsriber.Method(new InputClass()); // assert Assert.AreEqual(routeName, subsriber.Incoming.Name); Assert.AreEqual(typeof(InputClass), subsriber.Incoming.DataType); Assert.AreEqual(null, subsriber.Outcoming); Assert.AreEqual(true, isActionCalled); }