You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2017/03/07 19:39:29 UTC
[49/50] [abbrv] activemq-nms-msmq git commit: Apply patch for
AMQNET-556 from Stephane Ramet. Thanks Stephane!
http://git-wip-us.apache.org/repos/asf/activemq-nms-msmq/blob/7274a80a/src/main/csharp/Readers/ByIdMessageReader.cs
----------------------------------------------------------------------
diff --git a/src/main/csharp/Readers/ByIdMessageReader.cs b/src/main/csharp/Readers/ByIdMessageReader.cs
index f981ca8..6a544f4 100644
--- a/src/main/csharp/Readers/ByIdMessageReader.cs
+++ b/src/main/csharp/Readers/ByIdMessageReader.cs
@@ -1,136 +1,136 @@
-using System;
-using System.Messaging;
-using Apache.NMS.MSMQ;
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.NMS.MSMQ.Readers
-{
- /// <summary>
- /// MSMQ message reader, returning messages matching the specified
- /// message identifier.
- /// </summary>
- public class ByIdMessageReader : AbstractMessageReader
- {
- private string messageId;
-
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="messageQueue">The MSMQ message queue from which
- /// messages will be read.</param>
- /// <param name="messageConverter">A message converter for mapping
- /// MSMQ messages to NMS messages.</param>
- /// <param name="messageId">The message identifier of messages to
- /// be read.</param>
- public ByIdMessageReader(MessageQueue messageQueue,
- IMessageConverter messageConverter, string messageId)
- : base(messageQueue, messageConverter)
- {
- this.messageId = messageId;
- }
-
- /// <summary>
- /// Returns without removing (peeks) the first message in the queue
- /// referenced by this MessageQueue matching the selection criteria.
- /// The Peek method is synchronous, so it blocks the current thread
- /// until a message becomes available.
- /// </summary>
- /// <returns>Peeked message.</returns>
- public override IMessage Peek()
- {
- return Convert(messageQueue.PeekById(messageId));
- }
-
- /// <summary>
- /// Returns without removing (peeks) the first message in the queue
- /// referenced by this MessageQueue matching the selection criteria.
- /// The Peek method is synchronous, so it blocks the current thread
- /// until a message becomes available or the specified time-out occurs.
- /// </summary>
- /// <param name="timeSpan">Reception time-out.</param>
- /// <returns>Peeked message.</returns>
- public override IMessage Peek(TimeSpan timeSpan)
- {
- return Convert(messageQueue.PeekById(messageId, timeSpan));
- }
-
- /// <summary>
- /// Receives the first message available in the queue referenced by
- /// the MessageQueue matching the selection criteria.
- /// This call is synchronous, and blocks the current thread of execution
- /// until a message is available.
- /// </summary>
- /// <returns>Received message.</returns>
- public override IMessage Receive()
- {
- return Convert(messageQueue.ReceiveById(messageId));
- }
-
- /// <summary>
- /// Receives the first message available in the queue referenced by the
- /// MessageQueue matching the selection criteria, and waits until either
- /// a message is available in the queue, or the time-out expires.
- /// </summary>
- /// <param name="timeSpan">Reception time-out.</param>
- /// <returns>Received message.</returns>
- public override IMessage Receive(TimeSpan timeSpan)
- {
- return Convert(messageQueue.ReceiveById(messageId, timeSpan));
- }
-
- /// <summary>
- /// Receives the first message available in the transactional queue
- /// referenced by the MessageQueue matching the selection criteria.
- /// This call is synchronous, and blocks the current thread of execution
- /// until a message is available.
- /// </summary>
- /// <param name="transaction">Transaction.</param>
- /// <returns>Received message.</returns>
- public override IMessage Receive(MessageQueueTransaction transaction)
- {
- return Convert(messageQueue.ReceiveById(messageId, transaction));
- }
-
- /// <summary>
- /// Receives the first message available in the transactional queue
- /// referenced by the MessageQueue matching the selection criteria,
- /// and waits until either a message is available in the queue, or the
- /// time-out expires.
- /// </summary>
- /// <param name="timeSpan">Reception time-out.</param>
- /// <param name="transaction">Transaction.</param>
- /// <returns>Received message.</returns>
- public override IMessage Receive(TimeSpan timeSpan,
- MessageQueueTransaction transaction)
- {
- return Convert(messageQueue.ReceiveById(messageId, timeSpan,
- transaction));
- }
-
- /// <summary>
- /// Checks if an MSMQ message matches the selection criteria.
- /// </summary>
- /// <param name="message">MSMQ message.</param>
- /// <return>true if the message matches the selection criteria.</return>
- public override bool Matches(Message message)
- {
- // NB: case-sensitive match
- return message.Id == messageId;
- }
- }
-}
+using System;
+using System.Messaging;
+using Apache.NMS.MSMQ;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.NMS.MSMQ.Readers
+{
+ /// <summary>
+ /// MSMQ message reader, returning messages matching the specified
+ /// message identifier.
+ /// </summary>
+ public class ByIdMessageReader : AbstractMessageReader
+ {
+ private string messageId;
+
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="messageQueue">The MSMQ message queue from which
+ /// messages will be read.</param>
+ /// <param name="messageConverter">A message converter for mapping
+ /// MSMQ messages to NMS messages.</param>
+ /// <param name="messageId">The message identifier of messages to
+ /// be read.</param>
+ public ByIdMessageReader(MessageQueue messageQueue,
+ IMessageConverter messageConverter, string messageId)
+ : base(messageQueue, messageConverter)
+ {
+ this.messageId = messageId;
+ }
+
+ /// <summary>
+ /// Returns without removing (peeks) the first message in the queue
+ /// referenced by this MessageQueue matching the selection criteria.
+ /// The Peek method is synchronous, so it blocks the current thread
+ /// until a message becomes available.
+ /// </summary>
+ /// <returns>Peeked message.</returns>
+ public override IMessage Peek()
+ {
+ return Convert(messageQueue.PeekById(messageId));
+ }
+
+ /// <summary>
+ /// Returns without removing (peeks) the first message in the queue
+ /// referenced by this MessageQueue matching the selection criteria.
+ /// The Peek method is synchronous, so it blocks the current thread
+ /// until a message becomes available or the specified time-out occurs.
+ /// </summary>
+ /// <param name="timeSpan">Reception time-out.</param>
+ /// <returns>Peeked message.</returns>
+ public override IMessage Peek(TimeSpan timeSpan)
+ {
+ return Convert(messageQueue.PeekById(messageId, timeSpan));
+ }
+
+ /// <summary>
+ /// Receives the first message available in the queue referenced by
+ /// the MessageQueue matching the selection criteria.
+ /// This call is synchronous, and blocks the current thread of execution
+ /// until a message is available.
+ /// </summary>
+ /// <returns>Received message.</returns>
+ public override IMessage Receive()
+ {
+ return Convert(messageQueue.ReceiveById(messageId));
+ }
+
+ /// <summary>
+ /// Receives the first message available in the queue referenced by the
+ /// MessageQueue matching the selection criteria, and waits until either
+ /// a message is available in the queue, or the time-out expires.
+ /// </summary>
+ /// <param name="timeSpan">Reception time-out.</param>
+ /// <returns>Received message.</returns>
+ public override IMessage Receive(TimeSpan timeSpan)
+ {
+ return Convert(messageQueue.ReceiveById(messageId, timeSpan));
+ }
+
+ /// <summary>
+ /// Receives the first message available in the transactional queue
+ /// referenced by the MessageQueue matching the selection criteria.
+ /// This call is synchronous, and blocks the current thread of execution
+ /// until a message is available.
+ /// </summary>
+ /// <param name="transaction">Transaction.</param>
+ /// <returns>Received message.</returns>
+ public override IMessage Receive(MessageQueueTransaction transaction)
+ {
+ return Convert(messageQueue.ReceiveById(messageId, transaction));
+ }
+
+ /// <summary>
+ /// Receives the first message available in the transactional queue
+ /// referenced by the MessageQueue matching the selection criteria,
+ /// and waits until either a message is available in the queue, or the
+ /// time-out expires.
+ /// </summary>
+ /// <param name="timeSpan">Reception time-out.</param>
+ /// <param name="transaction">Transaction.</param>
+ /// <returns>Received message.</returns>
+ public override IMessage Receive(TimeSpan timeSpan,
+ MessageQueueTransaction transaction)
+ {
+ return Convert(messageQueue.ReceiveById(messageId, timeSpan,
+ transaction));
+ }
+
+ /// <summary>
+ /// Checks if an MSMQ message matches the selection criteria.
+ /// </summary>
+ /// <param name="message">MSMQ message.</param>
+ /// <return>true if the message matches the selection criteria.</return>
+ public override bool Matches(Message message)
+ {
+ // NB: case-sensitive match
+ return message.Id == messageId;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/activemq-nms-msmq/blob/7274a80a/src/main/csharp/Readers/ByLookupIdMessageReader.cs
----------------------------------------------------------------------
diff --git a/src/main/csharp/Readers/ByLookupIdMessageReader.cs b/src/main/csharp/Readers/ByLookupIdMessageReader.cs
index 421c52b..423c3a7 100644
--- a/src/main/csharp/Readers/ByLookupIdMessageReader.cs
+++ b/src/main/csharp/Readers/ByLookupIdMessageReader.cs
@@ -1,145 +1,215 @@
-using System;
-using System.Messaging;
-using Apache.NMS.MSMQ;
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.NMS.MSMQ.Readers
-{
- /// <summary>
- /// MSMQ message reader, returning messages matching the specified
- /// lookup identifier.
- /// </summary>
- public class ByLookupIdMessageReader : AbstractMessageReader
- {
- private Int64 lookupId;
-
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="messageQueue">The MSMQ message queue from which
- /// messages will be read.</param>
- /// <param name="messageConverter">A message converter for mapping
- /// MSMQ messages to NMS messages.</param>
- /// <param name="lookupId">The lookup identifier of the message
- /// to be read.</param>
- public ByLookupIdMessageReader(MessageQueue messageQueue,
- IMessageConverter messageConverter, Int64 lookupId)
- : base(messageQueue, messageConverter)
- {
- this.lookupId = lookupId;
- }
-
- /// <summary>
- /// Returns without removing (peeks) the first message in the queue
- /// referenced by this MessageQueue matching the selection criteria.
- /// The Peek method is synchronous, so it blocks the current thread
- /// until a message becomes available.
- /// </summary>
- /// <returns>Peeked message.</returns>
- public override IMessage Peek()
- {
- return Convert(messageQueue.PeekByLookupId(lookupId));
- }
-
- /// <summary>
- /// Returns without removing (peeks) the first message in the queue
- /// referenced by this MessageQueue matching the selection criteria.
- /// The Peek method is synchronous, so it blocks the current thread
- /// until a message becomes available or the specified time-out occurs.
- /// </summary>
- /// <param name="timeSpan">Reception time-out.</param>
- /// <returns>Peeked message.</returns>
- public override IMessage Peek(TimeSpan timeSpan)
- {
- // No time-out option for receiving messages by lookup identifiers:
- // either the message is present in the queue, or the method throws
- // an exception immediately if the message is not in the queue.
- return Convert(messageQueue.PeekByLookupId(lookupId));
- }
-
- /// <summary>
- /// Receives the first message available in the queue referenced by
- /// the MessageQueue matching the selection criteria.
- /// This call is synchronous, and blocks the current thread of execution
- /// until a message is available.
- /// </summary>
- /// <returns>Received message.</returns>
- public override IMessage Receive()
- {
- return Convert(messageQueue.ReceiveByLookupId(lookupId));
- }
-
- /// <summary>
- /// Receives the first message available in the queue referenced by the
- /// MessageQueue matching the selection criteria, and waits until either
- /// a message is available in the queue, or the time-out expires.
- /// </summary>
- /// <param name="timeSpan">Reception time-out.</param>
- /// <returns>Received message.</returns>
- public override IMessage Receive(TimeSpan timeSpan)
- {
- // No time-out option for receiving messages by lookup identifiers:
- // either the message is present in the queue, or the method throws
- // an exception immediately if the message is not in the queue.
- return Convert(messageQueue.ReceiveByLookupId(lookupId));
- }
-
- /// <summary>
- /// Receives the first message available in the transactional queue
- /// referenced by the MessageQueue matching the selection criteria.
- /// This call is synchronous, and blocks the current thread of execution
- /// until a message is available.
- /// </summary>
- /// <param name="transaction">Transaction.</param>
- /// <returns>Received message.</returns>
- public override IMessage Receive(MessageQueueTransaction transaction)
- {
- return Convert(messageQueue.ReceiveByLookupId(
- MessageLookupAction.Current, lookupId, transaction));
- }
-
- /// <summary>
- /// Receives the first message available in the transactional queue
- /// referenced by the MessageQueue matching the selection criteria,
- /// and waits until either a message is available in the queue, or the
- /// time-out expires.
- /// </summary>
- /// <param name="timeSpan">Reception time-out.</param>
- /// <param name="transaction">Transaction.</param>
- /// <returns>Received message.</returns>
- public override IMessage Receive(TimeSpan timeSpan,
- MessageQueueTransaction transaction)
- {
- // No time-out option for receiving messages by lookup identifiers:
- // either the message is present in the queue, or the method throws
- // an exception immediately if the message is not in the queue.
- return Convert(messageQueue.ReceiveByLookupId(
- MessageLookupAction.Current, lookupId, transaction));
- }
-
- /// <summary>
- /// Checks if an MSMQ message matches the selection criteria.
- /// </summary>
- /// <param name="message">MSMQ message.</param>
- /// <return>true if the message matches the selection criteria.</return>
- public override bool Matches(Message message)
- {
- return message.LookupId == lookupId;
- }
- }
-}
+using System;
+using System.Messaging;
+using Apache.NMS.MSMQ;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.NMS.MSMQ.Readers
+{
+ /// <summary>
+ /// MSMQ message reader, returning messages matching the specified
+ /// lookup identifier.
+ /// </summary>
+ public class ByLookupIdMessageReader : AbstractMessageReader
+ {
+ private Int64 lookupId;
+
+ // The MSMQ documentation for MessageQueue.PeekByLookupId(*) and
+ // MessageQueue.ReceiveByLookupId(*) specifies:
+ // InvalidOperationException: The message with the specified lookupId could not be found.
+
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="messageQueue">The MSMQ message queue from which
+ /// messages will be read.</param>
+ /// <param name="messageConverter">A message converter for mapping
+ /// MSMQ messages to NMS messages.</param>
+ /// <param name="lookupId">The lookup identifier of the message
+ /// to be read.</param>
+ public ByLookupIdMessageReader(MessageQueue messageQueue,
+ IMessageConverter messageConverter, Int64 lookupId)
+ : base(messageQueue, messageConverter)
+ {
+ this.lookupId = lookupId;
+ }
+
+ /// <summary>
+ /// Returns without removing (peeks) the first message in the queue
+ /// referenced by this MessageQueue matching the selection criteria.
+ /// The Peek method is synchronous, so it blocks the current thread
+ /// until a message becomes available.
+ /// </summary>
+ /// <returns>Peeked message.</returns>
+ public override IMessage Peek()
+ {
+ try
+ {
+ return Convert(messageQueue.PeekByLookupId(lookupId));
+ }
+ catch(InvalidOperationException)
+ {
+ return null;
+ }
+ catch(Exception ex)
+ {
+ throw ex;
+ }
+ }
+
+ /// <summary>
+ /// Returns without removing (peeks) the first message in the queue
+ /// referenced by this MessageQueue matching the selection criteria.
+ /// The Peek method is synchronous, so it blocks the current thread
+ /// until a message becomes available or the specified time-out occurs.
+ /// </summary>
+ /// <param name="timeSpan">Reception time-out.</param>
+ /// <returns>Peeked message.</returns>
+ public override IMessage Peek(TimeSpan timeSpan)
+ {
+ try
+ {
+ // No time-out option for receiving messages by lookup identifiers:
+ // either the message is present in the queue, or the method throws
+ // an exception immediately if the message is not in the queue.
+ return Convert(messageQueue.PeekByLookupId(lookupId));
+ }
+ catch(InvalidOperationException)
+ {
+ return null;
+ }
+ catch(Exception ex)
+ {
+ throw ex;
+ }
+ }
+
+ /// <summary>
+ /// Receives the first message available in the queue referenced by
+ /// the MessageQueue matching the selection criteria.
+ /// This call is synchronous, and blocks the current thread of execution
+ /// until a message is available.
+ /// </summary>
+ /// <returns>Received message.</returns>
+ public override IMessage Receive()
+ {
+ try
+ {
+ return Convert(messageQueue.ReceiveByLookupId(lookupId));
+ }
+ catch(InvalidOperationException)
+ {
+ return null;
+ }
+ catch(Exception ex)
+ {
+ throw ex;
+ }
+ }
+
+ /// <summary>
+ /// Receives the first message available in the queue referenced by the
+ /// MessageQueue matching the selection criteria, and waits until either
+ /// a message is available in the queue, or the time-out expires.
+ /// </summary>
+ /// <param name="timeSpan">Reception time-out.</param>
+ /// <returns>Received message.</returns>
+ public override IMessage Receive(TimeSpan timeSpan)
+ {
+ try
+ {
+ // No time-out option for receiving messages by lookup identifiers:
+ // either the message is present in the queue, or the method throws
+ // an exception immediately if the message is not in the queue.
+ return Convert(messageQueue.ReceiveByLookupId(lookupId));
+ }
+ catch(InvalidOperationException)
+ {
+ return null;
+ }
+ catch(Exception ex)
+ {
+ throw ex;
+ }
+ }
+
+ /// <summary>
+ /// Receives the first message available in the transactional queue
+ /// referenced by the MessageQueue matching the selection criteria.
+ /// This call is synchronous, and blocks the current thread of execution
+ /// until a message is available.
+ /// </summary>
+ /// <param name="transaction">Transaction.</param>
+ /// <returns>Received message.</returns>
+ public override IMessage Receive(MessageQueueTransaction transaction)
+ {
+ try
+ {
+ return Convert(messageQueue.ReceiveByLookupId(
+ MessageLookupAction.Current, lookupId, transaction));
+ }
+ catch(InvalidOperationException)
+ {
+ return null;
+ }
+ catch(Exception ex)
+ {
+ throw ex;
+ }
+ }
+
+ /// <summary>
+ /// Receives the first message available in the transactional queue
+ /// referenced by the MessageQueue matching the selection criteria,
+ /// and waits until either a message is available in the queue, or the
+ /// time-out expires.
+ /// </summary>
+ /// <param name="timeSpan">Reception time-out.</param>
+ /// <param name="transaction">Transaction.</param>
+ /// <returns>Received message.</returns>
+ public override IMessage Receive(TimeSpan timeSpan,
+ MessageQueueTransaction transaction)
+ {
+ try
+ {
+ // No time-out option for receiving messages by lookup identifiers:
+ // either the message is present in the queue, or the method throws
+ // an exception immediately if the message is not in the queue.
+ return Convert(messageQueue.ReceiveByLookupId(
+ MessageLookupAction.Current, lookupId, transaction));
+ }
+ catch(InvalidOperationException)
+ {
+ return null;
+ }
+ catch(Exception ex)
+ {
+ throw ex;
+ }
+ }
+
+ /// <summary>
+ /// Checks if an MSMQ message matches the selection criteria.
+ /// </summary>
+ /// <param name="message">MSMQ message.</param>
+ /// <return>true if the message matches the selection criteria.</return>
+ public override bool Matches(Message message)
+ {
+ return message.LookupId == lookupId;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/activemq-nms-msmq/blob/7274a80a/src/main/csharp/Readers/BySelectorMessageReader.cs
----------------------------------------------------------------------
diff --git a/src/main/csharp/Readers/BySelectorMessageReader.cs b/src/main/csharp/Readers/BySelectorMessageReader.cs
index e7cd5c3..5617784 100644
--- a/src/main/csharp/Readers/BySelectorMessageReader.cs
+++ b/src/main/csharp/Readers/BySelectorMessageReader.cs
@@ -1,290 +1,286 @@
-using System;
-using System.Messaging;
-using Apache.NMS.MSMQ;
-using Apache.NMS;
-using Apache.NMS.Selector;
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.NMS.MSMQ.Readers
-{
- /// <summary>
- /// MSMQ message reader, returning messages matching the specified
- /// selector.
- /// </summary>
- public class BySelectorMessageReader : AbstractMessageReader
- {
- private string selector;
- private MessageEvaluationContext evaluationContext;
- private IBooleanExpression selectionExpression;
-
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="messageQueue">The MSMQ message queue from which
- /// messages will be read.</param>
- /// <param name="messageConverter">A message converter for mapping
- /// MSMQ messages to NMS messages.</param>
- /// <param name="selector">The selector string.</param>
- public BySelectorMessageReader(MessageQueue messageQueue,
- IMessageConverter messageConverter, string selector)
- : base(messageQueue, messageConverter)
- {
- this.selector = selector;
-
- SelectorParser selectorParser = new SelectorParser();
- selectionExpression = selectorParser.Parse(selector);
-
- evaluationContext = new MessageEvaluationContext(null);
- }
-
- /// <summary>
- /// Returns without removing (peeks) the first message in the queue
- /// referenced by this MessageQueue matching the selection criteria.
- /// The Peek method is synchronous, so it blocks the current thread
- /// until a message becomes available.
- /// </summary>
- /// <returns>Peeked message.</returns>
- public override IMessage Peek()
- {
- return InternalPeek(DateTime.MaxValue, true);
- }
-
- /// <summary>
- /// Returns without removing (peeks) the first message in the queue
- /// referenced by this MessageQueue matching the selection criteria.
- /// The Peek method is synchronous, so it blocks the current thread
- /// until a message becomes available or the specified time-out occurs.
- /// </summary>
- /// <param name="timeSpan">Reception time-out.</param>
- /// <returns>Peeked message.</returns>
- public override IMessage Peek(TimeSpan timeSpan)
- {
- DateTime maxTime = DateTime.Now + timeSpan;
- return InternalPeek(maxTime, true);
- }
-
- /// <summary>
- /// Receives the first message available in the queue referenced by
- /// the MessageQueue matching the selection criteria.
- /// This call is synchronous, and blocks the current thread of execution
- /// until a message is available.
- /// </summary>
- /// <returns>Received message.</returns>
- public override IMessage Receive()
- {
- return InternalReceive(DateTime.MaxValue, null);
- }
-
- /// <summary>
- /// Receives the first message available in the queue referenced by the
- /// MessageQueue matching the selection criteria, and waits until either
- /// a message is available in the queue, or the time-out expires.
- /// </summary>
- /// <param name="timeSpan">Reception time-out.</param>
- /// <returns>Received message.</returns>
- public override IMessage Receive(TimeSpan timeSpan)
- {
- return InternalReceive(DateTime.Now + timeSpan, null);
- }
-
- /// <summary>
- /// Receives the first message available in the transactional queue
- /// referenced by the MessageQueue matching the selection criteria.
- /// This call is synchronous, and blocks the current thread of execution
- /// until a message is available.
- /// </summary>
- /// <param name="transaction">Transaction.</param>
- /// <returns>Received message.</returns>
- public override IMessage Receive(MessageQueueTransaction transaction)
- {
- return InternalReceive(DateTime.MaxValue, transaction);
- }
-
- /// <summary>
- /// Receives the first message available in the transactional queue
- /// referenced by the MessageQueue matching the selection criteria,
- /// and waits until either a message is available in the queue, or the
- /// time-out expires.
- /// </summary>
- /// <param name="timeSpan">Reception time-out.</param>
- /// <param name="transaction">Transaction.</param>
- /// <returns>Received message.</returns>
- public override IMessage Receive(TimeSpan timeSpan,
- MessageQueueTransaction transaction)
- {
- return InternalReceive(DateTime.Now + timeSpan, transaction);
- }
-
- /// <summary>
- /// Receives the first message available in the transactional queue
- /// referenced by the MessageQueue matching the selection criteria,
- /// and waits until either a message is available in the queue, or the
- /// time-out expires.
- /// </summary>
- /// <param name="maxTime">Reception time-out.</param>
- /// <param name="transaction">Transaction.</param>
- /// <returns>Received message.</returns>
- public IMessage InternalReceive(DateTime maxTime,
- MessageQueueTransaction transaction)
- {
- // In a shared connection / multi-consumer context, the message may
- // have been consumed by another client, after it was peeked but
- // before it was peeked by this client. Hence the loop.
- // (not sure it can be shared AND transactional, though).
- while(true)
- {
- IMessage peekedMessage = InternalPeek(maxTime, false);
-
- if(peekedMessage == null)
- {
- return null;
- }
-
- try
- {
- long lookupId = peekedMessage.Properties.GetLong("LookupId");
-
- Message message = (transaction == null ?
- messageQueue.ReceiveByLookupId(lookupId) :
- messageQueue.ReceiveByLookupId(
- MessageLookupAction.Current, lookupId, transaction));
-
- return Convert(message);
- }
- catch(InvalidOperationException exc)
- {
- // TODO: filter exceptions, catch only exceptions due to
- // unknown lookup id.
- }
- }
- }
-
- /// <summary>
- /// Returns without removing (peeks) the first message in the queue
- /// referenced by this MessageQueue, matching the selection criteria.
- /// </summary>
- /// <param name="maxTime">Reception time-out.</param>
- /// <param name="convertBody">true if message body should be converted.</param>
- /// <returns>Peeked message.</returns>
- private IMessage InternalPeek(DateTime maxTime, bool convertBody)
- {
- TimeSpan timeSpan = maxTime - DateTime.Now;
- if(timeSpan <= TimeSpan.Zero)
- {
- timeSpan = TimeSpan.Zero;
- }
-
- Cursor cursor = messageQueue.CreateCursor();
-
- PeekAction action = PeekAction.Current;
-
- while(true)
- {
- Message msmqMessage = null;
-
- try
- {
- msmqMessage = messageQueue.Peek(timeSpan, cursor, action);
- }
- catch(MessageQueueException exc)
- {
- if(exc.MessageQueueErrorCode != MessageQueueErrorCode.IOTimeout)
- {
- throw exc;
- }
- }
-
- if(msmqMessage == null)
- {
- return null;
- }
-
- IMessage nmsMessage = InternalMatch(msmqMessage, convertBody);
-
- if(nmsMessage != null)
- {
- return nmsMessage;
- }
-
- action = PeekAction.Next;
- }
- }
-
- /// <summary>
- /// Checks if an MSMQ message matches the selection criteria. If matched
- /// the method returns the converted NMS message. Else it returns null.
- /// </summary>
- /// <param name="message">The MSMQ message to check.</param>
- /// <param name="convertBody">true if the message body should be
- /// converted.</param>
- /// <returns>The matching message converted to NMS, or null.</returns>
- private IMessage InternalMatch(Message message, bool convertBody)
- {
- if(messageConverterEx == null)
- {
- IMessage nmsMessage = messageConverter.ToNmsMessage(message);
-
- evaluationContext.Message = nmsMessage;
-
- if(selectionExpression.Matches(evaluationContext))
- {
- return nmsMessage;
- }
- }
- else
- {
- // This version converts the message body only for those
- // messages matching the selection criteria.
- // Relies on MessageConverterEx for partial conversions.
- IMessage nmsMessage = messageConverterEx.ToNmsMessage(
- message, false);
-
- evaluationContext.Message = nmsMessage;
-
- if(selectionExpression.Matches(evaluationContext))
- {
- if(convertBody)
- {
- messageConverterEx.ConvertMessageBodyToNMS(
- message, nmsMessage);
- }
-
- return nmsMessage;
- }
- }
-
- return null;
- }
-
- /// <summary>
- /// Checks if an MSMQ message matches the selection criteria.
- /// </summary>
- /// <param name="message">MSMQ message.</param>
- /// <return>true if the message matches the selection criteria.</return>
- public override bool Matches(Message message)
- {
- IMessage nmsMessage = messageConverterEx == null ?
- messageConverter.ToNmsMessage(message) :
- messageConverterEx.ToNmsMessage(message, false);
-
- evaluationContext.Message = nmsMessage;
-
- return selectionExpression.Matches(evaluationContext);
- }
- }
-}
+using System;
+using System.Messaging;
+using Apache.NMS.MSMQ;
+using Apache.NMS;
+using Apache.NMS.Selector;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.NMS.MSMQ.Readers
+{
+ /// <summary>
+ /// MSMQ message reader, returning messages matching the specified
+ /// selector.
+ /// </summary>
+ public class BySelectorMessageReader : AbstractMessageReader
+ {
+ private string selector;
+ private MessageEvaluationContext evaluationContext;
+ private IBooleanExpression selectionExpression;
+
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="messageQueue">The MSMQ message queue from which
+ /// messages will be read.</param>
+ /// <param name="messageConverter">A message converter for mapping
+ /// MSMQ messages to NMS messages.</param>
+ /// <param name="selector">The selector string.</param>
+ public BySelectorMessageReader(MessageQueue messageQueue,
+ IMessageConverter messageConverter, string selector)
+ : base(messageQueue, messageConverter)
+ {
+ this.selector = selector;
+
+ SelectorParser selectorParser = new SelectorParser();
+ selectionExpression = selectorParser.Parse(selector);
+
+ evaluationContext = new MessageEvaluationContext(null);
+ }
+
+ /// <summary>
+ /// Returns without removing (peeks) the first message in the queue
+ /// referenced by this MessageQueue matching the selection criteria.
+ /// The Peek method is synchronous, so it blocks the current thread
+ /// until a message becomes available.
+ /// </summary>
+ /// <returns>Peeked message.</returns>
+ public override IMessage Peek()
+ {
+ return InternalPeek(DateTime.MaxValue, true);
+ }
+
+ /// <summary>
+ /// Returns without removing (peeks) the first message in the queue
+ /// referenced by this MessageQueue matching the selection criteria.
+ /// The Peek method is synchronous, so it blocks the current thread
+ /// until a message becomes available or the specified time-out occurs.
+ /// </summary>
+ /// <param name="timeSpan">Reception time-out.</param>
+ /// <returns>Peeked message.</returns>
+ public override IMessage Peek(TimeSpan timeSpan)
+ {
+ DateTime maxTime = DateTime.Now + timeSpan;
+ return InternalPeek(maxTime, true);
+ }
+
+ /// <summary>
+ /// Receives the first message available in the queue referenced by
+ /// the MessageQueue matching the selection criteria.
+ /// This call is synchronous, and blocks the current thread of execution
+ /// until a message is available.
+ /// </summary>
+ /// <returns>Received message.</returns>
+ public override IMessage Receive()
+ {
+ return InternalReceive(DateTime.MaxValue, null);
+ }
+
+ /// <summary>
+ /// Receives the first message available in the queue referenced by the
+ /// MessageQueue matching the selection criteria, and waits until either
+ /// a message is available in the queue, or the time-out expires.
+ /// </summary>
+ /// <param name="timeSpan">Reception time-out.</param>
+ /// <returns>Received message.</returns>
+ public override IMessage Receive(TimeSpan timeSpan)
+ {
+ return InternalReceive(DateTime.Now + timeSpan, null);
+ }
+
+ /// <summary>
+ /// Receives the first message available in the transactional queue
+ /// referenced by the MessageQueue matching the selection criteria.
+ /// This call is synchronous, and blocks the current thread of execution
+ /// until a message is available.
+ /// </summary>
+ /// <param name="transaction">Transaction.</param>
+ /// <returns>Received message.</returns>
+ public override IMessage Receive(MessageQueueTransaction transaction)
+ {
+ return InternalReceive(DateTime.MaxValue, transaction);
+ }
+
+ /// <summary>
+ /// Receives the first message available in the transactional queue
+ /// referenced by the MessageQueue matching the selection criteria,
+ /// and waits until either a message is available in the queue, or the
+ /// time-out expires.
+ /// </summary>
+ /// <param name="timeSpan">Reception time-out.</param>
+ /// <param name="transaction">Transaction.</param>
+ /// <returns>Received message.</returns>
+ public override IMessage Receive(TimeSpan timeSpan,
+ MessageQueueTransaction transaction)
+ {
+ return InternalReceive(DateTime.Now + timeSpan, transaction);
+ }
+
+ /// <summary>
+ /// Receives the first message available in the transactional queue
+ /// referenced by the MessageQueue matching the selection criteria,
+ /// and waits until either a message is available in the queue, or the
+ /// time-out expires.
+ /// </summary>
+ /// <param name="maxTime">Reception time-out.</param>
+ /// <param name="transaction">Transaction.</param>
+ /// <returns>Received message.</returns>
+ public IMessage InternalReceive(DateTime maxTime,
+ MessageQueueTransaction transaction)
+ {
+ // In a shared connection / multi-consumer context, the message may
+ // have been consumed by another client, after it was peeked but
+ // before it was peeked by this client. Hence the loop.
+ // (not sure it can be shared AND transactional, though).
+ while(true)
+ {
+ IMessage peekedMessage = InternalPeek(maxTime, false);
+
+ if(peekedMessage == null)
+ {
+ return null;
+ }
+
+ try
+ {
+ long lookupId = peekedMessage.Properties.GetLong("LookupId");
+
+ Message message = (transaction == null ?
+ messageQueue.ReceiveByLookupId(lookupId) :
+ messageQueue.ReceiveByLookupId(
+ MessageLookupAction.Current, lookupId, transaction));
+
+ return Convert(message);
+ }
+ catch(InvalidOperationException)
+ {
+ // TODO: filter exceptions, catch only exceptions due to
+ // unknown lookup id.
+ }
+ }
+ }
+
+ /// <summary>
+ /// Returns without removing (peeks) the first message in the queue
+ /// referenced by this MessageQueue, matching the selection criteria.
+ /// </summary>
+ /// <param name="maxTime">Reception time-out.</param>
+ /// <param name="convertBody">true if message body should be converted.</param>
+ /// <returns>Peeked message.</returns>
+ private IMessage InternalPeek(DateTime maxTime, bool convertBody)
+ {
+ TimeSpan timeSpan = maxTime - DateTime.Now;
+ if(timeSpan <= TimeSpan.Zero)
+ {
+ timeSpan = TimeSpan.Zero;
+ }
+
+ using(Cursor cursor = messageQueue.CreateCursor())
+ {
+ PeekAction action = PeekAction.Current;
+ while(true)
+ {
+ Message msmqMessage = null;
+
+ try
+ {
+ msmqMessage = messageQueue.Peek(timeSpan, cursor, action);
+ }
+ catch(MessageQueueException exc)
+ {
+ if(exc.MessageQueueErrorCode == MessageQueueErrorCode.IOTimeout)
+ {
+ return null;
+ }
+ throw exc;
+ }
+
+ IMessage nmsMessage = InternalMatch(msmqMessage, convertBody);
+
+ if(nmsMessage != null)
+ {
+ return nmsMessage;
+ }
+
+ action = PeekAction.Next;
+ }
+ }
+ }
+
+ /// <summary>
+ /// Checks if an MSMQ message matches the selection criteria. If matched
+ /// the method returns the converted NMS message. Else it returns null.
+ /// </summary>
+ /// <param name="message">The MSMQ message to check.</param>
+ /// <param name="convertBody">true if the message body should be
+ /// converted.</param>
+ /// <returns>The matching message converted to NMS, or null.</returns>
+ private IMessage InternalMatch(Message message, bool convertBody)
+ {
+ if(messageConverterEx == null)
+ {
+ IMessage nmsMessage = messageConverter.ToNmsMessage(message);
+
+ evaluationContext.Message = nmsMessage;
+
+ if(selectionExpression.Matches(evaluationContext))
+ {
+ return nmsMessage;
+ }
+ }
+ else
+ {
+ // This version converts the message body only for those
+ // messages matching the selection criteria.
+ // Relies on MessageConverterEx for partial conversions.
+ IMessage nmsMessage = messageConverterEx.ToNmsMessage(
+ message, false);
+
+ evaluationContext.Message = nmsMessage;
+
+ if(selectionExpression.Matches(evaluationContext))
+ {
+ if(convertBody)
+ {
+ messageConverterEx.ConvertMessageBodyToNMS(
+ message, nmsMessage);
+ }
+
+ return nmsMessage;
+ }
+ }
+
+ return null;
+ }
+
+ /// <summary>
+ /// Checks if an MSMQ message matches the selection criteria.
+ /// </summary>
+ /// <param name="message">MSMQ message.</param>
+ /// <return>true if the message matches the selection criteria.</return>
+ public override bool Matches(Message message)
+ {
+ IMessage nmsMessage = messageConverterEx == null ?
+ messageConverter.ToNmsMessage(message) :
+ messageConverterEx.ToNmsMessage(message, false);
+
+ evaluationContext.Message = nmsMessage;
+
+ return selectionExpression.Matches(evaluationContext);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/activemq-nms-msmq/blob/7274a80a/src/main/csharp/Readers/IMessageReader.cs
----------------------------------------------------------------------
diff --git a/src/main/csharp/Readers/IMessageReader.cs b/src/main/csharp/Readers/IMessageReader.cs
index 8168664..c36323f 100644
--- a/src/main/csharp/Readers/IMessageReader.cs
+++ b/src/main/csharp/Readers/IMessageReader.cs
@@ -1,93 +1,93 @@
-using System;
-using System.Messaging;
-using Apache.NMS.MSMQ;
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.NMS.MSMQ.Readers
-{
- /// <summary>
- /// MSMQ message reader.
- /// </summary>
- public interface IMessageReader
- {
- /// <summary>
- /// Returns without removing (peeks) the first message in the queue
- /// referenced by this MessageQueue matching the selection criteria.
- /// The Peek method is synchronous, so it blocks the current thread
- /// until a message becomes available.
- /// </summary>
- /// <returns>Peeked message.</returns>
- IMessage Peek();
-
- /// <summary>
- /// Returns without removing (peeks) the first message in the queue
- /// referenced by this MessageQueue matching the selection criteria.
- /// The Peek method is synchronous, so it blocks the current thread
- /// until a message becomes available or the specified time-out occurs.
- /// </summary>
- /// <param name="timeSpan">Reception time-out.</param>
- /// <returns>Peeked message.</returns>
- IMessage Peek(TimeSpan timeSpan);
-
- /// <summary>
- /// Receives the first message available in the queue referenced by
- /// the MessageQueue matching the selection criteria.
- /// This call is synchronous, and blocks the current thread of execution
- /// until a message is available.
- /// </summary>
- /// <returns>Received message.</returns>
- IMessage Receive();
-
- /// <summary>
- /// Receives the first message available in the queue referenced by the
- /// MessageQueue matching the selection criteria, and waits until either
- /// a message is available in the queue, or the time-out expires.
- /// </summary>
- /// <param name="timeSpan">Reception time-out.</param>
- /// <returns>Received message.</returns>
- IMessage Receive(TimeSpan timeSpan);
-
- /// <summary>
- /// Receives the first message available in the transactional queue
- /// referenced by the MessageQueue matching the selection criteria.
- /// This call is synchronous, and blocks the current thread of execution
- /// until a message is available.
- /// </summary>
- /// <param name="transaction">Transaction.</param>
- /// <returns>Received message.</returns>
- IMessage Receive(MessageQueueTransaction transaction);
-
- /// <summary>
- /// Receives the first message available in the transactional queue
- /// referenced by the MessageQueue matching the selection criteria,
- /// and waits until either a message is available in the queue, or the
- /// time-out expires.
- /// </summary>
- /// <param name="timeSpan">Reception time-out.</param>
- /// <param name="transaction">Transaction.</param>
- /// <returns>Received message.</returns>
- IMessage Receive(TimeSpan timeSpan, MessageQueueTransaction transaction);
-
- /// <summary>
- /// Checks if an MSMQ message matches the selection criteria.
- /// </summary>
- /// <param name="message">MSMQ message.</param>
- /// <return>true if the message matches the selection criteria.</return>
- bool Matches(Message message);
- }
-}
+using System;
+using System.Messaging;
+using Apache.NMS.MSMQ;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.NMS.MSMQ.Readers
+{
+ /// <summary>
+ /// MSMQ message reader.
+ /// </summary>
+ public interface IMessageReader
+ {
+ /// <summary>
+ /// Returns without removing (peeks) the first message in the queue
+ /// referenced by this MessageQueue matching the selection criteria.
+ /// The Peek method is synchronous, so it blocks the current thread
+ /// until a message becomes available.
+ /// </summary>
+ /// <returns>Peeked message.</returns>
+ IMessage Peek();
+
+ /// <summary>
+ /// Returns without removing (peeks) the first message in the queue
+ /// referenced by this MessageQueue matching the selection criteria.
+ /// The Peek method is synchronous, so it blocks the current thread
+ /// until a message becomes available or the specified time-out occurs.
+ /// </summary>
+ /// <param name="timeSpan">Reception time-out.</param>
+ /// <returns>Peeked message.</returns>
+ IMessage Peek(TimeSpan timeSpan);
+
+ /// <summary>
+ /// Receives the first message available in the queue referenced by
+ /// the MessageQueue matching the selection criteria.
+ /// This call is synchronous, and blocks the current thread of execution
+ /// until a message is available.
+ /// </summary>
+ /// <returns>Received message.</returns>
+ IMessage Receive();
+
+ /// <summary>
+ /// Receives the first message available in the queue referenced by the
+ /// MessageQueue matching the selection criteria, and waits until either
+ /// a message is available in the queue, or the time-out expires.
+ /// </summary>
+ /// <param name="timeSpan">Reception time-out.</param>
+ /// <returns>Received message.</returns>
+ IMessage Receive(TimeSpan timeSpan);
+
+ /// <summary>
+ /// Receives the first message available in the transactional queue
+ /// referenced by the MessageQueue matching the selection criteria.
+ /// This call is synchronous, and blocks the current thread of execution
+ /// until a message is available.
+ /// </summary>
+ /// <param name="transaction">Transaction.</param>
+ /// <returns>Received message.</returns>
+ IMessage Receive(MessageQueueTransaction transaction);
+
+ /// <summary>
+ /// Receives the first message available in the transactional queue
+ /// referenced by the MessageQueue matching the selection criteria,
+ /// and waits until either a message is available in the queue, or the
+ /// time-out expires.
+ /// </summary>
+ /// <param name="timeSpan">Reception time-out.</param>
+ /// <param name="transaction">Transaction.</param>
+ /// <returns>Received message.</returns>
+ IMessage Receive(TimeSpan timeSpan, MessageQueueTransaction transaction);
+
+ /// <summary>
+ /// Checks if an MSMQ message matches the selection criteria.
+ /// </summary>
+ /// <param name="message">MSMQ message.</param>
+ /// <return>true if the message matches the selection criteria.</return>
+ bool Matches(Message message);
+ }
+}
http://git-wip-us.apache.org/repos/asf/activemq-nms-msmq/blob/7274a80a/src/main/csharp/Readers/MessageReaderUtil.cs
----------------------------------------------------------------------
diff --git a/src/main/csharp/Readers/MessageReaderUtil.cs b/src/main/csharp/Readers/MessageReaderUtil.cs
index c303965..97d62c3 100644
--- a/src/main/csharp/Readers/MessageReaderUtil.cs
+++ b/src/main/csharp/Readers/MessageReaderUtil.cs
@@ -1,91 +1,91 @@
-using System;
-using System.Messaging;
-using System.Globalization;
-using System.Text.RegularExpressions;
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.NMS.MSMQ.Readers
-{
- /// <summary>
- /// Utility routines for creating MSMQ message readers.
- /// </summary>
- public static class MessageReaderUtil
- {
- private static Regex basicSelectorRegex =
- new Regex(@"^\s*" +
- @"(NMSMessageId)\s*=\s*'([^']*)'|" +
- @"(NMSCorrelationId)\s*=\s*'([^']*)'|" +
- @"(LookupId)\s*=\s*([-+]{0,1}\d+)" +
- @"\s*$",
- RegexOptions.IgnoreCase | RegexOptions.Compiled);
-
- /// <summary>
- /// Creates a message reader for the specified message selector.
- /// </summary>
- /// <param name="messageQueue">The MSMQ message queue from which
- /// messages will be read.</param>
- /// <param name="messageConverter">A message converter for mapping
- /// MSMQ messages to NMS messages.</param>
- /// <param name="selector">The message selector.</param>
- /// <return>A reader for the specified selector.</return>
- public static IMessageReader CreateMessageReader(
- MessageQueue messageQueue, IMessageConverter messageConverter,
- string selector)
- {
- IMessageReader reader;
-
- if(string.IsNullOrEmpty(selector))
- {
- reader = new NonFilteringMessageReader(messageQueue,
- messageConverter);
- }
- else
- {
- Match match = basicSelectorRegex.Match(selector);
- if(match.Success)
- {
- if(!string.IsNullOrEmpty(match.Groups[1].Value))
- {
- reader = new ByIdMessageReader(messageQueue,
- messageConverter, match.Groups[2].Value);
- }
- else if(!string.IsNullOrEmpty(match.Groups[3].Value))
- {
- reader = new ByCorrelationIdMessageReader(messageQueue,
- messageConverter, match.Groups[4].Value);
- }
- else
- {
- Int64 lookupId = Int64.Parse(match.Groups[6].Value,
- CultureInfo.InvariantCulture);
-
- reader = new ByLookupIdMessageReader(messageQueue,
- messageConverter, lookupId);
- }
- }
- else
- {
- reader = new BySelectorMessageReader(messageQueue,
- messageConverter, selector);
- }
- }
-
- return reader;
- }
- }
-}
+using System;
+using System.Messaging;
+using System.Globalization;
+using System.Text.RegularExpressions;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.NMS.MSMQ.Readers
+{
+ /// <summary>
+ /// Utility routines for creating MSMQ message readers.
+ /// </summary>
+ public static class MessageReaderUtil
+ {
+ private static Regex basicSelectorRegex =
+ new Regex(@"^\s*" +
+ @"(NMSMessageId)\s*=\s*'([^']*)'|" +
+ @"(NMSCorrelationId)\s*=\s*'([^']*)'|" +
+ @"(LookupId)\s*=\s*([-+]{0,1}\d+)" +
+ @"\s*$",
+ RegexOptions.IgnoreCase | RegexOptions.Compiled);
+
+ /// <summary>
+ /// Creates a message reader for the specified message selector.
+ /// </summary>
+ /// <param name="messageQueue">The MSMQ message queue from which
+ /// messages will be read.</param>
+ /// <param name="messageConverter">A message converter for mapping
+ /// MSMQ messages to NMS messages.</param>
+ /// <param name="selector">The message selector.</param>
+ /// <return>A reader for the specified selector.</return>
+ public static IMessageReader CreateMessageReader(
+ MessageQueue messageQueue, IMessageConverter messageConverter,
+ string selector)
+ {
+ IMessageReader reader;
+
+ if(string.IsNullOrEmpty(selector))
+ {
+ reader = new NonFilteringMessageReader(messageQueue,
+ messageConverter);
+ }
+ else
+ {
+ Match match = basicSelectorRegex.Match(selector);
+ if(match.Success)
+ {
+ if(!string.IsNullOrEmpty(match.Groups[1].Value))
+ {
+ reader = new ByIdMessageReader(messageQueue,
+ messageConverter, match.Groups[2].Value);
+ }
+ else if(!string.IsNullOrEmpty(match.Groups[3].Value))
+ {
+ reader = new ByCorrelationIdMessageReader(messageQueue,
+ messageConverter, match.Groups[4].Value);
+ }
+ else
+ {
+ Int64 lookupId = Int64.Parse(match.Groups[6].Value,
+ CultureInfo.InvariantCulture);
+
+ reader = new ByLookupIdMessageReader(messageQueue,
+ messageConverter, lookupId);
+ }
+ }
+ else
+ {
+ reader = new BySelectorMessageReader(messageQueue,
+ messageConverter, selector);
+ }
+ }
+
+ return reader;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/activemq-nms-msmq/blob/7274a80a/src/main/csharp/Readers/NonFilteringMessageReader.cs
----------------------------------------------------------------------
diff --git a/src/main/csharp/Readers/NonFilteringMessageReader.cs b/src/main/csharp/Readers/NonFilteringMessageReader.cs
index ea98baf..0b9ff7b 100644
--- a/src/main/csharp/Readers/NonFilteringMessageReader.cs
+++ b/src/main/csharp/Readers/NonFilteringMessageReader.cs
@@ -1,128 +1,128 @@
-using System;
-using System.Messaging;
-using Apache.NMS.MSMQ;
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.NMS.MSMQ.Readers
-{
- /// <summary>
- /// MSMQ message reader, returning all messages, without filtering.
- /// </summary>
- public class NonFilteringMessageReader : AbstractMessageReader
- {
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="messageQueue">The MSMQ message queue from which
- /// messages will be read.</param>
- /// <param name="messageConverter">A message converter for mapping
- /// MSMQ messages to NMS messages.</param>
- public NonFilteringMessageReader(MessageQueue messageQueue,
- IMessageConverter messageConverter)
- : base(messageQueue, messageConverter)
- {
- }
-
- /// <summary>
- /// Returns without removing (peeks) the first message in the queue
- /// referenced by this MessageQueue matching the selection criteria.
- /// The Peek method is synchronous, so it blocks the current thread
- /// until a message becomes available.
- /// </summary>
- /// <returns>Peeked message.</returns>
- public override IMessage Peek()
- {
- return Convert(messageQueue.Peek());
- }
-
- /// <summary>
- /// Returns without removing (peeks) the first message in the queue
- /// referenced by this MessageQueue matching the selection criteria.
- /// The Peek method is synchronous, so it blocks the current thread
- /// until a message becomes available or the specified time-out occurs.
- /// </summary>
- /// <param name="timeSpan">Reception time-out.</param>
- /// <returns>Peeked message.</returns>
- public override IMessage Peek(TimeSpan timeSpan)
- {
- return Convert(messageQueue.Peek(timeSpan));
- }
-
- /// <summary>
- /// Receives the first message available in the queue referenced by
- /// the MessageQueue matching the selection criteria.
- /// This call is synchronous, and blocks the current thread of execution
- /// until a message is available.
- /// </summary>
- /// <returns>Received message.</returns>
- public override IMessage Receive()
- {
- return Convert(messageQueue.Receive());
- }
-
- /// <summary>
- /// Receives the first message available in the queue referenced by the
- /// MessageQueue matching the selection criteria, and waits until either
- /// a message is available in the queue, or the time-out expires.
- /// </summary>
- /// <param name="timeSpan">Reception time-out.</param>
- /// <returns>Received message.</returns>
- public override IMessage Receive(TimeSpan timeSpan)
- {
- return Convert(messageQueue.Receive(timeSpan));
- }
-
- /// <summary>
- /// Receives the first message available in the transactional queue
- /// referenced by the MessageQueue matching the selection criteria.
- /// This call is synchronous, and blocks the current thread of execution
- /// until a message is available.
- /// </summary>
- /// <param name="transaction">Transaction.</param>
- /// <returns>Received message.</returns>
- public override IMessage Receive(MessageQueueTransaction transaction)
- {
- return Convert(messageQueue.Receive(transaction));
- }
-
- /// <summary>
- /// Receives the first message available in the transactional queue
- /// referenced by the MessageQueue matching the selection criteria,
- /// and waits until either a message is available in the queue, or the
- /// time-out expires.
- /// </summary>
- /// <param name="timeSpan">Reception time-out.</param>
- /// <param name="transaction">Transaction.</param>
- /// <returns>Received message.</returns>
- public override IMessage Receive(TimeSpan timeSpan,
- MessageQueueTransaction transaction)
- {
- return Convert(messageQueue.Receive(timeSpan, transaction));
- }
-
- /// <summary>
- /// Checks if an MSMQ message matches the selection criteria.
- /// </summary>
- /// <param name="message">MSMQ message.</param>
- /// <return>true if the message matches the selection criteria.</return>
- public override bool Matches(Message message)
- {
- return true;
- }
- }
-}
+using System;
+using System.Messaging;
+using Apache.NMS.MSMQ;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.NMS.MSMQ.Readers
+{
+ /// <summary>
+ /// MSMQ message reader, returning all messages, without filtering.
+ /// </summary>
+ public class NonFilteringMessageReader : AbstractMessageReader
+ {
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="messageQueue">The MSMQ message queue from which
+ /// messages will be read.</param>
+ /// <param name="messageConverter">A message converter for mapping
+ /// MSMQ messages to NMS messages.</param>
+ public NonFilteringMessageReader(MessageQueue messageQueue,
+ IMessageConverter messageConverter)
+ : base(messageQueue, messageConverter)
+ {
+ }
+
+ /// <summary>
+ /// Returns without removing (peeks) the first message in the queue
+ /// referenced by this MessageQueue matching the selection criteria.
+ /// The Peek method is synchronous, so it blocks the current thread
+ /// until a message becomes available.
+ /// </summary>
+ /// <returns>Peeked message.</returns>
+ public override IMessage Peek()
+ {
+ return Convert(messageQueue.Peek());
+ }
+
+ /// <summary>
+ /// Returns without removing (peeks) the first message in the queue
+ /// referenced by this MessageQueue matching the selection criteria.
+ /// The Peek method is synchronous, so it blocks the current thread
+ /// until a message becomes available or the specified time-out occurs.
+ /// </summary>
+ /// <param name="timeSpan">Reception time-out.</param>
+ /// <returns>Peeked message.</returns>
+ public override IMessage Peek(TimeSpan timeSpan)
+ {
+ return Convert(messageQueue.Peek(timeSpan));
+ }
+
+ /// <summary>
+ /// Receives the first message available in the queue referenced by
+ /// the MessageQueue matching the selection criteria.
+ /// This call is synchronous, and blocks the current thread of execution
+ /// until a message is available.
+ /// </summary>
+ /// <returns>Received message.</returns>
+ public override IMessage Receive()
+ {
+ return Convert(messageQueue.Receive());
+ }
+
+ /// <summary>
+ /// Receives the first message available in the queue referenced by the
+ /// MessageQueue matching the selection criteria, and waits until either
+ /// a message is available in the queue, or the time-out expires.
+ /// </summary>
+ /// <param name="timeSpan">Reception time-out.</param>
+ /// <returns>Received message.</returns>
+ public override IMessage Receive(TimeSpan timeSpan)
+ {
+ return Convert(messageQueue.Receive(timeSpan));
+ }
+
+ /// <summary>
+ /// Receives the first message available in the transactional queue
+ /// referenced by the MessageQueue matching the selection criteria.
+ /// This call is synchronous, and blocks the current thread of execution
+ /// until a message is available.
+ /// </summary>
+ /// <param name="transaction">Transaction.</param>
+ /// <returns>Received message.</returns>
+ public override IMessage Receive(MessageQueueTransaction transaction)
+ {
+ return Convert(messageQueue.Receive(transaction));
+ }
+
+ /// <summary>
+ /// Receives the first message available in the transactional queue
+ /// referenced by the MessageQueue matching the selection criteria,
+ /// and waits until either a message is available in the queue, or the
+ /// time-out expires.
+ /// </summary>
+ /// <param name="timeSpan">Reception time-out.</param>
+ /// <param name="transaction">Transaction.</param>
+ /// <returns>Received message.</returns>
+ public override IMessage Receive(TimeSpan timeSpan,
+ MessageQueueTransaction transaction)
+ {
+ return Convert(messageQueue.Receive(timeSpan, transaction));
+ }
+
+ /// <summary>
+ /// Checks if an MSMQ message matches the selection criteria.
+ /// </summary>
+ /// <param name="message">MSMQ message.</param>
+ /// <return>true if the message matches the selection criteria.</return>
+ public override bool Matches(Message message)
+ {
+ return true;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/activemq-nms-msmq/blob/7274a80a/src/main/csharp/Selector/ANDExpression.cs
----------------------------------------------------------------------
diff --git a/src/main/csharp/Selector/ANDExpression.cs b/src/main/csharp/Selector/ANDExpression.cs
index 285efe3..976eacc 100644
--- a/src/main/csharp/Selector/ANDExpression.cs
+++ b/src/main/csharp/Selector/ANDExpression.cs
@@ -1,47 +1,46 @@
-\ufeffusing System;
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.NMS.Selector
-{
- /// <summary>
- /// A filter performing a logical AND combination of two expressions.
- /// </summary>
- public class ANDExpression : LogicExpression
- {
- protected override string ExpressionSymbol
- {
- get { return "AND"; }
- }
-
- public ANDExpression(IBooleanExpression left, IBooleanExpression right)
- : base(left, right)
- {
- }
-
- public override object Evaluate(MessageEvaluationContext message)
- {
- object lvalue = Left.Evaluate(message);
- if(lvalue == null) return null;
- if(!(bool)lvalue) return false;
-
- object rvalue = Right.Evaluate(message);
- return rvalue == null ? null : rvalue;
- }
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+using System;
+
+namespace Apache.NMS.Selector
+{
+ /// <summary>
+ /// A filter performing a logical AND combination of two expressions.
+ /// </summary>
+ public class ANDExpression : LogicExpression
+ {
+ protected override string ExpressionSymbol
+ {
+ get { return "AND"; }
+ }
+
+ public ANDExpression(IBooleanExpression left, IBooleanExpression right)
+ : base(left, right)
+ {
+ }
+
+ public override object Evaluate(MessageEvaluationContext message)
+ {
+ object lvalue = Left.Evaluate(message);
+ if(lvalue == null) return null;
+ if(!(bool)lvalue) return false;
+
+ object rvalue = Right.Evaluate(message);
+ return rvalue == null ? null : rvalue;
+ }
+ }
+}