diff options
author | Michael Barker <mike@middlesoft.co.uk> | 2009-06-03 22:57:25 +0400 |
---|---|---|
committer | Michael Barker <mike@middlesoft.co.uk> | 2009-06-03 22:57:25 +0400 |
commit | 163810f640911e93e3d49e3ef4dd0c972a166c62 (patch) | |
tree | 1e136cc8c02f8fc8884526ad41f6b9af14d55fa2 /mcs | |
parent | 9a2c3234082cf2812da315a4fa58d73b6e2261f4 (diff) |
2009-05-23 Michael Barker <mike@middlesoft.co.uk>
* MessageEnumerator.cs: Added calls to the delegate IMessageEnumerator
for methods that use a timeout and added exception handling.
* MessageEnumeratorTest.cs: Added tests for timeout methods.
* MessageFactory.cs: Moved TimeSpanToInt32 method to here.
* RabbitMQMessageEnumerator.cs: Added Remove/MoveNext methods that include
timeouts.
* RabbitMQMessageQueue.cs: Updated to cater for moved TimeSpanToInt32 method
* MessageEnumeratorExceptionTest.cs: New
* QueueReferenceTest.cs: Incorrect namespace for test
* IMessageEnumerator.cs: Added additional methods to support operations
specified by the System.Messaging version.
* Mono.Messaging_test.dll.sources: Added MessageEnumeratorExceptionTest.cs
* Makefile: Added nunit-mocks.dll to build
svn path=/trunk/mcs/; revision=135338
Diffstat (limited to 'mcs')
15 files changed, 343 insertions, 71 deletions
diff --git a/mcs/class/Mono.Messaging.RabbitMQ/Mono.Messaging.RabbitMQ/ChangeLog b/mcs/class/Mono.Messaging.RabbitMQ/Mono.Messaging.RabbitMQ/ChangeLog index 7cefeaa3aec..c2caba20d62 100644 --- a/mcs/class/Mono.Messaging.RabbitMQ/Mono.Messaging.RabbitMQ/ChangeLog +++ b/mcs/class/Mono.Messaging.RabbitMQ/Mono.Messaging.RabbitMQ/ChangeLog @@ -1,3 +1,19 @@ +2009-05-23 Michael Barker <mike@middlesoft.co.uk> + + * MessageFactory.cs: Moved TimeSpanToInt32 method to here. + * RabbitMQMessageEnumerator.cs: Added Remove/MoveNext methods that include + timeouts. + * RabbitMQMessageQueue.cs: Updated to cater for moved TimeSpanToInt32 method + +2009-05-20 Michael Barker <mike@middlesoft.co.uk> + + * RabbitMQMessageEnumerator.cs: Removed references to realms & tickets. + * RabbitMQMessageQueue.cs: Removed references to realms & tickets. + +2009-05-19 Michael Barker <mike@middlesoft.co.uk> + + * RabbitMQMessageQueue.cs: Added comments. + 2008-12-22 Michael Barker <mike@middlesoft.co.uk> * RabbitMQMessageQueue.cs: Changed to extend MessageQueueBase to make use @@ -44,12 +60,3 @@ * RabbitMQMessageQueue.cs: New * RabbitMQMessagingProvider.cs: New - -2009-05-19 Michael Barker <mike@middlesoft.co.uk> - - * RabbitMQMessageQueue.cs: Added comments. - -2009-05-20 Michael Barker <mike@middlesoft.co.uk> - - * RabbitMQMessageEnumerator.cs: Removed references to realms & tickets. - * RabbitMQMessageQueue.cs: Removed references to realms & tickets.
\ No newline at end of file diff --git a/mcs/class/Mono.Messaging.RabbitMQ/Mono.Messaging.RabbitMQ/MessageFactory.cs b/mcs/class/Mono.Messaging.RabbitMQ/Mono.Messaging.RabbitMQ/MessageFactory.cs index e48da2ca2ba..cdf57dd7d6a 100644 --- a/mcs/class/Mono.Messaging.RabbitMQ/Mono.Messaging.RabbitMQ/MessageFactory.cs +++ b/mcs/class/Mono.Messaging.RabbitMQ/Mono.Messaging.RabbitMQ/MessageFactory.cs @@ -219,6 +219,13 @@ namespace Mono.Messaging.RabbitMQ { DateTime epoch = new DateTime(1970, 1, 1, 0, 0, 0, 0); return epoch.AddSeconds (ats.UnixTime).ToLocalTime (); } - + + public static int TimeSpanToInt32 (TimeSpan timespan) + { + if (timespan == TimeSpan.MaxValue) + return -1; + else + return (int) timespan.TotalMilliseconds; + } } } diff --git a/mcs/class/Mono.Messaging.RabbitMQ/Mono.Messaging.RabbitMQ/RabbitMQMessageEnumerator.cs b/mcs/class/Mono.Messaging.RabbitMQ/Mono.Messaging.RabbitMQ/RabbitMQMessageEnumerator.cs index 93be9fd83fe..1a05d371465 100644 --- a/mcs/class/Mono.Messaging.RabbitMQ/Mono.Messaging.RabbitMQ/RabbitMQMessageEnumerator.cs +++ b/mcs/class/Mono.Messaging.RabbitMQ/Mono.Messaging.RabbitMQ/RabbitMQMessageEnumerator.cs @@ -65,6 +65,10 @@ namespace Mono.Messaging.RabbitMQ { } } + public IntPtr CursorHandle { + get { throw new NotImplementedException (); } + } + public void Close () { if (subscription != null) { @@ -117,7 +121,6 @@ namespace Mono.Messaging.RabbitMQ { if (subscription == null) { IModel ch = Model; - //ushort ticket = ch.AccessRequest ("/data"); string finalName = ch.QueueDeclare (qRef.Queue, false); subscription = new Subscription (ch, finalName); @@ -132,6 +135,12 @@ namespace Mono.Messaging.RabbitMQ { Subscription sub = Subscription; return sub.Next (500, out current); } + + public bool MoveNext (TimeSpan timeout) + { + int to = MessageFactory.TimeSpanToInt32 (timeout); + return Subscription.Next (to, out current); + } public IMessage RemoveCurrent () { @@ -153,6 +162,29 @@ namespace Mono.Messaging.RabbitMQ { throw new NotSupportedException ("Unable to remove messages within a transaction"); } + public IMessage RemoveCurrent (TimeSpan timeout) + { + // Timeout makes no sense for this implementation, so we just work + // the same as the non-timeout based one. + + if (current == null) + throw new InvalidOperationException (); + + IMessage msg = CreateMessage (current); + Subscription.Ack (current); + return msg; + } + + public IMessage RemoveCurrent (TimeSpan timeout, IMessageQueueTransaction transaction) + { + throw new NotImplementedException (); + } + + public IMessage RemoveCurrent (TimeSpan timeout, MessageQueueTransactionType transactionType) + { + throw new NotImplementedException (); + } + private IMessage CreateMessage (BasicDeliverEventArgs result) { return helper.ReadMessage (qRef, result); diff --git a/mcs/class/Mono.Messaging.RabbitMQ/Mono.Messaging.RabbitMQ/RabbitMQMessageQueue.cs b/mcs/class/Mono.Messaging.RabbitMQ/Mono.Messaging.RabbitMQ/RabbitMQMessageQueue.cs index ea35c687760..ef2f6461df1 100644 --- a/mcs/class/Mono.Messaging.RabbitMQ/Mono.Messaging.RabbitMQ/RabbitMQMessageQueue.cs +++ b/mcs/class/Mono.Messaging.RabbitMQ/Mono.Messaging.RabbitMQ/RabbitMQMessageQueue.cs @@ -590,7 +590,7 @@ namespace Mono.Messaging.RabbitMQ { private static TxReceiver.DoReceive Receiver (TimeSpan timeout, IsMatch matcher) { - int to = TimeSpanToInt32 (timeout); + int to = MessageFactory.TimeSpanToInt32 (timeout); return new DoReceiveWithTimeout (to, matcher).DoReceive; } @@ -601,7 +601,7 @@ namespace Mono.Messaging.RabbitMQ { private static TxReceiver.DoReceive Receiver (TimeSpan timeout) { - int to = TimeSpanToInt32 (timeout); + int to = MessageFactory.TimeSpanToInt32 (timeout); return new DoReceiveWithTimeout (to, null).DoReceive; } @@ -617,7 +617,7 @@ namespace Mono.Messaging.RabbitMQ { private TxReceiver.DoReceive Peeker (TimeSpan timeout) { - int to = TimeSpanToInt32 (timeout); + int to = MessageFactory.TimeSpanToInt32 (timeout); return new DoReceiveWithTimeout (to, null, false).DoReceive; } @@ -628,7 +628,7 @@ namespace Mono.Messaging.RabbitMQ { private TxReceiver.DoReceive Peeker (TimeSpan timeout, IsMatch matcher) { - int to = TimeSpanToInt32 (timeout); + int to = MessageFactory.TimeSpanToInt32 (timeout); return new DoReceiveWithTimeout (to, matcher, false).DoReceive; } @@ -714,13 +714,5 @@ namespace Mono.Messaging.RabbitMQ { { return (RabbitMQMessageQueueTransaction) provider.CreateMessageQueueTransaction (); } - - private static int TimeSpanToInt32 (TimeSpan timespan) - { - if (timespan == TimeSpan.MaxValue) - return -1; - else - return (int) timespan.TotalMilliseconds; - } } } diff --git a/mcs/class/Mono.Messaging.RabbitMQ/Test/Mono.Messaging.RabbitMQ/ChangeLog b/mcs/class/Mono.Messaging.RabbitMQ/Test/Mono.Messaging.RabbitMQ/ChangeLog index 852578cde3f..8de774bbb81 100644 --- a/mcs/class/Mono.Messaging.RabbitMQ/Test/Mono.Messaging.RabbitMQ/ChangeLog +++ b/mcs/class/Mono.Messaging.RabbitMQ/Test/Mono.Messaging.RabbitMQ/ChangeLog @@ -1,3 +1,7 @@ +2009-05-23 Michael Barker <mike@middlesoft.co.uk> + + * MessageEnumeratorTest.cs: Added tests for timeout methods. + 2009-01-05 Michael Barker <mike@middlesoft.co.uk> * BinaryMessageFormatter.cs, XMLMessageFormatterTest.cs, TestUtils.cs, diff --git a/mcs/class/Mono.Messaging.RabbitMQ/Test/Mono.Messaging.RabbitMQ/MessageEnumeratorTest.cs b/mcs/class/Mono.Messaging.RabbitMQ/Test/Mono.Messaging.RabbitMQ/MessageEnumeratorTest.cs index ee76fb0f8cf..5535dd7efa3 100644 --- a/mcs/class/Mono.Messaging.RabbitMQ/Test/Mono.Messaging.RabbitMQ/MessageEnumeratorTest.cs +++ b/mcs/class/Mono.Messaging.RabbitMQ/Test/Mono.Messaging.RabbitMQ/MessageEnumeratorTest.cs @@ -87,6 +87,45 @@ namespace MonoTests.Mono.Messaging.RabbitMQ MessageQueue.Delete (qName); } + [Test] + public void RemoveMessageWithTimeout () + { + SendMessage ("message 1"); + SendMessage ("message 2"); + SendMessage ("message 3"); + SendMessage ("message 4"); + + MessageQueue mq0 = MQUtil.GetQueue (qName); + MessageEnumerator me0 = mq0.GetMessageEnumerator (); + + TimeSpan ts = new TimeSpan (0, 0, 2); + + me0.MoveNext (ts); + me0.MoveNext (ts); + me0.MoveNext (ts); + + Message m0 = me0.RemoveCurrent (ts); + + me0.MoveNext (ts); + + me0.Dispose (); + mq0.Dispose (); + + MessageQueue mq1 = MQUtil.GetQueue (qName); + MessageEnumerator me1 = mq1.GetMessageEnumerator (); + + me1.MoveNext (ts); + me1.MoveNext (ts); + me1.MoveNext (ts); + + Message m1 = me1.Current; + m1.Formatter = new BinaryMessageFormatter (); + Assert.AreEqual ("message 4", (String) m1.Body, "body incorrect"); + + mq1.Purge (); + MessageQueue.Delete (qName); + } + //[Test] // Not supported with AMQP public void RemoveMessageWithTx () diff --git a/mcs/class/Mono.Messaging/ChangeLog b/mcs/class/Mono.Messaging/ChangeLog index bbe8bc78fa0..9cfd069df5f 100644 --- a/mcs/class/Mono.Messaging/ChangeLog +++ b/mcs/class/Mono.Messaging/ChangeLog @@ -1,3 +1,8 @@ +2009-05-23 Michael Barker <mike@middlesoft.co.uk> + + * Mono.Messaging_test.dll.sources: Added MessageEnumeratorExceptionTest.cs + * Makefile: Added nunit-mocks.dll to build + 2008-12-30 Raja R Harinath <harinath@hurrynot.org> * Makefile (TEST_MCS_FLAGS): Reference System.Messaging.dll. diff --git a/mcs/class/Mono.Messaging/Makefile b/mcs/class/Mono.Messaging/Makefile index cfcb60e658d..bfc99895c79 100644 --- a/mcs/class/Mono.Messaging/Makefile +++ b/mcs/class/Mono.Messaging/Makefile @@ -5,6 +5,6 @@ include ../../build/rules.make LIBRARY = Mono.Messaging.dll LIB_MCS_FLAGS = /r:System.dll -TEST_MCS_FLAGS = $(LIB_MCS_FLAGS) -nowarn:0618 -nowarn:219 -nowarn:169 -r:System.Messaging.dll +TEST_MCS_FLAGS = $(LIB_MCS_FLAGS) -nowarn:0618 -nowarn:219 -nowarn:169 /r:System.Messaging.dll /r:nunit.mocks.dll include ../../build/library.make diff --git a/mcs/class/Mono.Messaging/Mono.Messaging/ChangeLog b/mcs/class/Mono.Messaging/Mono.Messaging/ChangeLog index 023c690a8f5..38bd62f9ae2 100644 --- a/mcs/class/Mono.Messaging/Mono.Messaging/ChangeLog +++ b/mcs/class/Mono.Messaging/Mono.Messaging/ChangeLog @@ -1,3 +1,15 @@ +2009-05-23 Michael Barker <mike@middlesoft.co.uk> + + * IMessageEnumerator.cs: Added additional methods to support operations + specified by the System.Messaging version. + +2009-05-19 Michael Barker <mike@middlesoft.co.uk> + + * IMessage.cs: Added additional comments. + * IMessagingProvider.cs: Added additional comments. + * MessagingProviderLocator.cs: Added support for specifing messaging + implementation using an environment variable. + 2009-01-03 Michael Barker <mike@middlesoft.co.uk> * MessageQueueBase.cs: Added support for handling exception asynchronously. @@ -67,11 +79,4 @@ * MessageType.cs: New * MessagingProviderLocator.cs: New * MonoMessagingException.cs: New - * QueueReference.cs: New - -2009-05-19 Michael Barker <mike@middlesoft.co.uk> - - * IMessage.cs: Added additional comments. - * IMessagingProvider.cs: Added additional comments. - * MessagingProviderLocator.cs: Added support for specifing messaging - implementation using an environment variable.
\ No newline at end of file + * QueueReference.cs: New
\ No newline at end of file diff --git a/mcs/class/Mono.Messaging/Mono.Messaging/IMessageEnumerator.cs b/mcs/class/Mono.Messaging/Mono.Messaging/IMessageEnumerator.cs index 07dccbfbdd0..9977c55d669 100644 --- a/mcs/class/Mono.Messaging/Mono.Messaging/IMessageEnumerator.cs +++ b/mcs/class/Mono.Messaging/Mono.Messaging/IMessageEnumerator.cs @@ -38,13 +38,15 @@ namespace Mono.Messaging { IMessage Current { get; } + IntPtr CursorHandle { get; } + void Close(); void Dispose(bool disposing); bool MoveNext(); - //bool MoveNext(TimeSpan timeout); + bool MoveNext(TimeSpan timeout); IMessage RemoveCurrent(); @@ -52,11 +54,11 @@ namespace Mono.Messaging { IMessage RemoveCurrent(MessageQueueTransactionType transactionType); - //IMessage RemoveCurrent(TimeSpan timeout); + IMessage RemoveCurrent(TimeSpan timeout); - //IMessage RemoveCurrent(TimeSpan timeout, MessageQueueTransaction transaction); + IMessage RemoveCurrent(TimeSpan timeout, IMessageQueueTransaction transaction); - //IMessage RemoveCurrent(TimeSpan timeout, MessageQueueTransactionType transactionType); + IMessage RemoveCurrent(TimeSpan timeout, MessageQueueTransactionType transactionType); } diff --git a/mcs/class/Mono.Messaging/Mono.Messaging_test.dll.sources b/mcs/class/Mono.Messaging/Mono.Messaging_test.dll.sources index 53a0d0af1ee..d5bfcb3a87e 100644 --- a/mcs/class/Mono.Messaging/Mono.Messaging_test.dll.sources +++ b/mcs/class/Mono.Messaging/Mono.Messaging_test.dll.sources @@ -1,2 +1,3 @@ Mono.Messaging/MessageBaseTest.cs +Mono.Messaging/MessageEnumeratorExceptionTest.cs Mono.Messaging/QueueReferenceTest.cs
\ No newline at end of file diff --git a/mcs/class/Mono.Messaging/Test/Mono.Messaging/ChangeLog b/mcs/class/Mono.Messaging/Test/Mono.Messaging/ChangeLog index 6a6b2a04b2d..76e40f0761b 100644 --- a/mcs/class/Mono.Messaging/Test/Mono.Messaging/ChangeLog +++ b/mcs/class/Mono.Messaging/Test/Mono.Messaging/ChangeLog @@ -1,12 +1,16 @@ -2008-09-29 Michael Barker <mike@middlesoft.co.uk> +2009-05-23 Michael Barker <mike@middlesoft.co.uk> - * MessageBaseTest.cs: New - * QueueReferenceTest.cs: New + * MessageEnumeratorExceptionTest.cs: New + +2009-05-23 Michael Barker <mike@middlesoft.co.uk> + * QueueReferenceTest.cs: Incorrect namespace for test + 2009-05-19 Michael Barker <mike@middlesoft.co.uk> * MessageBaseTest.cs: Used reflection to create Message Object -2009-05-23 Michael Barker <mike@middlesoft.co.uk> +2008-09-29 Michael Barker <mike@middlesoft.co.uk> - * QueueReferenceTest.cs: Incorrect namespace for test
\ No newline at end of file + * MessageBaseTest.cs: New + * QueueReferenceTest.cs: New
\ No newline at end of file diff --git a/mcs/class/Mono.Messaging/Test/Mono.Messaging/MessageEnumeratorExceptionTest.cs b/mcs/class/Mono.Messaging/Test/Mono.Messaging/MessageEnumeratorExceptionTest.cs new file mode 100644 index 00000000000..36edde5d52e --- /dev/null +++ b/mcs/class/Mono.Messaging/Test/Mono.Messaging/MessageEnumeratorExceptionTest.cs @@ -0,0 +1,105 @@ +//
+// MessageEnumeratorTest.cs -
+// NUnit Test Cases for MessageEnumerator
+//
+// Author:
+// Michael Barker <mike@middlesoft.co.uk>
+//
+// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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.Security;
+using System.Security.Permissions; +using System.Reflection; + +using Mono.Messaging; + +using NUnit.Framework; +using NUnit.Mocks;
+
+
+namespace MonoTests.Mono.Messaging {
+ + [TestFixture]
+ public class MessageEnumeratorExceptionTest + { + private DynamicMock mockME; + + [SetUp] + public void Init () + { + mockME = new DynamicMock (typeof (IMessageEnumerator)); + } + + [Test] + [ExpectedException("System.Messaging.MessageQueueException")] + public void RemoveCurrentThrowsConnectionException () + { + mockME.ExpectAndThrow ("RemoveCurrent", new ConnectionException (QueueReference.DEFAULT), null); + System.Messaging.MessageEnumerator me = CreateEnumerator ((IMessageEnumerator) mockME.MockInstance); + me.RemoveCurrent (); + } + + [Test] + [ExpectedException("System.InvalidOperationException")] + public void RemoveCurrentThrowsMessageUnavailableException () + { + mockME.ExpectAndThrow ("RemoveCurrent", new MessageUnavailableException (), null); + System.Messaging.MessageEnumerator me = CreateEnumerator ((IMessageEnumerator) mockME.MockInstance); + me.RemoveCurrent (); + } + + [Test] + [ExpectedException("System.Messaging.MessageQueueException")] + public void RemoveCurrentThrowsMonoMessagingException () + { + mockME.ExpectAndThrow ("RemoveCurrent", new MonoMessagingException (), null); + System.Messaging.MessageEnumerator me = CreateEnumerator ((IMessageEnumerator) mockME.MockInstance); + me.RemoveCurrent (); + } + + [Test] + [ExpectedException("System.NotImplementedException")] + public void RemoveCurrentThrowsMessageNotImplemented () + { + mockME.ExpectAndThrow ("RemoveCurrent", new NotImplementedException (), null); + System.Messaging.MessageEnumerator me = CreateEnumerator ((IMessageEnumerator) mockME.MockInstance); + me.RemoveCurrent (); + } + + public System.Messaging.MessageEnumerator CreateEnumerator (IMessageEnumerator ime) + { + Type[] types = { + typeof (IMessageEnumerator), typeof (System.Messaging.IMessageFormatter) + }; + + ConstructorInfo ci = typeof (System.Messaging.MessageEnumerator).GetConstructor ( + BindingFlags.NonPublic | BindingFlags.Instance, + Type.DefaultBinder, types, new ParameterModifier[0]); + + if (ci == null) + throw new Exception ("ConstructorInfo is null"); + + return (System.Messaging.MessageEnumerator) ci.Invoke (new object[] { ime, null }); + } + } +} diff --git a/mcs/class/System.Messaging/System.Messaging/ChangeLog b/mcs/class/System.Messaging/System.Messaging/ChangeLog index dd0a6207bc7..4b2c8833b08 100644 --- a/mcs/class/System.Messaging/System.Messaging/ChangeLog +++ b/mcs/class/System.Messaging/System.Messaging/ChangeLog @@ -1,3 +1,8 @@ +2009-05-23 Michael Barker <mike@middlesoft.co.uk> + + * MessageEnumerator.cs: Added calls to the delegate IMessageEnumerator + for methods that use a timeout and added exception handling. + 2008-12-20 Michael Barker <mike@middlesoft.co.uk> * MessageQueue.cs: Added implementation for async methods: BeginReceive, diff --git a/mcs/class/System.Messaging/System.Messaging/MessageEnumerator.cs b/mcs/class/System.Messaging/System.Messaging/MessageEnumerator.cs index a890b5ec8bd..b52231ebb9f 100644 --- a/mcs/class/System.Messaging/System.Messaging/MessageEnumerator.cs +++ b/mcs/class/System.Messaging/System.Messaging/MessageEnumerator.cs @@ -3,6 +3,7 @@ // // Authors: // Peter Van Isacker (sclytrack@planetinternet.be) +// Michael Barker (mike@middlesoft.co.uk) // // (C) 2003 Peter Van Isacker // @@ -61,8 +62,7 @@ namespace System.Messaging } public IntPtr CursorHandle { - [MonoTODO] - get {throw new NotImplementedException();} + get { return delegateEnumerator.CursorHandle; } } public void Close() @@ -87,58 +87,122 @@ namespace System.Messaging { return delegateEnumerator.MoveNext (); } - [MonoTODO] - public bool MoveNext(TimeSpan timeout) + + public bool MoveNext (TimeSpan timeout) { - throw new NotImplementedException(); + return delegateEnumerator.MoveNext (timeout); } - + public Message RemoveCurrent() { - IMessage iMsg = delegateEnumerator.RemoveCurrent (); - if (iMsg == null) - return null; - return new Message (iMsg, null, formatter); + try { + IMessage iMsg = delegateEnumerator.RemoveCurrent (); + 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); + } } public Message RemoveCurrent (MessageQueueTransaction transaction) { - - IMessage iMsg = delegateEnumerator.RemoveCurrent (transaction.DelegateTx); - if (iMsg == null) - return null; - return new Message (iMsg, null, formatter); + try { + IMessage iMsg = delegateEnumerator.RemoveCurrent (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); + } } public Message RemoveCurrent(MessageQueueTransactionType transactionType) { - IMessage iMsg = delegateEnumerator.RemoveCurrent ((Mono.Messaging.MessageQueueTransactionType) transactionType); - if (iMsg == null) - return null; - return new Message (iMsg, null, formatter); + try { + IMessage iMsg = delegateEnumerator.RemoveCurrent ((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 RemoveCurrent(TimeSpan timeout) + + public Message RemoveCurrent (TimeSpan timeout) { - throw new NotImplementedException(); + try { + IMessage iMsg = delegateEnumerator.RemoveCurrent (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 RemoveCurrent(TimeSpan timeout, MessageQueueTransaction transaction) + + public Message RemoveCurrent (TimeSpan timeout, + MessageQueueTransaction transaction) { - throw new NotImplementedException(); + try { + IMessage iMsg = delegateEnumerator.RemoveCurrent (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 RemoveCurrent(TimeSpan timeout, MessageQueueTransactionType transactionType) + + public Message RemoveCurrent (TimeSpan timeout, MessageQueueTransactionType transactionType) { - throw new NotImplementedException(); + try { + IMessage iMsg = delegateEnumerator.RemoveCurrent (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 Reset() { Close (); } - [MonoTODO] ~MessageEnumerator() { Dispose(false); |