/// <summary> /// Sends a message using the metadata in the envelope if applicable /// </summary> /// <param name="message"></param> public void Send(Envelope <Stream> message) { using (MessageQueueTransaction trans = new MessageQueueTransaction()) { trans.Begin(); _client.Send(MsmqMessageConverter.ConstructMessage(message), trans); trans.Commit(); } }
/// <summary> /// Called by the message receiver to start processing a message /// </summary> /// <param name="trans"></param> /// <param name="message"></param> private Task ProcessReceivedMessage(MessageQueueTransaction trans, Message message) { Envelope <Stream> envelope = MsmqMessageConverter.ConstructEnvelope(message); Task messageProcess = Task.Run(() => { MessageReleaseAction action = InvokeMessageHandler(envelope); CompleteMessage(message, trans, action); }); return(messageProcess); }
/// <summary> /// Sends a collection of messages inside a batch transaction /// </summary> /// <param name="messages"></param> public void SendBatch(IEnumerable <Envelope <Stream> > messages) { List <Message> msg = new List <Message>(); foreach (var message in messages) { msg.Add(MsmqMessageConverter.ConstructMessage(message)); } using (MessageQueueTransaction tran = new MessageQueueTransaction()) { tran.Begin(); foreach (var mg in msg) { _client.Send(mg, tran); } tran.Commit(); } }