public IMessage CreateMessage() { BaseMessage answer = new BaseMessage(); return(answer); }
public IMessage CreateMessage() { BaseMessage answer = new BaseMessage(); return answer; }
public void Send(IDestination destination, IMessage imessage, bool persistent, byte priority, TimeSpan timeToLive) { BaseMessage message = (BaseMessage)imessage; MessageQueue mq = null; MessageQueue responseQueue = null; MessageQueueTransaction transaction = null; try { // Locate the MSMQ Queue we will be sending to if (messageQueue != null) { if (destination.Equals(this.destination)) { mq = messageQueue; } else { throw new NMSException("This producer can only be used to send to: " + destination); } } else { mq = openMessageQueue((Destination)destination); } // Convert the Mesasge into a MSMQ message message.NMSPersistent = persistent; message.NMSExpiration = timeToLive; message.NMSPriority = priority; // message.NMSTimestamp = new DateTime().Date.; Message msg = messageConverter.ToMsmqMessage(message); // TODO: message.NMSMessageId = // Now Send the message if (mq.Transactional) { if (session.Transacted) { mq.Send(msg, session.MessageQueueTransaction); } else { // Start our own mini transaction here to send the message. transaction = new MessageQueueTransaction(); transaction.Begin(); mq.Send(msg, transaction); transaction.Commit(); } } else { if (session.Transacted) { // We may want to raise an exception here since app requested // a transeced NMS session, but is using a non transacted message queue // For now silently ignore it. } mq.Send(msg); } } finally { // Cleanup if (transaction != null) { transaction.Dispose(); } if (responseQueue != null) { responseQueue.Dispose(); } if (mq != null && mq != messageQueue) { mq.Dispose(); } } }