Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id A84A1200C3F for ; Tue, 7 Mar 2017 20:38:46 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id A70B0160B9B; Tue, 7 Mar 2017 19:38:46 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 5B613160B8B for ; Tue, 7 Mar 2017 20:38:45 +0100 (CET) Received: (qmail 71277 invoked by uid 500); 7 Mar 2017 19:38:42 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 70029 invoked by uid 99); 7 Mar 2017 19:38:42 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 07 Mar 2017 19:38:42 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 0DF1AF1761; Tue, 7 Mar 2017 19:38:42 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: tabish@apache.org To: commits@activemq.apache.org Date: Tue, 07 Mar 2017 19:39:15 -0000 Message-Id: <805d5ca4517d424c9488bc0a64f81002@git.apache.org> In-Reply-To: <9671c43771644fdcbe5a90712858608b@git.apache.org> References: <9671c43771644fdcbe5a90712858608b@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [35/50] [abbrv] activemq-nms-msmq git commit: Applied patch from Stephane Ramet to implement QueueBrowser and DeleteDestination. Thanks Stephane! Fixes [AMQNET-517]. (See https://issues.apache.org/jira/browse/AMQNET-517) archived-at: Tue, 07 Mar 2017 19:38:46 -0000 Applied patch from Stephane Ramet to implement QueueBrowser and DeleteDestination. Thanks Stephane! Fixes [AMQNET-517]. (See https://issues.apache.org/jira/browse/AMQNET-517) Project: http://git-wip-us.apache.org/repos/asf/activemq-nms-msmq/repo Commit: http://git-wip-us.apache.org/repos/asf/activemq-nms-msmq/commit/51ec9a29 Tree: http://git-wip-us.apache.org/repos/asf/activemq-nms-msmq/tree/51ec9a29 Diff: http://git-wip-us.apache.org/repos/asf/activemq-nms-msmq/diff/51ec9a29 Branch: refs/heads/master Commit: 51ec9a290ca7bc352d50e4d18599776cca8423b9 Parents: bf07d7b Author: Jim Gomes Authored: Wed Jan 13 23:24:08 2016 +0000 Committer: Jim Gomes Committed: Wed Jan 13 23:24:08 2016 +0000 ---------------------------------------------------------------------- src/main/csharp/QueueBrowser.cs | 141 +++++++++++++++++++++++++++++++++++ src/main/csharp/Session.cs | 16 ++-- vs2008-msmq.csproj | 1 + 3 files changed, 152 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/activemq-nms-msmq/blob/51ec9a29/src/main/csharp/QueueBrowser.cs ---------------------------------------------------------------------- diff --git a/src/main/csharp/QueueBrowser.cs b/src/main/csharp/QueueBrowser.cs new file mode 100644 index 0000000..32752c5 --- /dev/null +++ b/src/main/csharp/QueueBrowser.cs @@ -0,0 +1,141 @@ +/* + * 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; +using System.Collections; +using System.Messaging; +using Apache.NMS; +using Apache.NMS.Util; + +namespace Apache.NMS.MSMQ +{ + public class QueueBrowser : Apache.NMS.IQueueBrowser + { + private bool closed = false; + private bool disposed = false; + + private readonly Session session; + private MessageQueue messageQueue; + + public QueueBrowser(Session session, MessageQueue messageQueue) + { + this.session = session; + this.messageQueue = messageQueue; + if(null != this.messageQueue) + { + this.messageQueue.MessageReadPropertyFilter.SetAll(); + } + + } + + ~QueueBrowser() + { + Dispose(false); + } + + #region IDisposable Members + + /// + /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. + /// + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + protected void Dispose(bool disposing) + { + if(disposed) + { + return; + } + + if(disposing) + { + // Dispose managed code here. + } + + try + { + Close(); + } + catch + { + // Ignore errors. + } + + disposed = true; + } + + #endregion + + public void Close() + { + if(messageQueue != null) + { + messageQueue.Dispose(); + messageQueue = null; + } + closed = true; + } + + public string MessageSelector + { + get { throw new NotSupportedException(); } + } + + public IQueue Queue + { + get { return new Queue(this.messageQueue.Path); } + } + + internal class Enumerator : IEnumerator + { + private readonly Session session; + private readonly MessageEnumerator innerEnumerator; + + public Enumerator(Session session, MessageQueue messageQueue) + { + this.session = session; + this.innerEnumerator = messageQueue.GetMessageEnumerator2(); + } + + public object Current + { + get + { + return this.session.MessageConverter.ToNmsMessage(this.innerEnumerator.Current); + } + } + + public bool MoveNext() + { + return this.innerEnumerator.MoveNext(); + } + + public void Reset() + { + this.innerEnumerator.Reset(); + } + } + + public IEnumerator GetEnumerator() + { + return new Enumerator(this.session, this.messageQueue); + } + } +} http://git-wip-us.apache.org/repos/asf/activemq-nms-msmq/blob/51ec9a29/src/main/csharp/Session.cs ---------------------------------------------------------------------- diff --git a/src/main/csharp/Session.cs b/src/main/csharp/Session.cs index 9ce99f6..5172c08 100644 --- a/src/main/csharp/Session.cs +++ b/src/main/csharp/Session.cs @@ -90,12 +90,17 @@ namespace Apache.NMS.MSMQ public IQueueBrowser CreateBrowser(IQueue queue) { - throw new NotImplementedException(); + return CreateBrowser(queue, null); } public IQueueBrowser CreateBrowser(IQueue queue, string selector) { - throw new NotImplementedException(); + if(selector != null) + { + throw new NotSupportedException("Selectors are not supported by MSMQ"); + } + MessageQueue msmqQueue = MessageConverter.ToMsmqDestination(queue); + return new QueueBrowser(this, msmqQueue); } public IQueue GetQueue(string name) @@ -110,12 +115,12 @@ namespace Apache.NMS.MSMQ public ITemporaryQueue CreateTemporaryQueue() { - throw new NotSupportedException("Tempoary Queues are not supported by MSMQ"); + throw new NotSupportedException("Temporary Queues are not supported by MSMQ"); } public ITemporaryTopic CreateTemporaryTopic() { - throw new NotSupportedException("Tempoary Topics are not supported by MSMQ"); + throw new NotSupportedException("Temporary Topics are not supported by MSMQ"); } /// @@ -123,8 +128,7 @@ namespace Apache.NMS.MSMQ /// public void DeleteDestination(IDestination destination) { - // TODO: Implement if possible. If not possible, then change exception to NotSupportedException(). - throw new NotImplementedException(); + MessageQueue.Delete(destination.ToString()); } public IMessage CreateMessage() http://git-wip-us.apache.org/repos/asf/activemq-nms-msmq/blob/51ec9a29/vs2008-msmq.csproj ---------------------------------------------------------------------- diff --git a/vs2008-msmq.csproj b/vs2008-msmq.csproj index 6221c67..8a20d12 100644 --- a/vs2008-msmq.csproj +++ b/vs2008-msmq.csproj @@ -80,6 +80,7 @@ +