internal static EventMessageResult BuildMessageResult(byte[] bytes) { var eventMessage = MessageSerializerFactory.CreateMessageSerializerInstance().Deserializer <EventMessage>(bytes); var result = new EventMessageResult { MessageBytes = eventMessage.EventMessageBytes, EventMessageBytes = eventMessage }; return(result); }
public static EventMessage CreateEventMessageInstance <T>(T originObject, string eventMessageMarkcode) where T : class, new() { var result = new EventMessage { CreateTime = DateTime.Now, EventMessageMarkcode = eventMessageMarkcode }; ///序列化消息 var bytes = MessageSerializerFactory.CreateMessageSerializerInstance().SerializerByte <T>(originObject); result.EventMessageBytes = bytes; return(result); }
public void Send(EventMessage eventMessage, string exchangeName, string queueName) { Context.SendConnection = ServerManger.Instance.CreateConnectionFactory().CreateConnection(); const byte DeliveryTag = 2; using (Context.SendConnection) { var messageSerializer = MessageSerializerFactory.CreateMessageSerializerInstance(); Context.SendCannel = Context.SendConnection.CreateModel(); var properties = Context.SendCannel.CreateBasicProperties(); properties.DeliveryMode = DeliveryTag; Context.SendCannel.BasicPublish(exchangeName, queueName, true, properties, messageSerializer.SerializerByte(eventMessage)); } }