public void Process(MessageContext messageContext) { object body = null; var subject = messageContext.Message.Properties.Subject; switch(subject) { case "Person": body = messageContext.Message.GetBody<Person>(); break; case "MapAddress": body = messageContext.Message.GetBody<MapAddress>(); break; case "InternationalAddress": body = messageContext.Message.GetBody<InternationalAddress>(); break; default: break; } if (body == null) { Console.WriteLine("Received a message with unknown type {0} in subject.", subject); } else { Console.WriteLine("Received a message with body {0}", body.GetType().Name); } messageContext.Complete(); }
public override void OnMessage(MessageContext messageContext) { // this can also be done when an async operation, if required, is done messageContext.Complete(); }
public void Process(MessageContext messageContext) { if (this.Messages != null) { this.Messages.Add(messageContext.Message); } messageContext.Complete(); }
void IMessageProcessor.Process(MessageContext messageContext) { messageContext.Complete(); this.OnComplete(); }
void IMessageProcessor.Process(MessageContext messageContext) { Console.WriteLine("Received a message."); messageContext.Complete(); }
public override void OnMessage(MessageContext messageContext) { messageContext.Complete(); }
public override void OnMessage(MessageContext messageContext) { this.semaphore.WaitAsync(30000).ContinueWith( t => { if (!t.Result) { messageContext.Complete(new Error() { Condition = ErrorCode.ResourceLimitExceeded }); } else { this.semaphore.Release(); messageContext.Complete(); } }); }
public override void OnMessage(MessageContext messageContext) { messageContext.Complete(); // delay 1s for the next message Task.Delay(1000, this.cts.Token).ContinueWith( t => { if (!t.IsCanceled) { this.link.SetCredit(1, false, false); } }); }
public void Process(MessageContext messageContext) { Console.WriteLine("Listener: received '{0}'.", messageContext.Message.Body); messageContext.Complete(); }
public void Process(MessageContext messageContext) { this.Messages.Add(messageContext.Message); messageContext.Complete(); }