private static void Main(string[] args) { var queueAddress = ".\\private$\\sixeyed.messagequeue.unsubscribe-legacy"; var properties = new Dictionary <string, object>(); properties.Add("MulticastAddress", "234.1.1.2:8001"); using (var queue = MessageQueueFactory.CreateInbound(queueAddress, MessagePattern.PublishSubscribe, properties)) { Console.WriteLine("Listening on: {0}", queueAddress); Console.WriteLine("Listening on: {0}", queueAddress); queue.Listen(x => { if (x.BodyType == typeof(UserUnsubscribed)) { var unsubscribedEvent = x.BodyAs <UserUnsubscribed>(); Console.WriteLine("Starting UnsubscribeLegacyWorkflow for: {0}, at: {1}", unsubscribedEvent.EmailAddress, DateTime.Now.TimeOfDay); var workflow = new UnsubscribeLegacyWorkflow(unsubscribedEvent.EmailAddress); workflow.Run(); Console.WriteLine("Completed UnsubscribeLegacyWorkflow for: {0}, at: {1}", unsubscribedEvent.EmailAddress, DateTime.Now.TimeOfDay); } }); } }
public override void Handle(Message message, IMessageQueue sourceQueue) { var data = message.BodyAs <UserUnsubscribed>(); _logger.LogInformation($"[{DateTime.Now}] Started: {data.EmailAddress}"); var workflow = new UnsubscribeLegacyWorkflow(data.EmailAddress); workflow.Run(); _logger.LogInformation($"[{DateTime.Now}] Finished: {data.EmailAddress}"); }
static void Main(string[] args) { using (var queue = new msmq.MessageQueue( ".\\private$\\sixeyed.messagequeue.unsubscribe-legacy")) { queue.MulticastAddress = "234.1.1.2:8001"; while (true) { Console.WriteLine("unsubscribe-legacy listening"); var message = queue.Receive(); var body = message.BodyStream.ReadFromJson(message.Label); if (body.GetType() == typeof(UserUnsubscribed)) { var unsubscribedEvent = body as UserUnsubscribed; Console.WriteLine("Received UserUnsubscribed event for: {0}, at: {1}", unsubscribedEvent.EmailAddress, DateTime.Now); var workflow = new UnsubscribeLegacyWorkflow(unsubscribedEvent.EmailAddress); workflow.Run(); Console.WriteLine("Processed UserUnsubscribed event for: {0}, at: {1}", unsubscribedEvent.EmailAddress, DateTime.Now); } } } }