Return-Path: X-Original-To: apmail-activemq-commits-archive@www.apache.org Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D539118D5E for ; Wed, 13 Jan 2016 23:24:11 +0000 (UTC) Received: (qmail 55902 invoked by uid 500); 13 Jan 2016 23:24:11 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 55861 invoked by uid 500); 13 Jan 2016 23:24:11 -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 55852 invoked by uid 99); 13 Jan 2016 23:24:11 -0000 Received: from Unknown (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 13 Jan 2016 23:24:11 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 4BD2C1A0490 for ; Wed, 13 Jan 2016 23:24:11 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.246 X-Spam-Level: * X-Spam-Status: No, score=1.246 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RP_MATCHES_RCVD=-0.554] autolearn=disabled Received: from mx1-us-east.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id r3uxkkmHDIh6 for ; Wed, 13 Jan 2016 23:24:09 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-us-east.apache.org (ASF Mail Server at mx1-us-east.apache.org) with ESMTP id 7C8A842ADC for ; Wed, 13 Jan 2016 23:24:09 +0000 (UTC) Received: from svn01-us-west.apache.org (svn.apache.org [10.41.0.6]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id E46A9E01D9 for ; Wed, 13 Jan 2016 23:24:08 +0000 (UTC) Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id BF5D53A01DB for ; Wed, 13 Jan 2016 23:24:08 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1724526 - in /activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk: src/main/csharp/QueueBrowser.cs src/main/csharp/Session.cs vs2008-msmq.csproj Date: Wed, 13 Jan 2016 23:24:08 -0000 To: commits@activemq.apache.org From: jgomes@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20160113232408.BF5D53A01DB@svn01-us-west.apache.org> Author: jgomes Date: Wed Jan 13 23:24:08 2016 New Revision: 1724526 URL: http://svn.apache.org/viewvc?rev=1724526&view=rev Log: Applied patch from Stephane Ramet to implement QueueBrowser and DeleteDestination. Thanks Stephane! Fixes [AMQNET-517]. (See https://issues.apache.org/jira/browse/AMQNET-517) Added: activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/QueueBrowser.cs Modified: activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/Session.cs activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/vs2008-msmq.csproj Added: activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/QueueBrowser.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/QueueBrowser.cs?rev=1724526&view=auto ============================================================================== --- activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/QueueBrowser.cs (added) +++ activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/QueueBrowser.cs Wed Jan 13 23:24:08 2016 @@ -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); + } + } +} Modified: activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/Session.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/Session.cs?rev=1724526&r1=1724525&r2=1724526&view=diff ============================================================================== --- activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/Session.cs (original) +++ activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/Session.cs Wed Jan 13 23:24:08 2016 @@ -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() Modified: activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/vs2008-msmq.csproj URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/vs2008-msmq.csproj?rev=1724526&r1=1724525&r2=1724526&view=diff ============================================================================== --- activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/vs2008-msmq.csproj (original) +++ activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/vs2008-msmq.csproj Wed Jan 13 23:24:08 2016 @@ -80,6 +80,7 @@ +