Skip to content
Browse files

oops, forgot to apply the patch here in bug #457089 by Michael Barker.

svn path=/branches/messaging-2008/mcs/; revision=120980
  • Loading branch information...
1 parent 56f2a5e commit 41ca39c136de914adeb30deba27ecbb987e05350 @atsushieno atsushieno committed Dec 8, 2008
View
15 mcs/class/System.Messaging/System.Messaging/ChangeLog
@@ -1,3 +1,18 @@
+2008-11-23 Michael Barker <mike@middlesoft.co.uk>
+
+ * MessageQueue.cs: Added support for MessageQueueTransactionType methods,
+ ReceiveBy{Id,CorrelationId} and PeekBy{Id,CorrelationId} methods.
+
+2008-11-02 Michael Barker <mike@middlesoft.co.uk>
+
+ * MessageQueue.cs: Added implementation for deleting, purging, sending with
+ labels and message transactions.
+
+2008-10-27 Michael Barker <mike@middlesoft.co.uk>
+
+ * MessageQueueTransaction.cs: Delegated all methods to IMessageQueueTransaction
+ from Mono.Messaging.
+
2008-10-12 Michael Barker <mike@middlesoft.co.uk>
* MessageQueue.cs: Implemented GetMessageEnumerator().
View
19 mcs/class/System.Messaging/System.Messaging/MessageEnumerator.cs
@@ -98,17 +98,24 @@ public Message RemoveCurrent()
IMessage iMsg = delegateEnumerator.RemoveCurrent ();
if (iMsg == null)
return null;
- return new Message (iMsg);
+ return new Message (iMsg, null, formatter);
}
- [MonoTODO]
- public Message RemoveCurrent(MessageQueueTransaction transaction)
+
+ public Message RemoveCurrent (MessageQueueTransaction transaction)
{
- throw new NotImplementedException();
+
+ IMessage iMsg = delegateEnumerator.RemoveCurrent (transaction.DelegateTx);
+ if (iMsg == null)
+ return null;
+ return new Message (iMsg, null, formatter);
}
- [MonoTODO]
+
public Message RemoveCurrent(MessageQueueTransactionType transactionType)
{
- throw new NotImplementedException();
+ IMessage iMsg = delegateEnumerator.RemoveCurrent ((Mono.Messaging.MessageQueueTransactionType) transactionType);
+ if (iMsg == null)
+ return null;
+ return new Message (iMsg, null, formatter);
}
[MonoTODO]
public Message RemoveCurrent(TimeSpan timeout)
View
570 mcs/class/System.Messaging/System.Messaging/MessageQueue.cs
@@ -51,25 +51,22 @@ public class MessageQueue : Component, IEnumerable
public static readonly long InfiniteQueueSize;
public static readonly TimeSpan InfiniteTimeout;
private IMessageFormatter formatter;
-
+ private MessagePropertyFilter messageReadPropertyFilter = new MessagePropertyFilter ();
private readonly IMessageQueue delegateQueue;
#endregion //Fields
#region Constructor
- [MonoTODO]
public MessageQueue () : this (GetMessageQueue ())
{
}
- [MonoTODO]
public MessageQueue (string path) : this (path, false)
{
}
- [MonoTODO]
public MessageQueue (string path, bool sharedModeDenyReceive) :
this (GetMessageQueue (path))
{
@@ -281,13 +278,11 @@ internal MessageQueue (IMessageQueue delegateQueue)
[DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
[MessagingDescription ("MQ_MessageReadPropertyFilter")]
public MessagePropertyFilter MessageReadPropertyFilter {
- [MonoTODO]
get {
- throw new NotImplementedException ();
+ return messageReadPropertyFilter;
}
- [MonoTODO]
set {
- throw new NotImplementedException ();
+ messageReadPropertyFilter = value;
}
}
@@ -424,27 +419,31 @@ public static void ClearConnectionCache ()
{
throw new NotImplementedException ();
}
- [MonoTODO]
+
public void Close ()
{
- throw new NotImplementedException ();
+ delegateQueue.Close ();
}
public static MessageQueue Create (string path)
{
QueueReference qRef = QueueReference.Parse (path);
- IMessageQueue iMessageQueue = CreateMessageQueue (qRef);
+ IMessageQueue iMessageQueue = CreateMessageQueue (qRef, false);
return new MessageQueue (iMessageQueue);
}
- [MonoTODO]
+
public static MessageQueue Create (string path, bool transactional)
{
- throw new NotImplementedException ();
+ QueueReference qRef = QueueReference.Parse (path);
+ IMessageQueue iMessageQueue = CreateMessageQueue (qRef,
+ transactional);
+ return new MessageQueue (iMessageQueue);
}
- [MonoTODO]
+
public static void Delete (string path)
{
- throw new NotImplementedException ();
+ QueueReference qRef = QueueReference.Parse (path);
+ MessagingProviderLocator.GetProvider ().DeleteQueue (qRef);
}
[MonoTODO]
public Message EndPeek (IAsyncResult asyncResult)
@@ -466,10 +465,10 @@ public Message[] GetAllMessages ()
{
throw new NotImplementedException ();
}
- [MonoTODO]
+
public IEnumerator GetEnumerator ()
{
- throw new NotImplementedException ();
+ return GetMessageEnumerator ();
}
[MonoTODO]
public static Guid GetMachineId (string machineName)
@@ -481,45 +480,35 @@ public MessageEnumerator GetMessageEnumerator ()
{
return new MessageEnumerator (delegateQueue.GetMessageEnumerator (), Formatter);
}
-
- private static ArrayList currentQueueList;
-
- static MessageQueue ()
- {
- currentQueueList = new ArrayList ();
- // for testing purposes
- //currentQueueList.Add (new MessageQueue (@"localhost:\public\TestQueue"));
- //currentQueueList.Add (new MessageQueue (@"\private\AnotherTestQueue", "localhost", true));
- }
-
+ [MonoTODO]
public static MessageQueueEnumerator GetMessageQueueEnumerator ()
{
- return new MessageQueueEnumerator (currentQueueList);
+ throw new NotImplementedException ();
}
-
+ [MonoTODO]
private static ArrayList filteredQueueList (MessageQueueCriteria criteria)
{
- ArrayList list = new ArrayList ();
- foreach (MessageQueue queue in currentQueueList)
- if (criteria.Match (queue.Id, queue.CreateTime, queue.Label, queue.MachineName, queue.LastModifyTime))
- list.Add (queue);
- return list;
+ throw new NotImplementedException ();
}
-
+ [MonoTODO]
public static MessageQueueEnumerator GetMessageQueueEnumerator (MessageQueueCriteria criteria)
{
- return new MessageQueueEnumerator (filteredQueueList (criteria));
+ throw new NotImplementedException ();
}
-
+ [MonoTODO]
public static MessageQueue[] GetPrivateQueuesByMachine (string machineName)
{
throw new NotImplementedException ();
}
- [MonoTODO]
public static MessageQueue[] GetPublicQueues ()
{
- throw new NotImplementedException ();
+ IMessagingProvider provider = MessagingProviderLocator.GetProvider ();
+ IMessageQueue[] imqs = provider.GetPublicQueues ();
+ MessageQueue[] mqs = new MessageQueue[imqs.Length];
+ for (int i = 0; i < imqs.Length; i++)
+ mqs[i] = new MessageQueue (imqs[i]);
+ return mqs;
}
[MonoTODO]
public static MessageQueue[] GetPublicQueues (MessageQueueCriteria criteria)
@@ -541,46 +530,127 @@ public static MessageQueue[] GetPublicQueuesByMachine (string machineName)
{
throw new NotImplementedException ();
}
- [MonoTODO]
+
public Message Peek ()
{
- throw new NotImplementedException ();
+ try {
+ IMessage iMsg = delegateQueue.Peek ();
+ if (iMsg == null)
+ return null;
+
+ return new Message (iMsg, null, Formatter);
+
+ } catch (ConnectionException e) {
+ throw new MessageQueueException (MessageQueueErrorCode.QueueNotAvailable, e.Message);
+ } catch (MessageUnavailableException e) {
+ throw new InvalidOperationException (e.Message, e);
+ } catch (MonoMessagingException e) {
+ throw new MessageQueueException (MessageQueueErrorCode.Generic, e.Message);
+ }
}
- [MonoTODO]
+
public Message Peek (TimeSpan timeout)
{
- throw new NotImplementedException ();
+ try {
+ IMessage iMsg = delegateQueue.Peek (timeout);
+ if (iMsg == null)
+ return null;
+
+ return new Message (iMsg, null, Formatter);
+
+ } catch (ConnectionException e) {
+ throw new MessageQueueException (MessageQueueErrorCode.QueueNotAvailable, e.Message);
+ } catch (MessageUnavailableException e) {
+ throw new InvalidOperationException (e.Message, e);
+ } catch (MonoMessagingException e) {
+ throw new MessageQueueException (MessageQueueErrorCode.Generic, e.Message);
+ }
}
- [MonoTODO]
+
public Message PeekByCorrelationId (string correlationId)
{
- throw new NotImplementedException ();
+ try {
+ IMessage iMsg = delegateQueue.PeekByCorrelationId (correlationId);
+ if (iMsg == null)
+ return null;
+
+ return new Message (iMsg, null, Formatter);
+
+ } catch (ConnectionException e) {
+ throw new MessageQueueException (MessageQueueErrorCode.QueueNotAvailable, e.Message);
+ } catch (MessageUnavailableException e) {
+ throw new InvalidOperationException (e.Message, e);
+ } catch (MonoMessagingException e) {
+ throw new MessageQueueException (MessageQueueErrorCode.Generic, e.Message);
+ }
}
- [MonoTODO]
+
public Message PeekByCorrelationId (string correlationId, TimeSpan timeout)
{
- throw new NotImplementedException ();
+ try {
+ IMessage iMsg = delegateQueue.PeekByCorrelationId (correlationId, timeout);
+ if (iMsg == null)
+ return null;
+
+ return new Message (iMsg, null, Formatter);
+
+ } catch (ConnectionException e) {
+ throw new MessageQueueException (MessageQueueErrorCode.QueueNotAvailable, e.Message);
+ } catch (MessageUnavailableException e) {
+ throw new InvalidOperationException (e.Message, e);
+ } catch (MonoMessagingException e) {
+ throw new MessageQueueException (MessageQueueErrorCode.Generic, e.Message);
+ }
}
- [MonoTODO]
+
public Message PeekById (string id)
{
- throw new NotImplementedException ();
+ try {
+ IMessage iMsg = delegateQueue.PeekById (id);
+ if (iMsg == null)
+ return null;
+
+ return new Message (iMsg, null, Formatter);
+
+ } catch (ConnectionException e) {
+ throw new MessageQueueException (MessageQueueErrorCode.QueueNotAvailable, e.Message);
+ } catch (MessageUnavailableException e) {
+ throw new InvalidOperationException (e.Message, e);
+ } catch (MonoMessagingException e) {
+ throw new MessageQueueException (MessageQueueErrorCode.Generic, e.Message);
+ }
}
- [MonoTODO]
+
public Message PeekById (string id, TimeSpan timeout)
{
- throw new NotImplementedException ();
+ try {
+ IMessage iMsg = delegateQueue.PeekById (id, timeout);
+ if (iMsg == null)
+ return null;
+
+ return new Message (iMsg, null, Formatter);
+
+ } catch (ConnectionException e) {
+ throw new MessageQueueException (MessageQueueErrorCode.QueueNotAvailable, e.Message);
+ } catch (MessageUnavailableException e) {
+ throw new InvalidOperationException (e.Message, e);
+ } catch (MonoMessagingException e) {
+ throw new MessageQueueException (MessageQueueErrorCode.Generic, e.Message);
+ }
}
- [MonoTODO]
+
public void Purge ()
{
- throw new NotImplementedException ();
+ delegateQueue.Purge ();
}
public Message Receive ()
{
try {
IMessage iMsg = delegateQueue.Receive ();
+ if (iMsg == null)
+ return null;
+
return new Message (iMsg, null, Formatter);
} catch (ConnectionException e) {
@@ -589,90 +659,313 @@ public Message Receive ()
throw new MessageQueueException (MessageQueueErrorCode.Generic, e.Message);
}
}
- [MonoTODO]
+
public Message Receive (MessageQueueTransaction transaction)
{
- throw new NotImplementedException ();
+ try {
+ IMessage iMsg = delegateQueue.Receive (transaction.DelegateTx);
+ if (iMsg == null)
+ return null;
+
+ return new Message (iMsg, null, Formatter);
+
+ } catch (ConnectionException e) {
+ throw new MessageQueueException (MessageQueueErrorCode.QueueNotAvailable, e.Message);
+ } catch (MessageUnavailableException e) {
+ throw new InvalidOperationException (e.Message, e);
+ } catch (MonoMessagingException e) {
+ throw new MessageQueueException (MessageQueueErrorCode.Generic, e.Message);
+ }
}
- [MonoTODO]
+
public Message Receive (MessageQueueTransactionType transactionType)
{
- throw new NotImplementedException ();
+ try {
+ IMessage iMsg = delegateQueue.Receive ((Mono.Messaging.MessageQueueTransactionType) transactionType);
+ if (iMsg == null)
+ return null;
+
+ return new Message (iMsg, null, Formatter);
+
+ } catch (ConnectionException e) {
+ throw new MessageQueueException (MessageQueueErrorCode.QueueNotAvailable, e.Message);
+ } catch (MessageUnavailableException e) {
+ throw new InvalidOperationException (e.Message, e);
+ } catch (MonoMessagingException e) {
+ throw new MessageQueueException (MessageQueueErrorCode.Generic, e.Message);
+ }
}
- [MonoTODO]
+
public Message Receive (TimeSpan timeout)
{
- throw new NotImplementedException ();
+ try {
+ IMessage iMsg = delegateQueue.Receive (timeout);
+ if (iMsg == null)
+ return null;
+
+ return new Message (iMsg, null, Formatter);
+
+ } catch (ConnectionException e) {
+ throw new MessageQueueException (MessageQueueErrorCode.QueueNotAvailable, e.Message);
+ } catch (MessageUnavailableException e) {
+ throw new InvalidOperationException (e.Message, e);
+ } catch (MonoMessagingException e) {
+ throw new MessageQueueException (MessageQueueErrorCode.Generic, e.Message);
+ }
}
- [MonoTODO]
+
public Message Receive (TimeSpan timeout, MessageQueueTransaction transaction)
{
- throw new NotImplementedException ();
+ try {
+ IMessage iMsg = delegateQueue.Receive (timeout, transaction.DelegateTx);
+ if (iMsg == null)
+ return null;
+
+ return new Message (iMsg, null, Formatter);
+
+ } catch (ConnectionException e) {
+ throw new MessageQueueException (MessageQueueErrorCode.QueueNotAvailable, e.Message);
+ } catch (MessageUnavailableException e) {
+ throw new InvalidOperationException (e.Message, e);
+ } catch (MonoMessagingException e) {
+ throw new MessageQueueException (MessageQueueErrorCode.Generic, e.Message);
+ }
}
- [MonoTODO]
+
public Message Receive (TimeSpan timeout, MessageQueueTransactionType transactionType)
{
- throw new NotImplementedException ();
+ try {
+ IMessage iMsg = delegateQueue.Receive (timeout,
+ (Mono.Messaging.MessageQueueTransactionType) transactionType);
+ if (iMsg == null)
+ return null;
+
+ return new Message (iMsg, null, Formatter);
+
+ } catch (ConnectionException e) {
+ throw new MessageQueueException (MessageQueueErrorCode.QueueNotAvailable, e.Message);
+ } catch (MessageUnavailableException e) {
+ throw new InvalidOperationException (e.Message, e);
+ } catch (MonoMessagingException e) {
+ throw new MessageQueueException (MessageQueueErrorCode.Generic, e.Message);
+ }
}
- [MonoTODO]
+
public Message ReceiveByCorrelationId (string correlationId)
{
- throw new NotImplementedException ();
+ try {
+ IMessage iMsg = delegateQueue.ReceiveByCorrelationId (correlationId);
+ if (iMsg == null)
+ return null;
+
+ return new Message (iMsg, null, Formatter);
+
+ } catch (ConnectionException e) {
+ throw new MessageQueueException (MessageQueueErrorCode.QueueNotAvailable, e.Message);
+ } catch (MessageUnavailableException e) {
+ throw new InvalidOperationException (e.Message, e);
+ } catch (MonoMessagingException e) {
+ throw new MessageQueueException (MessageQueueErrorCode.Generic, e.Message);
+ }
}
- [MonoTODO]
+
public Message ReceiveByCorrelationId (string correlationId, MessageQueueTransaction transaction)
{
- throw new NotImplementedException ();
+ try {
+ IMessage iMsg = delegateQueue.ReceiveByCorrelationId (correlationId, transaction.DelegateTx);
+ if (iMsg == null)
+ return null;
+
+ return new Message (iMsg, null, Formatter);
+
+ } catch (ConnectionException e) {
+ throw new MessageQueueException (MessageQueueErrorCode.QueueNotAvailable, e.Message);
+ } catch (MessageUnavailableException e) {
+ throw new InvalidOperationException (e.Message, e);
+ } catch (MonoMessagingException e) {
+ throw new MessageQueueException (MessageQueueErrorCode.Generic, e.Message);
+ }
}
- [MonoTODO]
+
public Message ReceiveByCorrelationId (string correlationId, MessageQueueTransactionType transactionType)
{
- throw new NotImplementedException ();
+ try {
+ IMessage iMsg = delegateQueue.ReceiveByCorrelationId (correlationId, (Mono.Messaging.MessageQueueTransactionType) transactionType);
+ if (iMsg == null)
+ return null;
+
+ return new Message (iMsg, null, Formatter);
+
+ } catch (ConnectionException e) {
+ throw new MessageQueueException (MessageQueueErrorCode.QueueNotAvailable, e.Message);
+ } catch (MessageUnavailableException e) {
+ throw new InvalidOperationException (e.Message, e);
+ } catch (MonoMessagingException e) {
+ throw new MessageQueueException (MessageQueueErrorCode.Generic, e.Message);
+ }
}
- [MonoTODO]
+
public Message ReceiveByCorrelationId (string correlationId, TimeSpan timeout)
{
- throw new NotImplementedException ();
+ try {
+ IMessage iMsg = delegateQueue.ReceiveByCorrelationId (correlationId,
+ timeout);
+ if (iMsg == null)
+ return null;
+
+ return new Message (iMsg, null, Formatter);
+
+ } catch (ConnectionException e) {
+ throw new MessageQueueException (MessageQueueErrorCode.QueueNotAvailable, e.Message);
+ } catch (MessageUnavailableException e) {
+ throw new InvalidOperationException (e.Message, e);
+ } catch (MonoMessagingException e) {
+ throw new MessageQueueException (MessageQueueErrorCode.Generic, e.Message);
+ }
}
- [MonoTODO]
+
public Message ReceiveByCorrelationId (string correlationId, TimeSpan timeout, MessageQueueTransaction transaction)
{
- throw new NotImplementedException ();
+ try {
+ IMessage iMsg = delegateQueue.ReceiveByCorrelationId (correlationId, timeout, transaction.DelegateTx);
+ if (iMsg == null)
+ return null;
+
+ return new Message (iMsg, null, Formatter);
+
+ } catch (ConnectionException e) {
+ throw new MessageQueueException (MessageQueueErrorCode.QueueNotAvailable, e.Message);
+ } catch (MessageUnavailableException e) {
+ throw new InvalidOperationException (e.Message, e);
+ } catch (MonoMessagingException e) {
+ throw new MessageQueueException (MessageQueueErrorCode.Generic, e.Message);
+ }
}
- [MonoTODO]
+
public Message ReceiveByCorrelationId (string correlationId, TimeSpan timeout, MessageQueueTransactionType transactionType)
{
- throw new NotImplementedException ();
+ try {
+ IMessage iMsg = delegateQueue.ReceiveByCorrelationId (correlationId, timeout, (Mono.Messaging.MessageQueueTransactionType) transactionType);
+ if (iMsg == null)
+ return null;
+
+ return new Message (iMsg, null, Formatter);
+
+ } catch (ConnectionException e) {
+ throw new MessageQueueException (MessageQueueErrorCode.QueueNotAvailable, e.Message);
+ } catch (MessageUnavailableException e) {
+ throw new InvalidOperationException (e.Message, e);
+ } catch (MonoMessagingException e) {
+ throw new MessageQueueException (MessageQueueErrorCode.Generic, e.Message);
+ }
}
- [MonoTODO]
+
public Message ReceiveById (string id)
{
- throw new NotImplementedException ();
+ try {
+ IMessage iMsg = delegateQueue.ReceiveById (id);
+ if (iMsg == null)
+ return null;
+
+ return new Message (iMsg, null, Formatter);
+
+ } catch (ConnectionException e) {
+ throw new MessageQueueException (MessageQueueErrorCode.QueueNotAvailable, e.Message);
+ } catch (MessageUnavailableException e) {
+ throw new InvalidOperationException (e.Message, e);
+ } catch (MonoMessagingException e) {
+ throw new MessageQueueException (MessageQueueErrorCode.Generic, e.Message);
+ }
}
- [MonoTODO]
+
public Message ReceiveById (string id, MessageQueueTransaction transaction)
{
- throw new NotImplementedException ();
+ try {
+ IMessage iMsg = delegateQueue.ReceiveById (id, transaction.DelegateTx);
+ if (iMsg == null)
+ return null;
+
+ return new Message (iMsg, null, Formatter);
+
+ } catch (ConnectionException e) {
+ throw new MessageQueueException (MessageQueueErrorCode.QueueNotAvailable, e.Message);
+ } catch (MessageUnavailableException e) {
+ throw new InvalidOperationException (e.Message, e);
+ } catch (MonoMessagingException e) {
+ throw new MessageQueueException (MessageQueueErrorCode.Generic, e.Message);
+ }
}
- [MonoTODO]
+
public Message ReceiveById (string id, MessageQueueTransactionType transactionType)
{
- throw new NotImplementedException ();
+ try {
+ IMessage iMsg = delegateQueue.ReceiveById (id, (Mono.Messaging.MessageQueueTransactionType) transactionType);
+ if (iMsg == null)
+ return null;
+
+ return new Message (iMsg, null, Formatter);
+
+ } catch (ConnectionException e) {
+ throw new MessageQueueException (MessageQueueErrorCode.QueueNotAvailable, e.Message);
+ } catch (MessageUnavailableException e) {
+ throw new InvalidOperationException (e.Message, e);
+ } catch (MonoMessagingException e) {
+ throw new MessageQueueException (MessageQueueErrorCode.Generic, e.Message);
+ }
}
- [MonoTODO]
+
public Message ReceiveById (string id, TimeSpan timeout)
{
- throw new NotImplementedException ();
+ try {
+ IMessage iMsg = delegateQueue.ReceiveById (id, timeout);
+ if (iMsg == null)
+ return null;
+
+ return new Message (iMsg, null, Formatter);
+
+ } catch (ConnectionException e) {
+ throw new MessageQueueException (MessageQueueErrorCode.QueueNotAvailable, e.Message);
+ } catch (MessageUnavailableException e) {
+ throw new InvalidOperationException (e.Message, e);
+ } catch (MonoMessagingException e) {
+ throw new MessageQueueException (MessageQueueErrorCode.Generic, e.Message);
+ }
}
- [MonoTODO]
+
public Message ReceiveById (string id, TimeSpan timeout, MessageQueueTransaction transaction)
{
- throw new NotImplementedException ();
+ try {
+ IMessage iMsg = delegateQueue.ReceiveById (id, timeout, transaction.DelegateTx);
+ if (iMsg == null)
+ return null;
+
+ return new Message (iMsg, null, Formatter);
+
+ } catch (ConnectionException e) {
+ throw new MessageQueueException (MessageQueueErrorCode.QueueNotAvailable, e.Message);
+ } catch (MessageUnavailableException e) {
+ throw new InvalidOperationException (e.Message, e);
+ } catch (MonoMessagingException e) {
+ throw new MessageQueueException (MessageQueueErrorCode.Generic, e.Message);
+ }
}
- [MonoTODO]
+
public Message ReceiveById (string id, TimeSpan timeout, MessageQueueTransactionType transactionType)
{
- throw new NotImplementedException ();
+ try {
+ IMessage iMsg = delegateQueue.ReceiveById (id, timeout, (Mono.Messaging.MessageQueueTransactionType) transactionType);
+ if (iMsg == null)
+ return null;
+
+ return new Message (iMsg, null, Formatter);
+
+ } catch (ConnectionException e) {
+ throw new MessageQueueException (MessageQueueErrorCode.QueueNotAvailable, e.Message);
+ } catch (MessageUnavailableException e) {
+ throw new InvalidOperationException (e.Message, e);
+ } catch (MonoMessagingException e) {
+ throw new MessageQueueException (MessageQueueErrorCode.Generic, e.Message);
+ }
}
[MonoTODO]
public void Refresh ()
@@ -689,7 +982,6 @@ public void Send (object obj)
{
if (typeof (Message) == obj.GetType ()) {
Message m = (Message) obj;
- Console.WriteLine ("BodyStream {0}", m.BodyStream == null);
if (m.BodyStream == null) {
IMessageFormatter f = (m.Formatter == null) ? Formatter : m.Formatter;
f.Write (m, m.Body);
@@ -707,30 +999,98 @@ public void Send (object obj)
Send (m);
}
}
- [MonoTODO]
+
public void Send (object obj, MessageQueueTransaction transaction)
{
- throw new NotImplementedException ();
+ if (typeof (Message) == obj.GetType ()) {
+ Message m = (Message) obj;
+ if (m.BodyStream == null) {
+ IMessageFormatter f = (m.Formatter == null) ? Formatter : m.Formatter;
+ f.Write (m, m.Body);
+ }
+
+ try {
+ delegateQueue.Send (m.DelegateMessage, transaction.DelegateTx);
+ } catch (ConnectionException e) {
+ throw new MessageQueueException (MessageQueueErrorCode.QueueNotAvailable, e.Message);
+ } catch (MonoMessagingException e) {
+ throw new MessageQueueException (MessageQueueErrorCode.Generic, e.Message);
+ }
+ } else {
+ Message m = new Message (obj);
+ Send (m, transaction);
+ }
}
- [MonoTODO]
+
public void Send (object obj, MessageQueueTransactionType transactionType)
{
- throw new NotImplementedException ();
+ if (typeof (Message) == obj.GetType ()) {
+ Message m = (Message) obj;
+ if (m.BodyStream == null) {
+ IMessageFormatter f = (m.Formatter == null) ? Formatter : m.Formatter;
+ f.Write (m, m.Body);
+ }
+
+ try {
+ delegateQueue.Send (m.DelegateMessage, (Mono.Messaging.MessageQueueTransactionType) transactionType);
+ } catch (ConnectionException e) {
+ throw new MessageQueueException (MessageQueueErrorCode.QueueNotAvailable, e.Message);
+ } catch (MonoMessagingException e) {
+ throw new MessageQueueException (MessageQueueErrorCode.Generic, e.Message);
+ }
+ } else {
+ Message m = new Message (obj);
+ Send (m, transactionType);
+ }
}
- [MonoTODO]
+
public void Send (object obj, string label)
{
- throw new NotImplementedException ();
+ if (typeof (Message) == obj.GetType ()) {
+ Message m = (Message) obj;
+ m.Label = label;
+
+ Send (m);
+ } else {
+ Message m = new Message (obj);
+ Send (m, label);
+ }
}
- [MonoTODO]
+
public void Send (object obj, string label, MessageQueueTransaction transaction)
{
- throw new NotImplementedException ();
+ if (typeof (Message) == obj.GetType ()) {
+ Message m = (Message) obj;
+ m.Label = label;
+
+ if (m.BodyStream == null) {
+ IMessageFormatter f = (m.Formatter == null) ? Formatter : m.Formatter;
+ f.Write (m, m.Body);
+ }
+
+ try {
+ delegateQueue.Send (m.DelegateMessage, transaction.DelegateTx);
+ } catch (ConnectionException e) {
+ throw new MessageQueueException (MessageQueueErrorCode.QueueNotAvailable, e.Message);
+ } catch (MonoMessagingException e) {
+ throw new MessageQueueException (MessageQueueErrorCode.Generic, e.Message);
+ }
+ } else {
+ Message m = new Message (obj);
+ Send (m, label, transaction);
+ }
}
- [MonoTODO]
+
public void Send (object obj, string label, MessageQueueTransactionType transactionType)
{
- throw new NotImplementedException ();
+ if (typeof (Message) == obj.GetType ()) {
+ Message m = (Message) obj;
+ m.Label = label;
+ Send (m, transactionType);
+ } else {
+ Message m = new Message (obj);
+ Send (m, label, transactionType);
+ }
}
[MonoTODO]
public void SetPermissions (AccessControlList dacl)
@@ -770,29 +1130,29 @@ protected override void Dispose (bool disposing)
private static IMessageQueue GetMessageQueue (string path)
{
+ QueueReference qRef = QueueReference.Parse (path);
IMessageQueue q = MessagingProviderLocator
.GetProvider ()
- .GetMessageQueue ();
- q.QRef = QueueReference.Parse (path);
+ .GetMessageQueue (qRef);
return q;
}
private static IMessageQueue GetMessageQueue ()
{
return MessagingProviderLocator.GetProvider ()
- .GetMessageQueue ();
+ .GetMessageQueue (QueueReference.DEFAULT);
}
- private static IMessageQueue CreateMessageQueue (QueueReference qRef)
+ private static IMessageQueue CreateMessageQueue (QueueReference qRef,
+ bool transactional)
{
return MessagingProviderLocator.GetProvider ()
- .CreateMessageQueue (qRef);
+ .CreateMessageQueue (qRef, transactional);
}
private static bool Exists (QueueReference qRef)
{
return MessagingProviderLocator.GetProvider ().Exists (qRef);
}
-
}
}
View
104 mcs/class/System.Messaging/System.Messaging/MessageQueueTransaction.cs
@@ -28,84 +28,78 @@
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-using System;
+using System;
+
+using Mono.Messaging;
namespace System.Messaging
{
// TODO: have to comply with 'This type is safe for multithreaded operations'
public class MessageQueueTransaction : IDisposable
{
- // To avoid multiple disposals
- private bool disposed = false;
+ private readonly IMessageQueueTransaction delegateTx;
+ private readonly object syncObj = new object ();
+ private bool isDisposed = false;
- public MessageQueueTransaction()
+ public MessageQueueTransaction () : this (GetMessageQueueTransaction ())
{
- status = MessageQueueTransactionStatus.Initialized;
+ }
+
+ internal MessageQueueTransaction (IMessageQueueTransaction delegateTx)
+ {
+ this.delegateTx = delegateTx;
}
- MessageQueueTransactionStatus status;
-
public MessageQueueTransactionStatus Status
{
- get { return status; }
+ get {
+ return (MessageQueueTransactionStatus) delegateTx.Status;
+ }
+ }
+
+ internal IMessageQueueTransaction DelegateTx {
+ get { return delegateTx; }
+ }
+
+ private static IMessageQueueTransaction GetMessageQueueTransaction ()
+ {
+ return MessagingProviderLocator.GetProvider ().CreateMessageQueueTransaction ();
}
- [MonoTODO]
- public void Abort()
- {
- if (status != MessageQueueTransactionStatus.Pending)
- throw new InvalidOperationException();
- status = MessageQueueTransactionStatus.Aborted;
- throw new NotImplementedException();
+ public void Abort ()
+ {
+ delegateTx.Abort ();
}
- [MonoTODO]
- public void Begin()
- {
- if (status != MessageQueueTransactionStatus.Initialized)
- throw new InvalidOperationException();
- status = MessageQueueTransactionStatus.Pending;
- throw new NotImplementedException();
+ public void Begin ()
+ {
+ delegateTx.Begin ();
}
- [MonoTODO]
- public void Commit()
- {
- if (status != MessageQueueTransactionStatus.Pending)
- throw new InvalidOperationException();
- status = MessageQueueTransactionStatus.Committed;
- throw new NotImplementedException();
- }
-
- public virtual void Dispose()
- {
- if (status == MessageQueueTransactionStatus.Pending)
- Abort();
- // Do this only at the first time
- if (!this.disposed)
- Dispose(true);
- disposed = true;
- // Take this object off the finalization queue
- GC.SuppressFinalize(this);
+ public void Commit ()
+ {
+ delegateTx.Commit ();
}
-
- [MonoTODO]
- protected virtual void Dispose(bool disposing)
- {
- //if (disposing)
- // free managed resources, by calling dispose on them
- // free external resources
- throw new NotImplementedException();
- }
+ public void Dispose ()
+ {
+ Dispose (true);
+ GC.SuppressFinalize (this);
+ }
+
+ protected virtual void Dispose (bool disposing)
+ {
+ lock (syncObj) {
+ if (!isDisposed && disposing) {
+ delegateTx.Dispose ();
+ }
+ }
+ }
~MessageQueueTransaction()
- {
- if (status == MessageQueueTransactionStatus.Pending)
- Abort();
- if (!this.disposed)
- Dispose(false);
+ {
+ Dispose ();
}
}
}

0 comments on commit 41ca39c

Please sign in to comment.
Something went wrong with that request. Please try again.