public void SerializerTest2() { var serializer = new Daytona.Store.Serializer(Encoding.Unicode); var cust = new Customer { Firstname = "Jie", Lastname = "wilson" }; var pl = new DBPayload<Customer>(); pl.Payload = cust; var input = serializer.GetSerializedPayload<Customer>(pl); var output = serializer.Deserializer<DBPayload<Customer>>(input); Assert.AreEqual(pl.Payload.Firstname, output.Payload.Firstname); Assert.AreEqual(pl.Payload.Lastname, output.Payload.Lastname); }
public void SerializerTest2() { var serializer = new Daytona.Store.Serializer(Encoding.Unicode); var cust = new Customer { Firstname = "Jie", Lastname = "wilson" }; var pl = new DBPayload <Customer>(); pl.Payload = cust; var input = serializer.GetSerializedPayload <Customer>(pl); var output = serializer.Deserializer <DBPayload <Customer> >(input); Assert.AreEqual(pl.Payload.Firstname, output.Payload.Firstname); Assert.AreEqual(pl.Payload.Lastname, output.Payload.Lastname); }
private static string SynchronizedSender(string input) { using (var context = ZmqContext.Create()) { using (ZmqSocket pub = Helper.GetConnectedPublishSocket(context, Pipe.PublishAddressClient), syncService = context.CreateSocket(SocketType.REP)) { //syncService.Connect(Pipe.PubSubControlFrontAddressClient); //for (int i = 0; i < 1; i++) //{ // syncService.Receive(Encoding.Unicode); // syncService.Send("", Encoding.Unicode); //} for (int i = 0; i < 100000; i++) { Console.WriteLine("Enter to send message=>"); input = Console.ReadLine(); if (input == "Exit") { break; } var cust = new Customer { Firstname = "John", Lastname = "Lemon" }; var pl = new Daytona.Store.DBPayload <Customer>(); pl.Payload = cust; ISerializer serializer = new Daytona.Store.Serializer(Encoding.Unicode); Helper.SendOneMessageOfType <Daytona.Store.DBPayload <Customer> >("Writer", pl, serializer, pub); // Helper.SendOneSimpleMessage("Writer", "Hello its me", pub); Console.WriteLine("message sent"); } Console.WriteLine("message sent enter to exit=>"); input = Console.ReadLine(); } } return(input); }
private static void SendCustomers(ZmqContext context) { ISerializer serializer = new Daytona.Store.Serializer(Encoding.Unicode); using (ZmqSocket publisher = context.CreateSocket(SocketType.PUB)) { publisher.Connect("tcp://*****:*****@"c:\dev\sender.log"); } Helper.SendOneSimpleMessage("XXXX", "stop", publisher); } }
private static string RunSenderWriterTest(string input) { using (var context = ZmqContext.Create()) { ISerializer serializer = new Daytona.Store.Serializer(Encoding.Unicode); var actorFactory = new Actor(context); actorFactory.RegisterActor <DBPayload <Customer> >("Writer", "Writer", "Sender", serializer, (IPayload message, byte[] messageAsBytes, string inRoute, string outRoute, ZmqSocket socket, Actor actor) => { Actor.Writeline("Got here in the writer"); var writer = new Writer(); //int Id = writer.Save(messageAsBytes); int Id = 3; var dBPayload = new DBPayload <Customer>(); dBPayload.Id = Id; actor.SendOneMessageOfType <DBPayload <Customer> >(outRoute, dBPayload, serializer, socket); }); actorFactory.RegisterActor <DBPayload <Customer> >("Sender", "Sender", "NO OUT ROUTE", serializer, (IPayload message, byte[] messageAsBytes, string inRoute, string outRoute, ZmqSocket socket, Actor actor) => { try { Actor.Writeline("Got here in the Sender"); var dBPayload = new DBPayload <Customer>(); actor.CallBack(1, null, null); } catch (Exception ex) { actor.CallBack(1, null, ex); } }); actorFactory.StartAllActors(); Console.WriteLine("enter to exit=>"); input = Console.ReadLine(); } return(input); }
private static string SynchronizedSender(string input) { using (var context = ZmqContext.Create()) { using (ZmqSocket pub = Helper.GetConnectedPublishSocket(context, Pipe.PublishAddressClient), syncService = context.CreateSocket(SocketType.REP)) { //syncService.Connect(Pipe.PubSubControlFrontAddressClient); //for (int i = 0; i < 1; i++) //{ // syncService.Receive(Encoding.Unicode); // syncService.Send("", Encoding.Unicode); //} for (int i = 0; i < 100000; i++) { Console.WriteLine("Enter to send message=>"); input = Console.ReadLine(); if (input == "Exit") break; var cust = new Customer { Firstname = "John", Lastname = "Lemon" }; var pl = new Daytona.Store.DBPayload<Customer>(); pl.Payload = cust; ISerializer serializer = new Daytona.Store.Serializer(Encoding.Unicode); Helper.SendOneMessageOfType<Daytona.Store.DBPayload<Customer>>("Writer", pl, serializer, pub); // Helper.SendOneSimpleMessage("Writer", "Hello its me", pub); Console.WriteLine("message sent"); } Console.WriteLine("message sent enter to exit=>"); input = Console.ReadLine(); } } return input; }