Return-Path: Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: (qmail 64909 invoked from network); 29 Oct 2007 14:02:08 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 29 Oct 2007 14:02:08 -0000 Received: (qmail 34610 invoked by uid 500); 29 Oct 2007 14:00:59 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 34584 invoked by uid 500); 29 Oct 2007 14:00:59 -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 34568 invoked by uid 99); 29 Oct 2007 14:00:59 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 29 Oct 2007 07:00:59 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 29 Oct 2007 14:01:12 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id B3F531A984F; Mon, 29 Oct 2007 07:00:18 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r589629 [5/7] - in /activemq/activemq-dotnet/trunk: ./ src/main/csharp/ActiveMQ/ src/main/csharp/ActiveMQ/Commands/ src/main/csharp/ActiveMQ/OpenWire/ src/main/csharp/ActiveMQ/OpenWire/V1/ src/main/csharp/ActiveMQ/OpenWire/V2/ src/main/csha... Date: Mon, 29 Oct 2007 13:55:57 -0000 To: commits@activemq.apache.org From: chirino@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20071029140018.B3F531A984F@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Modified: activemq/activemq-dotnet/trunk/src/main/csharp/MSMQ/MapMessage.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/MSMQ/MapMessage.cs?rev=589629&r1=589628&r2=589629&view=diff ============================================================================== --- activemq/activemq-dotnet/trunk/src/main/csharp/MSMQ/MapMessage.cs (original) +++ activemq/activemq-dotnet/trunk/src/main/csharp/MSMQ/MapMessage.cs Mon Oct 29 06:55:09 2007 @@ -14,43 +14,20 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -using NMS; +using Apache.NMS; using System; -namespace MSMQ +namespace Apache.MSMQ { public class MapMessage : BaseMessage, IMapMessage { - private PrimitiveMap body; + private PrimitiveMap body = new PrimitiveMap(); public IPrimitiveMap Body { - get { - if (body == null) - { - // body = PrimitiveMap.Unmarshal(Content); - } - return body; - } + get { return body; } } - -// public override void BeforeMarshall(OpenWireFormat wireFormat) -// { -// if (body == null) -// { -// Content = null; -// } -// else -// { -// Content = body.Marshal(); -// } -// -// Console.WriteLine("BeforeMarshalling, content is: " + Content); -// -// base.BeforeMarshall(wireFormat); -// } - } } Modified: activemq/activemq-dotnet/trunk/src/main/csharp/MSMQ/MessageConsumer.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/MSMQ/MessageConsumer.cs?rev=589629&r1=589628&r2=589629&view=diff ============================================================================== --- activemq/activemq-dotnet/trunk/src/main/csharp/MSMQ/MessageConsumer.cs (original) +++ activemq/activemq-dotnet/trunk/src/main/csharp/MSMQ/MessageConsumer.cs Mon Oct 29 06:55:09 2007 @@ -14,14 +14,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -using ActiveMQ; -using ActiveMQ.Util; -using NMS; +using Apache.ActiveMQ; +using Apache.ActiveMQ.Util; +using Apache.NMS; using System; using System.Messaging; using System.Threading; -namespace MSMQ +namespace Apache.MSMQ { /// /// An object capable of receiving messages from some destination Modified: activemq/activemq-dotnet/trunk/src/main/csharp/MSMQ/MessageProducer.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/MSMQ/MessageProducer.cs?rev=589629&r1=589628&r2=589629&view=diff ============================================================================== --- activemq/activemq-dotnet/trunk/src/main/csharp/MSMQ/MessageProducer.cs (original) +++ activemq/activemq-dotnet/trunk/src/main/csharp/MSMQ/MessageProducer.cs Mon Oct 29 06:55:09 2007 @@ -16,9 +16,9 @@ */ using System; using System.Messaging; -using NMS; +using Apache.NMS; -namespace MSMQ +namespace Apache.MSMQ { /// /// An object capable of sending messages to some destination @@ -123,7 +123,7 @@ // Convert the Mesasge into a MSMQ message message.NMSPersistent = persistent; - message.NMSExpiration = timeToLive; + message.NMSTimeToLive = timeToLive; message.NMSPriority = priority; // message.NMSTimestamp = new DateTime().Date.; Modified: activemq/activemq-dotnet/trunk/src/main/csharp/MSMQ/ObjectMessage.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/MSMQ/ObjectMessage.cs?rev=589629&r1=589628&r2=589629&view=diff ============================================================================== --- activemq/activemq-dotnet/trunk/src/main/csharp/MSMQ/ObjectMessage.cs (original) +++ activemq/activemq-dotnet/trunk/src/main/csharp/MSMQ/ObjectMessage.cs Mon Oct 29 06:55:09 2007 @@ -15,7 +15,7 @@ * limitations under the License. */ -using NMS; +using Apache.NMS; using System; using System.Collections; using System.IO; @@ -25,7 +25,7 @@ using System.Runtime.Serialization.Formatters.Binary; #endif -namespace MSMQ +namespace Apache.MSMQ { public class ObjectMessage : BaseMessage, IObjectMessage { Modified: activemq/activemq-dotnet/trunk/src/main/csharp/MSMQ/PrimitiveMap.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/MSMQ/PrimitiveMap.cs?rev=589629&r1=589628&r2=589629&view=diff ============================================================================== --- activemq/activemq-dotnet/trunk/src/main/csharp/MSMQ/PrimitiveMap.cs (original) +++ activemq/activemq-dotnet/trunk/src/main/csharp/MSMQ/PrimitiveMap.cs Mon Oct 29 06:55:09 2007 @@ -14,12 +14,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -using NMS; +using Apache.NMS; using System; using System.Collections; using System.Collections.Generic; -namespace MSMQ +namespace Apache.MSMQ { /// /// A default implementation of IPrimitiveMap Modified: activemq/activemq-dotnet/trunk/src/main/csharp/MSMQ/Queue.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/MSMQ/Queue.cs?rev=589629&r1=589628&r2=589629&view=diff ============================================================================== --- activemq/activemq-dotnet/trunk/src/main/csharp/MSMQ/Queue.cs (original) +++ activemq/activemq-dotnet/trunk/src/main/csharp/MSMQ/Queue.cs Mon Oct 29 06:55:09 2007 @@ -14,10 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -using NMS; +using Apache.NMS; using System; -namespace MSMQ +namespace Apache.MSMQ { /// Modified: activemq/activemq-dotnet/trunk/src/main/csharp/MSMQ/Session.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/MSMQ/Session.cs?rev=589629&r1=589628&r2=589629&view=diff ============================================================================== --- activemq/activemq-dotnet/trunk/src/main/csharp/MSMQ/Session.cs (original) +++ activemq/activemq-dotnet/trunk/src/main/csharp/MSMQ/Session.cs Mon Oct 29 06:55:09 2007 @@ -14,11 +14,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -using NMS; +using Apache.NMS; using System; using System.Messaging; -namespace MSMQ +namespace Apache.MSMQ { /// /// MSQM provider of ISession Modified: activemq/activemq-dotnet/trunk/src/main/csharp/MSMQ/StreamMessage.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/MSMQ/StreamMessage.cs?rev=589629&r1=589628&r2=589629&view=diff ============================================================================== --- activemq/activemq-dotnet/trunk/src/main/csharp/MSMQ/StreamMessage.cs (original) +++ activemq/activemq-dotnet/trunk/src/main/csharp/MSMQ/StreamMessage.cs Mon Oct 29 06:55:09 2007 @@ -15,7 +15,7 @@ * limitations under the License. */ -namespace MSMQ +namespace Apache.MSMQ { public class StreamMessage : BaseMessage { Modified: activemq/activemq-dotnet/trunk/src/main/csharp/MSMQ/TextMessage.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/MSMQ/TextMessage.cs?rev=589629&r1=589628&r2=589629&view=diff ============================================================================== --- activemq/activemq-dotnet/trunk/src/main/csharp/MSMQ/TextMessage.cs (original) +++ activemq/activemq-dotnet/trunk/src/main/csharp/MSMQ/TextMessage.cs Mon Oct 29 06:55:09 2007 @@ -14,11 +14,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -using NMS; +using Apache.NMS; using System; -namespace MSMQ +namespace Apache.MSMQ { public class TextMessage : BaseMessage, ITextMessage { Modified: activemq/activemq-dotnet/trunk/src/main/csharp/NMS/CommonAssemblyInfo.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/NMS/CommonAssemblyInfo.cs?rev=589629&r1=589628&r2=589629&view=diff ============================================================================== --- activemq/activemq-dotnet/trunk/src/main/csharp/NMS/CommonAssemblyInfo.cs (original) +++ activemq/activemq-dotnet/trunk/src/main/csharp/NMS/CommonAssemblyInfo.cs Mon Oct 29 06:55:09 2007 @@ -5,7 +5,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:2.0.50727.42 +// Runtime Version:2.0.50727.832 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. Modified: activemq/activemq-dotnet/trunk/src/main/csharp/NMS/IBytesMessage.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/NMS/IBytesMessage.cs?rev=589629&r1=589628&r2=589629&view=diff ============================================================================== --- activemq/activemq-dotnet/trunk/src/main/csharp/NMS/IBytesMessage.cs (original) +++ activemq/activemq-dotnet/trunk/src/main/csharp/NMS/IBytesMessage.cs Mon Oct 29 06:55:09 2007 @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -namespace NMS +namespace Apache.NMS { /// /// Represents a binary based message Modified: activemq/activemq-dotnet/trunk/src/main/csharp/NMS/IConnection.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/NMS/IConnection.cs?rev=589629&r1=589628&r2=589629&view=diff ============================================================================== --- activemq/activemq-dotnet/trunk/src/main/csharp/NMS/IConnection.cs (original) +++ activemq/activemq-dotnet/trunk/src/main/csharp/NMS/IConnection.cs Mon Oct 29 06:55:09 2007 @@ -16,18 +16,17 @@ */ using System; -namespace NMS { +namespace Apache.NMS { /// /// The mode used to acknowledge messages after they are consumed /// public enum AcknowledgementMode { /** - * With this acknowledgment mode, the session automatically - * acknowledges a client's receipt of a message either when - * the session has successfully returned from a call to receive - * or when the message listener the session has called to - * process the message successfully returns. + * With this acknowledgment mode, the session will not + * acknowledge receipt of a message since the broker assumes + * successful receipt of a message after the onMessage handler + * has returned without error. */ AutoAcknowledge, @@ -48,9 +47,21 @@ */ ClientAcknowledge, - /** - * Messages will be consumed when the transaction commits. - */ + /** + * With this acknowledgment mode, the session automatically + * acknowledges a client's receipt of a message either when + * the session has successfully returned from a call to receive + * or when the message listener the session has called to + * process the message successfully returns. The broker is + * set to ClientAcknowledge mode, but no manual acknowledgements + * are necessary from the client code. This mode is useful for + * controlling the flow of messages to the client. + */ + AutoClientAcknowledge, + + /** + * Messages will be consumed when the transaction commits. + */ Transactional } Modified: activemq/activemq-dotnet/trunk/src/main/csharp/NMS/IConnectionFactory.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/NMS/IConnectionFactory.cs?rev=589629&r1=589628&r2=589629&view=diff ============================================================================== --- activemq/activemq-dotnet/trunk/src/main/csharp/NMS/IConnectionFactory.cs (original) +++ activemq/activemq-dotnet/trunk/src/main/csharp/NMS/IConnectionFactory.cs Mon Oct 29 06:55:09 2007 @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -namespace NMS +namespace Apache.NMS { /// Modified: activemq/activemq-dotnet/trunk/src/main/csharp/NMS/IDestination.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/NMS/IDestination.cs?rev=589629&r1=589628&r2=589629&view=diff ============================================================================== --- activemq/activemq-dotnet/trunk/src/main/csharp/NMS/IDestination.cs (original) +++ activemq/activemq-dotnet/trunk/src/main/csharp/NMS/IDestination.cs Mon Oct 29 06:55:09 2007 @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -namespace NMS +namespace Apache.NMS { /// /// Represents the type of the destination such as a queue or topic. Modified: activemq/activemq-dotnet/trunk/src/main/csharp/NMS/IMapMessage.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/NMS/IMapMessage.cs?rev=589629&r1=589628&r2=589629&view=diff ============================================================================== --- activemq/activemq-dotnet/trunk/src/main/csharp/NMS/IMapMessage.cs (original) +++ activemq/activemq-dotnet/trunk/src/main/csharp/NMS/IMapMessage.cs Mon Oct 29 06:55:09 2007 @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -namespace NMS +namespace Apache.NMS { /// Modified: activemq/activemq-dotnet/trunk/src/main/csharp/NMS/IMessage.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/NMS/IMessage.cs?rev=589629&r1=589628&r2=589629&view=diff ============================================================================== --- activemq/activemq-dotnet/trunk/src/main/csharp/NMS/IMessage.cs (original) +++ activemq/activemq-dotnet/trunk/src/main/csharp/NMS/IMessage.cs Mon Oct 29 06:55:09 2007 @@ -16,7 +16,7 @@ */ using System; -namespace NMS +namespace Apache.NMS { /// /// Represents a message either to be sent to a message broker or received from a message broker @@ -59,7 +59,7 @@ /// The amount of time that this message is valid for. null If this /// message does not expire. /// - TimeSpan NMSExpiration + TimeSpan NMSTimeToLive { get; set; Modified: activemq/activemq-dotnet/trunk/src/main/csharp/NMS/IMessageConsumer.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/NMS/IMessageConsumer.cs?rev=589629&r1=589628&r2=589629&view=diff ============================================================================== --- activemq/activemq-dotnet/trunk/src/main/csharp/NMS/IMessageConsumer.cs (original) +++ activemq/activemq-dotnet/trunk/src/main/csharp/NMS/IMessageConsumer.cs Mon Oct 29 06:55:09 2007 @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -namespace NMS +namespace Apache.NMS { /// /// A delegate that can receive messages async. Modified: activemq/activemq-dotnet/trunk/src/main/csharp/NMS/IMessageProducer.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/NMS/IMessageProducer.cs?rev=589629&r1=589628&r2=589629&view=diff ============================================================================== --- activemq/activemq-dotnet/trunk/src/main/csharp/NMS/IMessageProducer.cs (original) +++ activemq/activemq-dotnet/trunk/src/main/csharp/NMS/IMessageProducer.cs Mon Oct 29 06:55:09 2007 @@ -16,7 +16,7 @@ */ using System; -namespace NMS +namespace Apache.NMS { /// Modified: activemq/activemq-dotnet/trunk/src/main/csharp/NMS/IObjectMessage.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/NMS/IObjectMessage.cs?rev=589629&r1=589628&r2=589629&view=diff ============================================================================== --- activemq/activemq-dotnet/trunk/src/main/csharp/NMS/IObjectMessage.cs (original) +++ activemq/activemq-dotnet/trunk/src/main/csharp/NMS/IObjectMessage.cs Mon Oct 29 06:55:09 2007 @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -namespace NMS +namespace Apache.NMS { /// /// Represents an Object message which contains a serializable .Net object. Modified: activemq/activemq-dotnet/trunk/src/main/csharp/NMS/IPrimitiveMap.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/NMS/IPrimitiveMap.cs?rev=589629&r1=589628&r2=589629&view=diff ============================================================================== --- activemq/activemq-dotnet/trunk/src/main/csharp/NMS/IPrimitiveMap.cs (original) +++ activemq/activemq-dotnet/trunk/src/main/csharp/NMS/IPrimitiveMap.cs Mon Oct 29 06:55:09 2007 @@ -16,7 +16,7 @@ */ using System.Collections; -namespace NMS +namespace Apache.NMS { /// Modified: activemq/activemq-dotnet/trunk/src/main/csharp/NMS/IQueue.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/NMS/IQueue.cs?rev=589629&r1=589628&r2=589629&view=diff ============================================================================== --- activemq/activemq-dotnet/trunk/src/main/csharp/NMS/IQueue.cs (original) +++ activemq/activemq-dotnet/trunk/src/main/csharp/NMS/IQueue.cs Mon Oct 29 06:55:09 2007 @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -namespace NMS +namespace Apache.NMS { /// /// Represents a queue in a message broker. A message sent to a queue is delivered Modified: activemq/activemq-dotnet/trunk/src/main/csharp/NMS/ISession.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/NMS/ISession.cs?rev=589629&r1=589628&r2=589629&view=diff ============================================================================== --- activemq/activemq-dotnet/trunk/src/main/csharp/NMS/ISession.cs (original) +++ activemq/activemq-dotnet/trunk/src/main/csharp/NMS/ISession.cs Mon Oct 29 06:55:09 2007 @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -namespace NMS { +namespace Apache.NMS { /// /// Represents a single unit of work on an IConnection. /// So the ISession can be used to perform transactional receive and sends Modified: activemq/activemq-dotnet/trunk/src/main/csharp/NMS/IStartable.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/NMS/IStartable.cs?rev=589629&r1=589628&r2=589629&view=diff ============================================================================== --- activemq/activemq-dotnet/trunk/src/main/csharp/NMS/IStartable.cs (original) +++ activemq/activemq-dotnet/trunk/src/main/csharp/NMS/IStartable.cs Mon Oct 29 06:55:09 2007 @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -namespace NMS +namespace Apache.NMS { /// /// A lifecycle for NMS objects to indicate they can be started Modified: activemq/activemq-dotnet/trunk/src/main/csharp/NMS/IStoppable.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/NMS/IStoppable.cs?rev=589629&r1=589628&r2=589629&view=diff ============================================================================== --- activemq/activemq-dotnet/trunk/src/main/csharp/NMS/IStoppable.cs (original) +++ activemq/activemq-dotnet/trunk/src/main/csharp/NMS/IStoppable.cs Mon Oct 29 06:55:09 2007 @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -namespace NMS +namespace Apache.NMS { /// /// A lifecycle for NMS objects to indicate they can be stopped Modified: activemq/activemq-dotnet/trunk/src/main/csharp/NMS/ITemporaryQueue.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/NMS/ITemporaryQueue.cs?rev=589629&r1=589628&r2=589629&view=diff ============================================================================== --- activemq/activemq-dotnet/trunk/src/main/csharp/NMS/ITemporaryQueue.cs (original) +++ activemq/activemq-dotnet/trunk/src/main/csharp/NMS/ITemporaryQueue.cs Mon Oct 29 06:55:09 2007 @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -namespace NMS +namespace Apache.NMS { /// /// Represents a temporary queue which exists for the duration Modified: activemq/activemq-dotnet/trunk/src/main/csharp/NMS/ITemporaryTopic.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/NMS/ITemporaryTopic.cs?rev=589629&r1=589628&r2=589629&view=diff ============================================================================== --- activemq/activemq-dotnet/trunk/src/main/csharp/NMS/ITemporaryTopic.cs (original) +++ activemq/activemq-dotnet/trunk/src/main/csharp/NMS/ITemporaryTopic.cs Mon Oct 29 06:55:09 2007 @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -namespace NMS +namespace Apache.NMS { /// /// Represents a temporary topic which exists for the duration Modified: activemq/activemq-dotnet/trunk/src/main/csharp/NMS/ITextMessage.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/NMS/ITextMessage.cs?rev=589629&r1=589628&r2=589629&view=diff ============================================================================== --- activemq/activemq-dotnet/trunk/src/main/csharp/NMS/ITextMessage.cs (original) +++ activemq/activemq-dotnet/trunk/src/main/csharp/NMS/ITextMessage.cs Mon Oct 29 06:55:09 2007 @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -namespace NMS +namespace Apache.NMS { /// /// Represents a text based message Modified: activemq/activemq-dotnet/trunk/src/main/csharp/NMS/ITopic.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/NMS/ITopic.cs?rev=589629&r1=589628&r2=589629&view=diff ============================================================================== --- activemq/activemq-dotnet/trunk/src/main/csharp/NMS/ITopic.cs (original) +++ activemq/activemq-dotnet/trunk/src/main/csharp/NMS/ITopic.cs Mon Oct 29 06:55:09 2007 @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -namespace NMS +namespace Apache.NMS { /// /// Represents a topic in a message broker. A message sent to a topic Added: activemq/activemq-dotnet/trunk/src/main/csharp/NMS/ITrace.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/NMS/ITrace.cs?rev=589629&view=auto ============================================================================== --- activemq/activemq-dotnet/trunk/src/main/csharp/NMS/ITrace.cs (added) +++ activemq/activemq-dotnet/trunk/src/main/csharp/NMS/ITrace.cs Mon Oct 29 06:55:09 2007 @@ -0,0 +1,46 @@ +// +// Copyright 2001-2006 The Apache Software Foundation +// +// Licensed 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 +{ + /// + /// The ITrace interface is used internally by ActiveMQ to log messages. + /// The client aplication may provide an implementation of ITrace if it wishes to + /// route messages to a specific destination. + /// + /// + /// + /// Use the class to register an instance of ITrace as the + /// active trace destination. + /// + /// + public interface ITrace + { + void Debug(string message); + void Info(string message); + void Warn(string message); + void Error(string message); + void Fatal(object message); + + bool IsDebugEnabled { get; } + bool IsInfoEnabled { get; } + bool IsWarnEnabled { get; } + bool IsErrorEnabled { get; } + bool IsFatalEnabled { get; } + } +} + + Modified: activemq/activemq-dotnet/trunk/src/main/csharp/NMS/InvalidDestinationException.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/NMS/InvalidDestinationException.cs?rev=589629&r1=589628&r2=589629&view=diff ============================================================================== --- activemq/activemq-dotnet/trunk/src/main/csharp/NMS/InvalidDestinationException.cs (original) +++ activemq/activemq-dotnet/trunk/src/main/csharp/NMS/InvalidDestinationException.cs Mon Oct 29 06:55:09 2007 @@ -16,7 +16,7 @@ */ using System; -namespace NMS +namespace Apache.NMS { /// /// An attempt is made to access an invalid destination Modified: activemq/activemq-dotnet/trunk/src/main/csharp/NMS/NMSConnectionException.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/NMS/NMSConnectionException.cs?rev=589629&r1=589628&r2=589629&view=diff ============================================================================== --- activemq/activemq-dotnet/trunk/src/main/csharp/NMS/NMSConnectionException.cs (original) +++ activemq/activemq-dotnet/trunk/src/main/csharp/NMS/NMSConnectionException.cs Mon Oct 29 06:55:09 2007 @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -namespace NMS +namespace Apache.NMS { /// /// Represents a connection failure. Modified: activemq/activemq-dotnet/trunk/src/main/csharp/NMS/NMSConstants.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/NMS/NMSConstants.cs?rev=589629&r1=589628&r2=589629&view=diff ============================================================================== --- activemq/activemq-dotnet/trunk/src/main/csharp/NMS/NMSConstants.cs (original) +++ activemq/activemq-dotnet/trunk/src/main/csharp/NMS/NMSConstants.cs Mon Oct 29 06:55:09 2007 @@ -16,15 +16,16 @@ */ using System; -namespace NMS +namespace Apache.NMS { /// /// Defines a number of constants /// public class NMSConstants { - public const int defaultPriority = 5; + public const byte defaultPriority = 5; public const bool defaultPersistence = true; + public static readonly TimeSpan defaultTimeToLive = TimeSpan.Zero; } } Modified: activemq/activemq-dotnet/trunk/src/main/csharp/NMS/NMSException.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/NMS/NMSException.cs?rev=589629&r1=589628&r2=589629&view=diff ============================================================================== --- activemq/activemq-dotnet/trunk/src/main/csharp/NMS/NMSException.cs (original) +++ activemq/activemq-dotnet/trunk/src/main/csharp/NMS/NMSException.cs Mon Oct 29 06:55:09 2007 @@ -16,7 +16,7 @@ */ using System; -namespace NMS +namespace Apache.NMS { /// /// Represents a NMS exception Added: activemq/activemq-dotnet/trunk/src/main/csharp/NMS/NMSFactory.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/NMS/NMSFactory.cs?rev=589629&view=auto ============================================================================== --- activemq/activemq-dotnet/trunk/src/main/csharp/NMS/NMSFactory.cs (added) +++ activemq/activemq-dotnet/trunk/src/main/csharp/NMS/NMSFactory.cs Mon Oct 29 06:55:09 2007 @@ -0,0 +1,111 @@ +/* + * 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.Reflection; + +namespace Apache.NMS +{ + public class NMSFactory + { + public static IConnectionFactory CreateConnectionFactory(string providerURLs, params object[] constructorParams) + { + return CreateConnectionFactory(new Uri(providerURLs), constructorParams); + } + + /// + /// The ConnectionFactory object must define a constructor that takes as a minimum a Uri object. + /// Any additional parameters are optional, but will typically include a Client ID string. + /// + /// + /// + /// + public static IConnectionFactory CreateConnectionFactory(Uri uriProvider, params object[] constructorParams) + { + Apache.NMS.IConnectionFactory connectionFactory = null; + + try + { + ConnectionFactoryInfo cfi; + + if(LookupConnectionFactoryInfo(uriProvider.Scheme, out cfi)) + { + Assembly assembly = Assembly.LoadFrom(cfi.assemblyFileName); + Type factoryType = assembly.GetType(cfi.factoryClassName, true, true); + object[] parameters = GetParameters(uriProvider, constructorParams); + connectionFactory = (Apache.NMS.IConnectionFactory) Activator.CreateInstance(factoryType, parameters); + } + } + catch(Exception ex) + { + Tracer.ErrorFormat("Error creating ConnectionFactory: {0}", ex.Message); + connectionFactory = null; + } + + return connectionFactory; + } + + /// + /// Create an object array containing the parameters to pass to the constructor. + /// + /// + /// + /// + protected static object[] GetParameters(object firstParam, params object[] varParams) + { + ArrayList paramList = new ArrayList(); + + paramList.Add(firstParam); + foreach(object param in varParams) + { + paramList.Add(param); + } + + return paramList.ToArray(); + } + + protected class ConnectionFactoryInfo + { + public string assemblyFileName; + public string factoryClassName; + } + + protected static bool LookupConnectionFactoryInfo(string scheme, out ConnectionFactoryInfo cfi) + { + cfi = new ConnectionFactoryInfo(); + + // TODO: Read an external configuration file that maps scheme to provider implementation. + if(String.Compare(scheme, "tibco", true) == 0) + { + cfi.assemblyFileName = "Apache.NMS.TIBCO.dll"; + cfi.factoryClassName = "Apache.TibcoEMS.ConnectionFactory"; + } + else if(String.Compare(scheme, "msmq", true) == 0) + { + cfi.assemblyFileName = "Apache.NMS.MSMQ.dll"; + cfi.factoryClassName = "Apache.MSMQ.ConnectionFactory"; + } + else + { + cfi.assemblyFileName = "Apache.NMS.ActiveMQ.dll"; + cfi.factoryClassName = "Apache.ActiveMQ.ConnectionFactory"; + } + + return true; + } + } +} Modified: activemq/activemq-dotnet/trunk/src/main/csharp/NMS/NMSSecurityException.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/NMS/NMSSecurityException.cs?rev=589629&r1=589628&r2=589629&view=diff ============================================================================== --- activemq/activemq-dotnet/trunk/src/main/csharp/NMS/NMSSecurityException.cs (original) +++ activemq/activemq-dotnet/trunk/src/main/csharp/NMS/NMSSecurityException.cs Mon Oct 29 06:55:09 2007 @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -namespace NMS +namespace Apache.NMS { /// /// Represents a connection failure. Added: activemq/activemq-dotnet/trunk/src/main/csharp/NMS/Tracer.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/NMS/Tracer.cs?rev=589629&view=auto ============================================================================== --- activemq/activemq-dotnet/trunk/src/main/csharp/NMS/Tracer.cs (added) +++ activemq/activemq-dotnet/trunk/src/main/csharp/NMS/Tracer.cs Mon Oct 29 06:55:09 2007 @@ -0,0 +1,139 @@ +/* + * 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 +{ + public sealed class Tracer + { + private static ITrace s_trace = null; + + // prevent instantiation of this class. All methods are static. + private Tracer() + { + } + + public static ITrace Trace + { + get { return s_trace; } + set { s_trace = value; } + } + + public static bool IsDebugEnabled + { + get { return s_trace != null && s_trace.IsDebugEnabled; } + } + + public static bool IsInfoEnabled + { + get { return s_trace != null && s_trace.IsInfoEnabled; } + } + + public static bool IsWarnEnabled + { + get { return s_trace != null && s_trace.IsWarnEnabled; } + } + + public static bool IsErrorEnabled + { + get { return s_trace != null && s_trace.IsErrorEnabled; } + } + + public static bool IsFatalEnabled + { + get { return s_trace != null && s_trace.IsFatalEnabled; } + } + + public static void Debug(object message) + { + if(IsDebugEnabled) + { + s_trace.Debug(message.ToString()); + } + } + + public static void DebugFormat(string format, params object[] args) + { + if(IsDebugEnabled) + { + s_trace.Debug(string.Format(format, args)); + } + } + + public static void Info(object message) + { + if(IsInfoEnabled) + { + s_trace.Info(message.ToString()); + } + } + + public static void InfoFormat(string format, params object[] args) + { + if(IsInfoEnabled) + { + s_trace.Info(string.Format(format, args)); + } + } + + public static void Warn(object message) + { + if(IsWarnEnabled) + { + s_trace.Warn(message.ToString()); + } + } + + public static void WarnFormat(string format, params object[] args) + { + if(IsWarnEnabled) + { + s_trace.Warn(string.Format(format, args)); + } + } + + public static void Error(object message) + { + if(IsErrorEnabled) + { + s_trace.Error(message.ToString()); + } + } + + public static void ErrorFormat(string format, params object[] args) + { + if(IsErrorEnabled) + { + s_trace.Error(string.Format(format, args)); + } + } + + public static void Fatal(object message) + { + if(IsFatalEnabled) + { + s_trace.Fatal(message.ToString()); + } + } + + public static void FatalFormat(string format, params object[] args) + { + if(IsFatalEnabled) + { + s_trace.Fatal(string.Format(format, args)); + } + } + } +} \ No newline at end of file Added: activemq/activemq-dotnet/trunk/src/main/csharp/TIBCO/BytesMessage.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/TIBCO/BytesMessage.cs?rev=589629&view=auto ============================================================================== --- activemq/activemq-dotnet/trunk/src/main/csharp/TIBCO/BytesMessage.cs (added) +++ activemq/activemq-dotnet/trunk/src/main/csharp/TIBCO/BytesMessage.cs Mon Oct 29 06:55:09 2007 @@ -0,0 +1,56 @@ +/* + * 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.TibcoEMS +{ + class BytesMessage : Apache.TibcoEMS.Message, Apache.NMS.IBytesMessage + { + public TIBCO.EMS.BytesMessage tibcoBytesMessage + { + get { return this.tibcoMessage as TIBCO.EMS.BytesMessage; } + set { this.tibcoMessage = value; } + } + + public BytesMessage(TIBCO.EMS.BytesMessage message) + : base(message) + { + } + + #region IBytesMessage Members + + public byte[] Content + { + get + { + int contentLength = (int) this.tibcoBytesMessage.BodyLength; + byte[] msgContent = new byte[contentLength]; + + this.tibcoBytesMessage.Reset(); + this.tibcoBytesMessage.ReadBytes(msgContent, contentLength); + return msgContent; + } + + set + { + this.tibcoBytesMessage.ClearBody(); + this.tibcoBytesMessage.WriteBytes(value, 0, value.Length); + } + } + + #endregion + } +} Added: activemq/activemq-dotnet/trunk/src/main/csharp/TIBCO/CommonAssemblyInfo.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/TIBCO/CommonAssemblyInfo.cs?rev=589629&view=auto ============================================================================== --- activemq/activemq-dotnet/trunk/src/main/csharp/TIBCO/CommonAssemblyInfo.cs (added) +++ activemq/activemq-dotnet/trunk/src/main/csharp/TIBCO/CommonAssemblyInfo.cs Mon Oct 29 06:55:09 2007 @@ -0,0 +1,27 @@ +using System; +using System.Reflection; +using System.Runtime.InteropServices; + +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +[assembly: ComVisibleAttribute(false)] +[assembly: CLSCompliantAttribute(false)] +[assembly: AssemblyTitleAttribute("Apache NMS for TIBCO")] +[assembly: AssemblyDescriptionAttribute("An NMS (.Net Messaging Library) to TIBCO EMS")] +[assembly: AssemblyConfigurationAttribute("SNAPSHOT")] +[assembly: AssemblyCompanyAttribute("http://activemq.apache.org/")] +[assembly: AssemblyProductAttribute("Apache ActiveMQ")] +[assembly: AssemblyCopyrightAttribute("Copyright (C) 2007 Apache Software Foundation")] +[assembly: AssemblyTrademarkAttribute("")] +[assembly: AssemblyCultureAttribute("")] +[assembly: AssemblyVersionAttribute("4.0")] +[assembly: AssemblyInformationalVersionAttribute("4.0")] + Added: activemq/activemq-dotnet/trunk/src/main/csharp/TIBCO/Connection.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/TIBCO/Connection.cs?rev=589629&view=auto ============================================================================== --- activemq/activemq-dotnet/trunk/src/main/csharp/TIBCO/Connection.cs (added) +++ activemq/activemq-dotnet/trunk/src/main/csharp/TIBCO/Connection.cs Mon Oct 29 06:55:09 2007 @@ -0,0 +1,165 @@ +/* + * 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.TibcoEMS +{ + /// + /// Represents a NMS connection to TIBCO. + /// + /// + public class Connection : Apache.NMS.IConnection + { + private Apache.NMS.AcknowledgementMode acknowledgementMode; + public readonly TIBCO.EMS.Connection tibcoConnection; + private bool closed = false; + private bool disposed = false; + + public Connection(TIBCO.EMS.Connection cnx) + { + this.tibcoConnection = cnx; + this.tibcoConnection.ExceptionHandler += this.HandleTibcoException; + } + + ~Connection() + { + Dispose(false); + } + + #region IStartable Members + + /// + /// Starts message delivery for this connection. + /// + public void Start() + { + this.tibcoConnection.Start(); + } + + #endregion + + #region IStoppable Members + + /// + /// Stop message delivery for this connection. + /// + public void Stop() + { + this.tibcoConnection.Stop(); + } + + #endregion + + #region IConnection Members + + /// + /// Creates a new session to work on this connection + /// + public Apache.NMS.ISession CreateSession() + { + return CreateSession(acknowledgementMode); + } + + /// + /// Creates a new session to work on this connection + /// + public Apache.NMS.ISession CreateSession(Apache.NMS.AcknowledgementMode mode) + { + bool isTransacted = (Apache.NMS.AcknowledgementMode.Transactional == mode); + return TibcoUtil.ToNMSSession(this.tibcoConnection.CreateSession(isTransacted, + TibcoUtil.ToSessionMode(mode))); + } + + public void Close() + { + lock(this) + { + if(closed) + { + return; + } + + this.tibcoConnection.ExceptionHandler -= this.HandleTibcoException; + this.tibcoConnection.Stop(); + this.tibcoConnection.Close(); + closed = true; + } + } + + #endregion + + #region IDisposable Members + + 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; + } + + public Apache.NMS.AcknowledgementMode AcknowledgementMode + { + get { return acknowledgementMode; } + set { acknowledgementMode = value; } + } + + public string ClientId + { + get { return this.tibcoConnection.ClientID; } + set { this.tibcoConnection.ClientID = value; } + } + + public event Apache.NMS.ExceptionListener ExceptionListener; + + #endregion + + private void HandleTibcoException(object sender, TIBCO.EMS.EMSExceptionEventArgs arg) + { + if(ExceptionListener != null) + { + ExceptionListener(arg.Exception); + } + else + { + Apache.NMS.Tracer.Error(arg.Exception); + } + } + } +} Added: activemq/activemq-dotnet/trunk/src/main/csharp/TIBCO/ConnectionFactory.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/TIBCO/ConnectionFactory.cs?rev=589629&view=auto ============================================================================== --- activemq/activemq-dotnet/trunk/src/main/csharp/TIBCO/ConnectionFactory.cs (added) +++ activemq/activemq-dotnet/trunk/src/main/csharp/TIBCO/ConnectionFactory.cs Mon Oct 29 06:55:09 2007 @@ -0,0 +1,114 @@ +/* + * 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; + +namespace Apache.TibcoEMS +{ + /// + /// A Factory that can estbalish NMS connections to TIBCO + /// + public class ConnectionFactory : Apache.NMS.IConnectionFactory + { + public TIBCO.EMS.ConnectionFactory tibcoConnectionFactory; + + public ConnectionFactory() + { + try + { + this.tibcoConnectionFactory = new TIBCO.EMS.ConnectionFactory(); + } + catch(Exception ex) + { + Apache.NMS.Tracer.DebugFormat("Exception instantiating TIBCO.EMS.ConnectionFactory: {0}", ex.Message); + } + + VerifyConnectionFactory(); + } + + public ConnectionFactory(Uri uriProvider) + : this(uriProvider.AbsolutePath) + { + } + + public ConnectionFactory(Uri uriProvider, string clientId) + : this(uriProvider.AbsolutePath, clientId) + { + } + + public ConnectionFactory(string serverUrl) + : this(serverUrl, Guid.NewGuid().ToString()) + { + } + + public ConnectionFactory(string serverUrl, string clientId) + { + try + { + this.tibcoConnectionFactory = new TIBCO.EMS.ConnectionFactory(serverUrl, clientId); + } + catch(Exception ex) + { + Apache.NMS.Tracer.DebugFormat("Exception instantiating TIBCO.EMS.ConnectionFactory: {0}", ex.Message); + } + + VerifyConnectionFactory(); + } + + public ConnectionFactory(string serverUrl, string clientId, Hashtable properties) + { + try + { + this.tibcoConnectionFactory = new TIBCO.EMS.ConnectionFactory(serverUrl, clientId, properties); + } + catch(Exception ex) + { + Apache.NMS.Tracer.DebugFormat("Exception instantiating TIBCO.EMS.ConnectionFactory: {0}", ex.Message); + } + + VerifyConnectionFactory(); + } + + private void VerifyConnectionFactory() + { + if(null == this.tibcoConnectionFactory) + { + throw new Apache.NMS.NMSException("Error instantiating TIBCO connection factory object."); + } + } + + #region IConnectionFactory Members + + /// + /// Creates a new connection to TIBCO. + /// + public Apache.NMS.IConnection CreateConnection() + { + return TibcoUtil.ToNMSConnection(this.tibcoConnectionFactory.CreateConnection()); + } + + /// + /// Creates a new connection to TIBCO. + /// + public Apache.NMS.IConnection CreateConnection(string userName, string password) + { + return TibcoUtil.ToNMSConnection(this.tibcoConnectionFactory.CreateConnection(userName, password)); + } + + #endregion + } +} Added: activemq/activemq-dotnet/trunk/src/main/csharp/TIBCO/Destination.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/TIBCO/Destination.cs?rev=589629&view=auto ============================================================================== --- activemq/activemq-dotnet/trunk/src/main/csharp/TIBCO/Destination.cs (added) +++ activemq/activemq-dotnet/trunk/src/main/csharp/TIBCO/Destination.cs Mon Oct 29 06:55:09 2007 @@ -0,0 +1,29 @@ +/* + * 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.TibcoEMS +{ + public class Destination + { + public TIBCO.EMS.Destination tibcoDestination; + + public Destination(TIBCO.EMS.Destination destination) + { + this.tibcoDestination = destination; + } + } +} Added: activemq/activemq-dotnet/trunk/src/main/csharp/TIBCO/Dispatcher.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/TIBCO/Dispatcher.cs?rev=589629&view=auto ============================================================================== --- activemq/activemq-dotnet/trunk/src/main/csharp/TIBCO/Dispatcher.cs (added) +++ activemq/activemq-dotnet/trunk/src/main/csharp/TIBCO/Dispatcher.cs Mon Oct 29 06:55:09 2007 @@ -0,0 +1,168 @@ +/* + * 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.Threading; + +namespace Apache.TibcoEMS +{ + /// + /// Handles the multi-threaded dispatching between the transport and the consumers + /// + public class Dispatcher + { + System.Collections.Queue queue = new System.Collections.Queue(); + readonly Object semaphore = new Object(); + readonly ArrayList messagesToRedeliver = new ArrayList(); + + // TODO can't use EventWaitHandle on MONO 1.0 + AutoResetEvent messageReceivedEventHandle = new AutoResetEvent(false); + bool m_bAsyncDelivery = false; + bool m_bClosed = false; + + public void SetAsyncDelivery(AutoResetEvent eventHandle) + { + lock (semaphore) + { + messageReceivedEventHandle = eventHandle; + m_bAsyncDelivery = true; + if (queue.Count > 0) + { + messageReceivedEventHandle.Set(); + } + } + } + + /// + /// Whem we start a transaction we must redeliver any rolled back messages + /// + public void RedeliverRolledBackMessages() + { + lock (semaphore) + { + System.Collections.Queue replacement = new System.Collections.Queue(queue.Count + messagesToRedeliver.Count); + foreach (Apache.NMS.IMessage element in messagesToRedeliver) + { + replacement.Enqueue(element); + } + messagesToRedeliver.Clear(); + + while (queue.Count > 0) + { + Apache.NMS.IMessage element = (Apache.NMS.IMessage) queue.Dequeue(); + replacement.Enqueue(element); + } + + queue = replacement; + if (queue.Count > 0) + { + messageReceivedEventHandle.Set(); + } + } + } + + /// + /// Redeliver the given message, putting it at the head of the queue + /// + public void Redeliver(Apache.NMS.IMessage message) + { + lock (semaphore) + { + messagesToRedeliver.Add(message); + } + } + + /// + /// Method Enqueue + /// + public void Enqueue(Apache.NMS.IMessage message) + { + lock (semaphore) + { + queue.Enqueue(message); + messageReceivedEventHandle.Set(); + } + } + + /// + /// Method DequeueNoWait + /// + public Apache.NMS.IMessage DequeueNoWait() + { + Apache.NMS.IMessage rc = null; + lock (semaphore) + { + if (!m_bClosed && queue.Count > 0) + { + rc = (Apache.NMS.IMessage) queue.Dequeue(); + } + } + return rc; + } + + /// + /// Method Dequeue + /// + public Apache.NMS.IMessage Dequeue(TimeSpan timeout) + { + Apache.NMS.IMessage rc; + bool bClosed = false; + lock (semaphore) + { + bClosed = m_bClosed; + rc = DequeueNoWait(); + } + + while (!bClosed && rc == null) + { + if( !messageReceivedEventHandle.WaitOne(timeout, false)) + { + break; + } + + lock (semaphore) + { + rc = DequeueNoWait(); + bClosed = m_bClosed; + } + } + return rc; + } + + /// + /// Method Dequeue + /// + public Apache.NMS.IMessage Dequeue() + { + TimeSpan indefiniteWait = TimeSpan.FromMilliseconds(Timeout.Infinite); + return Dequeue(indefiniteWait); + } + + public void Close() + { + lock (semaphore) + { + m_bClosed = true; + queue.Clear(); + if(m_bAsyncDelivery) + { + messageReceivedEventHandle.Set(); + } + } + } + } +} Added: activemq/activemq-dotnet/trunk/src/main/csharp/TIBCO/MapMessage.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/TIBCO/MapMessage.cs?rev=589629&view=auto ============================================================================== --- activemq/activemq-dotnet/trunk/src/main/csharp/TIBCO/MapMessage.cs (added) +++ activemq/activemq-dotnet/trunk/src/main/csharp/TIBCO/MapMessage.cs Mon Oct 29 06:55:09 2007 @@ -0,0 +1,249 @@ +/* + * 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; + +namespace Apache.TibcoEMS +{ + class MapMessage : Apache.TibcoEMS.Message, Apache.NMS.IMapMessage, Apache.NMS.IPrimitiveMap + { + public TIBCO.EMS.MapMessage tibcoMapMessage + { + get { return this.tibcoMessage as TIBCO.EMS.MapMessage; } + set { this.tibcoMessage = value; } + } + + public MapMessage(TIBCO.EMS.MapMessage message) + : base(message) + { + } + + #region IMapMessage Members + + public Apache.NMS.IPrimitiveMap Body + { + get { return this; } + } + + #endregion + + private class MapEnumerable : IEnumerable + { + private readonly TIBCO.EMS.MapMessage tibcoMapMessage; + public MapEnumerable(TIBCO.EMS.MapMessage message) + { + this.tibcoMapMessage = message; + } + + public IEnumerator GetEnumerator() + { + return tibcoMapMessage.MapNames; + } + } + + #region IPrimitiveMap Members + + public void Clear() + { + this.tibcoMapMessage.ClearBody(); + } + + public bool Contains(object key) + { + return this.tibcoMapMessage.ItemExists(key.ToString()); + } + + public void Remove(object key) + { + // Best guess at equivalent implementation. + this.tibcoMapMessage.SetObject(key.ToString(), null); + } + + public int Count + { + get + { + int count = 0; + MapEnumerable mapItems = new MapEnumerable(this.tibcoMapMessage); + + foreach(object item in mapItems) + { + count++; + } + + return count; + } + } + + public ICollection Keys + { + get + { + ArrayList keys = new ArrayList(); + MapEnumerable mapItems = new MapEnumerable(this.tibcoMapMessage); + + foreach(string itemName in mapItems) + { + keys.Add(itemName); + } + + return keys; + } + } + + public ICollection Values + { + get + { + ArrayList keys = new ArrayList(); + MapEnumerable mapItems = new MapEnumerable(this.tibcoMapMessage); + + foreach(string itemName in mapItems) + { + keys.Add(this.tibcoMapMessage.GetObject(itemName)); + } + + return keys; + } + } + + public object this[string key] + { + get + { + return this.tibcoMapMessage.GetObject(key); + } + set + { + this.tibcoMapMessage.SetObject(key, value); + } + } + + public string GetString(string key) + { + return this.tibcoMapMessage.GetString(key); + } + + public void SetString(string key, string value) + { + this.tibcoMapMessage.SetString(key, value); + } + + public bool GetBool(string key) + { + return this.tibcoMapMessage.GetBoolean(key); + } + + public void SetBool(string key, bool value) + { + this.tibcoMapMessage.SetBoolean(key, value); + } + + public byte GetByte(string key) + { + return this.tibcoMapMessage.GetByte(key); + } + + public void SetByte(string key, byte value) + { + this.tibcoMapMessage.SetByte(key, value); + } + + public char GetChar(string key) + { + return this.tibcoMapMessage.GetChar(key); + } + + public void SetChar(string key, char value) + { + this.tibcoMapMessage.SetChar(key, value); + } + + public short GetShort(string key) + { + return this.tibcoMapMessage.GetShort(key); + } + + public void SetShort(string key, short value) + { + this.tibcoMapMessage.SetShort(key, value); + } + + public int GetInt(string key) + { + return this.tibcoMapMessage.GetInt(key); + } + + public void SetInt(string key, int value) + { + this.tibcoMapMessage.SetInt(key, value); + } + + public long GetLong(string key) + { + return this.tibcoMapMessage.GetLong(key); + } + + public void SetLong(string key, long value) + { + this.tibcoMapMessage.SetLong(key, value); + } + + public float GetFloat(string key) + { + return this.tibcoMapMessage.GetFloat(key); + } + + public void SetFloat(string key, float value) + { + this.tibcoMapMessage.SetFloat(key, value); + } + + public double GetDouble(string key) + { + return this.tibcoMapMessage.GetDouble(key); + } + + public void SetDouble(string key, double value) + { + this.tibcoMapMessage.SetDouble(key, value); + } + + public IList GetList(string key) + { + return (IList) this.tibcoMapMessage.GetObject(key); + } + + public void SetList(string key, IList list) + { + this.tibcoMapMessage.SetObject(key, list); + } + + public IDictionary GetDictionary(string key) + { + return (IDictionary) this.tibcoMapMessage.GetObject(key); + } + + public void SetDictionary(string key, IDictionary dictionary) + { + this.tibcoMapMessage.SetObject(key, dictionary); + } + + #endregion + } +} Added: activemq/activemq-dotnet/trunk/src/main/csharp/TIBCO/Message.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/TIBCO/Message.cs?rev=589629&view=auto ============================================================================== --- activemq/activemq-dotnet/trunk/src/main/csharp/TIBCO/Message.cs (added) +++ activemq/activemq-dotnet/trunk/src/main/csharp/TIBCO/Message.cs Mon Oct 29 06:55:09 2007 @@ -0,0 +1,163 @@ +/* + * 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.TibcoEMS +{ + class Message : Apache.NMS.IMessage + { + public TIBCO.EMS.Message tibcoMessage; + + public Message(TIBCO.EMS.Message message) + { + this.tibcoMessage = message; + } + +#region IMessage Members + + /// + /// If using client acknowledgement mode on the session then this method will acknowledge that the + /// message has been processed correctly. + /// + public void Acknowledge() + { + this.tibcoMessage.Acknowledge(); + } + + /// + /// Provides access to the message properties (headers) + /// + public Apache.NMS.IPrimitiveMap Properties + { + get { return TibcoUtil.ToMessageProperties(this.tibcoMessage); } + } + + /// + /// The correlation ID used to correlate messages from conversations or long running business processes + /// + public string NMSCorrelationID + { + get { return this.tibcoMessage.CorrelationID; } + set { this.tibcoMessage.CorrelationID = value; } + } + + /// + /// The destination of the message + /// + public Apache.NMS.IDestination NMSDestination + { + get { return TibcoUtil.ToNMSDestination(this.tibcoMessage.Destination); } + } + + protected TimeSpan timeToLive; + + /// + /// The amount of time that this message is valid for. null If this + /// message does not expire. + /// + public TimeSpan NMSTimeToLive + { + get { return this.timeToLive; } + set { this.timeToLive = value; } + } +#if false + { + get + { + if(this.tibcoMessage.Expiration > 0) + { + return Apache.ActiveMQ.Util.DateUtils.ToDateTime(this.tibcoMessage.Expiration) + - DateTime.Now; + } + else + { + return new TimeSpan(); + } + } + + set + { + this.tibcoMessage.Expiration = + Apache.ActiveMQ.Util.DateUtils.ToJavaTime(DateTime.Now + value); + } + } +#endif + + /// + /// The message ID which is set by the provider + /// + public string NMSMessageId + { + get { return this.tibcoMessage.MessageID; } + } + + /// + /// Whether or not this message is persistent + /// + public bool NMSPersistent + { + get { return TibcoUtil.ToPersistent(this.tibcoMessage.MsgDeliveryMode); } + set { this.tibcoMessage.MsgDeliveryMode = TibcoUtil.ToMessageDeliveryMode(value); } + } + + /// + /// The Priority on this message + /// + public byte NMSPriority + { + get { return (byte) this.tibcoMessage.Priority; } + set { this.tibcoMessage.Priority = value; } + } + + /// + /// Returns true if this message has been redelivered to this or another consumer before being acknowledged successfully. + /// + public bool NMSRedelivered + { + get { return this.tibcoMessage.Redelivered; } + } + + /// + /// The destination that the consumer of this message should send replies to + /// + public Apache.NMS.IDestination NMSReplyTo + { + get { return TibcoUtil.ToNMSDestination(this.tibcoMessage.ReplyTo); } + set { this.tibcoMessage.ReplyTo = ((Apache.TibcoEMS.Destination) value).tibcoDestination; } + } + + /// + /// The timestamp of when the message was pubished in UTC time. If the publisher disables setting + /// the timestamp on the message, the time will be set to the start of the UNIX epoch (1970-01-01 00:00:00). + /// + public DateTime NMSTimestamp + { + get { return TibcoUtil.ToDateTime(this.tibcoMessage.Timestamp); } + } + + /// + /// The type name of this message + /// + public string NMSType + { + get { return this.tibcoMessage.MsgType; } + set { this.tibcoMessage.MsgType = value; } + } + + #endregion + } +} Added: activemq/activemq-dotnet/trunk/src/main/csharp/TIBCO/MessageConsumer-v1.0.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/TIBCO/MessageConsumer-v1.0.cs?rev=589629&view=auto ============================================================================== --- activemq/activemq-dotnet/trunk/src/main/csharp/TIBCO/MessageConsumer-v1.0.cs (added) +++ activemq/activemq-dotnet/trunk/src/main/csharp/TIBCO/MessageConsumer-v1.0.cs Mon Oct 29 06:55:09 2007 @@ -0,0 +1,131 @@ +/* + * 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.TibcoEMS +{ + class MessageConsumer : Apache.NMS.IMessageConsumer, TIBCO.EMS.IMessageListener + { + public TIBCO.EMS.MessageConsumer tibcoMessageConsumer; + + public MessageConsumer(TIBCO.EMS.MessageConsumer consumer) + { + this.tibcoMessageConsumer = consumer; + } + + #region IMessageConsumer Members + + /// + /// Waits until a message is available and returns it + /// + public Apache.NMS.IMessage Receive() + { + return TibcoUtil.ToNMSMessage(this.tibcoMessageConsumer.Receive()); + } + + /// + /// If a message is available within the timeout duration it is returned otherwise this method returns null + /// + public Apache.NMS.IMessage Receive(TimeSpan timeout) + { + return TibcoUtil.ToNMSMessage(this.tibcoMessageConsumer.Receive((long) timeout.TotalMilliseconds)); + } + + /// + /// If a message is available immediately it is returned otherwise this method returns null + /// + public Apache.NMS.IMessage ReceiveNoWait() + { + return TibcoUtil.ToNMSMessage(this.tibcoMessageConsumer.ReceiveNoWait()); + } + + /// + /// An asynchronous listener which can be used to consume messages asynchronously + /// + private event Apache.NMS.MessageListener listener; + public event Apache.NMS.MessageListener Listener + { + add + { + listener += value; + this.tibcoMessageConsumer.MessageListener = this; + } + + remove + { + listener -= value; + if(null == listener) + { + this.tibcoMessageConsumer.MessageListener = null; + } + } + } + + /// + /// Closes the message consumer. + /// + /// + /// Clients should close message consumers them when they are not needed. + /// This call blocks until a receive or message listener in progress has completed. + /// A blocked message consumer receive call returns null when this message consumer is closed. + /// + public void Close() + { + this.tibcoMessageConsumer.Close(); + } + + #endregion + + #region IDisposable Members + + /// + /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. + /// + ///2 + public void Dispose() + { + Close(); + } + + #endregion + + #region IMessageListener Members + + public void OnMessage(TIBCO.EMS.Message message) + { + HandleMessage(TibcoUtil.ToNMSMessage(message)); + } + + #endregion + + public void HandleMessage(Apache.NMS.IMessage message) + { + if(null != message) + { + if(listener != null) + { + listener(message); + } + else + { + Apache.ActiveMQ.Tracer.Info("Unhandled message"); + } + } + } + } +} Added: activemq/activemq-dotnet/trunk/src/main/csharp/TIBCO/MessageConsumer.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/TIBCO/MessageConsumer.cs?rev=589629&view=auto ============================================================================== --- activemq/activemq-dotnet/trunk/src/main/csharp/TIBCO/MessageConsumer.cs (added) +++ activemq/activemq-dotnet/trunk/src/main/csharp/TIBCO/MessageConsumer.cs Mon Oct 29 06:55:09 2007 @@ -0,0 +1,170 @@ +/* + * 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.TibcoEMS +{ + class MessageConsumer : Apache.NMS.IMessageConsumer + { + private readonly Apache.TibcoEMS.Dispatcher dispatcher = new Apache.TibcoEMS.Dispatcher(); + protected readonly Apache.TibcoEMS.Session nmsSession; + public TIBCO.EMS.MessageConsumer tibcoMessageConsumer; + private bool closed = false; + private bool disposed = false; + + public MessageConsumer(Apache.TibcoEMS.Session session, TIBCO.EMS.MessageConsumer consumer) + { + this.nmsSession = session; + this.tibcoMessageConsumer = consumer; + this.tibcoMessageConsumer.MessageHandler += this.HandleTibcoMsg; + } + + ~MessageConsumer() + { + Dispose(false); + } + + #region IMessageConsumer Members + + /// + /// Waits until a message is available and returns it + /// + public Apache.NMS.IMessage Receive() + { + return this.dispatcher.Dequeue(); + } + + /// + /// If a message is available within the timeout duration it is returned otherwise this method returns null + /// + public Apache.NMS.IMessage Receive(TimeSpan timeout) + { + return this.dispatcher.Dequeue(timeout); + } + + /// + /// If a message is available immediately it is returned otherwise this method returns null + /// + public Apache.NMS.IMessage ReceiveNoWait() + { + return this.dispatcher.DequeueNoWait(); + } + + /// + /// An asynchronous listener which can be used to consume messages asynchronously + /// + public event Apache.NMS.MessageListener Listener; + + /// + /// Closes the message consumer. + /// + /// + /// Clients should close message consumers them when they are not needed. + /// This call blocks until a receive or message listener in progress has completed. + /// A blocked message consumer receive call returns null when this message consumer is closed. + /// + public void Close() + { + lock(this) + { + if(closed) + { + return; + } + } + + // wake up any pending dequeue() call on the dispatcher + this.dispatcher.Close(); + + lock(this) + { + if(!this.nmsSession.tibcoSession.IsClosed) + { + this.tibcoMessageConsumer.MessageHandler -= this.HandleTibcoMsg; + this.tibcoMessageConsumer.Close(); + } + + closed = true; + } + } + + #endregion + + #region IDisposable Members + + /// + /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. + /// + ///2 + 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 + + private void HandleTibcoMsg(object sender, TIBCO.EMS.EMSMessageEventArgs arg) + { + Apache.NMS.IMessage message = TibcoUtil.ToNMSMessage(arg.Message); + + if(null != message) + { + if(Listener != null) + { + try + { + Listener(message); + } + catch(Exception ex) + { + Apache.NMS.Tracer.Debug("Error handling message: " + ex.Message); + } + } + else + { + this.dispatcher.Enqueue(message); + } + } + } + } +} Added: activemq/activemq-dotnet/trunk/src/main/csharp/TIBCO/MessageProducer.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/TIBCO/MessageProducer.cs?rev=589629&view=auto ============================================================================== --- activemq/activemq-dotnet/trunk/src/main/csharp/TIBCO/MessageProducer.cs (added) +++ activemq/activemq-dotnet/trunk/src/main/csharp/TIBCO/MessageProducer.cs Mon Oct 29 06:55:09 2007 @@ -0,0 +1,258 @@ +/* + * 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.TibcoEMS +{ + class MessageProducer : Apache.NMS.IMessageProducer + { + protected readonly Apache.TibcoEMS.Session nmsSession; + public TIBCO.EMS.MessageProducer tibcoMessageProducer; + private bool closed = false; + private bool disposed = false; + + public MessageProducer(Apache.TibcoEMS.Session session, TIBCO.EMS.MessageProducer producer) + { + this.nmsSession = session; + this.tibcoMessageProducer = producer; + } + + ~MessageProducer() + { + Dispose(false); + } + + #region IMessageProducer Members + + /// + /// Sends the message to the default destination for this producer + /// + public void Send(Apache.NMS.IMessage message) + { + Apache.TibcoEMS.Message msg = (Apache.TibcoEMS.Message) message; + long timeToLive = (long) message.NMSTimeToLive.TotalMilliseconds; + + if(0 == timeToLive) + { + timeToLive = this.tibcoMessageProducer.TimeToLive; + } + + this.tibcoMessageProducer.Send( + msg.tibcoMessage, + this.tibcoMessageProducer.MsgDeliveryMode, + this.tibcoMessageProducer.Priority, + timeToLive); + } + + /// + /// Sends the message to the default destination with the explicit QoS configuration + /// + public void Send(Apache.NMS.IMessage message, bool persistent, byte priority, TimeSpan timeToLive) + { + Apache.TibcoEMS.Message msg = (Apache.TibcoEMS.Message) message; + + this.tibcoMessageProducer.Send( + msg.tibcoMessage, + TibcoUtil.ToMessageDeliveryMode(persistent), + priority, + (long) timeToLive.TotalMilliseconds); + } + + /// + /// Sends the message to the given destination + /// + public void Send(Apache.NMS.IDestination destination, Apache.NMS.IMessage message) + { + Apache.TibcoEMS.Destination dest = (Apache.TibcoEMS.Destination) destination; + Apache.TibcoEMS.Message msg = (Apache.TibcoEMS.Message) message; + long timeToLive = (long) message.NMSTimeToLive.TotalMilliseconds; + + if(0 == timeToLive) + { + timeToLive = this.tibcoMessageProducer.TimeToLive; + } + + this.tibcoMessageProducer.Send( + dest.tibcoDestination, + msg.tibcoMessage, + this.tibcoMessageProducer.MsgDeliveryMode, + this.tibcoMessageProducer.Priority, + timeToLive); + } + + /// + /// Sends the message to the given destination with the explicit QoS configuration + /// + public void Send(Apache.NMS.IDestination destination, Apache.NMS.IMessage message, + bool persistent, byte priority, TimeSpan timeToLive) + { + Apache.TibcoEMS.Destination dest = (Apache.TibcoEMS.Destination) destination; + Apache.TibcoEMS.Message msg = (Apache.TibcoEMS.Message) message; + + this.tibcoMessageProducer.Send( + dest.tibcoDestination, + msg.tibcoMessage, + TibcoUtil.ToMessageDeliveryMode(persistent), + priority, + (long) timeToLive.TotalMilliseconds); + } + + public bool Persistent + { + get { return TibcoUtil.ToPersistent(this.tibcoMessageProducer.MsgDeliveryMode); } + set { this.tibcoMessageProducer.MsgDeliveryMode = TibcoUtil.ToMessageDeliveryMode(value); } + } + + public TimeSpan TimeToLive + { + get { return TimeSpan.FromMilliseconds(this.tibcoMessageProducer.TimeToLive); } + set { this.tibcoMessageProducer.TimeToLive = (long) value.TotalMilliseconds; } + } + + public byte Priority + { + get { return (byte) this.tibcoMessageProducer.Priority; } + set { this.tibcoMessageProducer.Priority = value; } + } + + public bool DisableMessageID + { + get { return this.tibcoMessageProducer.DisableMessageID; } + set { this.tibcoMessageProducer.DisableMessageID = value; } + } + + public bool DisableMessageTimestamp + { + get { return this.tibcoMessageProducer.DisableMessageTimestamp; } + set { this.tibcoMessageProducer.DisableMessageTimestamp = value; } + } + + /// + /// Creates a new message with an empty body + /// + public Apache.NMS.IMessage CreateMessage() + { + return this.nmsSession.CreateMessage(); + } + + /// + /// Creates a new text message with an empty body + /// + public Apache.NMS.ITextMessage CreateTextMessage() + { + return this.nmsSession.CreateTextMessage(); + } + + /// + /// Creates a new text message with the given body + /// + public Apache.NMS.ITextMessage CreateTextMessage(string text) + { + return this.nmsSession.CreateTextMessage(text); + } + + /// + /// Creates a new Map message which contains primitive key and value pairs + /// + public Apache.NMS.IMapMessage CreateMapMessage() + { + return this.nmsSession.CreateMapMessage(); + } + + /// + /// Creates a new Object message containing the given .NET object as the body + /// + public Apache.NMS.IObjectMessage CreateObjectMessage(object body) + { + return this.nmsSession.CreateObjectMessage(body); + } + + /// + /// Creates a new binary message + /// + public Apache.NMS.IBytesMessage CreateBytesMessage() + { + return this.nmsSession.CreateBytesMessage(); + } + + /// + /// Creates a new binary message with the given body + /// + public Apache.NMS.IBytesMessage CreateBytesMessage(byte[] body) + { + return this.nmsSession.CreateBytesMessage(body); + } + + #endregion + + #region IDisposable Members + + public void Close() + { + lock(this) + { + if(closed) + { + return; + } + + if(!this.nmsSession.tibcoSession.IsClosed) + { + this.tibcoMessageProducer.Close(); + } + + closed = true; + } + } + /// + ///Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. + /// + ///2 + 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 + } +}