Author: jgomes
Date: Fri Aug 8 11:49:28 2008
New Revision: 684050
URL: http://svn.apache.org/viewvc?rev=684050&view=rev
Log:
Refactoring unit tests and the build process. Removed support for obsolete
platforms MONO 1.0, .NET 1.0, and .NET Compact Framework 1.0.
Upgraded NUnit version to 2.4.7 and included the assembly in the main
repository so that it can be easily upgraded in future.
Fixes [AMQNET-71]. (See https://issues.apache.org/activemq/browse/AMQNET-71)
Modified:
activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/nant-common.xml
activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/nant.build
activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/MessageProducer.cs
activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/Session.cs
activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/test/csharp/InheritedTests.cs
Modified: activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/nant-common.xml
URL:
http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/nant-common.xml?rev=684050&r1=684049&r2=684050&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/nant-common.xml (original)
+++ activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/nant-common.xml Fri Aug 8
11:49:28 2008
@@ -198,18 +198,6 @@
<property name="csc.optimize" value="true" />
</target>
- <target name="set-net-1.0-framework-configuration">
- <property name="current.build.framework" value="net-1.0" />
- <property name="current.build.framework.name" value=".NET 1.0"/>
- <property name="current.build.defines" value="${build.defines}NET,NET_1_0"
dynamic="true" />
- <property name="current.build.framework.sign" value="true" />
- <property name="link.sdkdoc.version" value="SDK_v1_0" />
- <property name="link.sdkdoc.web" value="true" />
- <if test="${framework::exists(current.build.framework)}">
- <property name="nant.settings.currentframework"
value="${current.build.framework}" />
- </if>
- </target>
-
<target name="set-net-1.1-framework-configuration">
<property name="current.build.framework" value="net-1.1" />
<property name="current.build.framework.name" value=".NET 1.1"/>
@@ -246,18 +234,6 @@
</if>
</target>
- <target name="set-netcf-1.0-framework-configuration">
- <property name="current.build.framework" value="netcf-1.0" />
- <property name="current.build.framework.name" value=".NET Compact
Framework 1.0"/>
- <property name="current.build.defines"
value="${build.defines}PocketPC,NETCF,NETCF_1_0" dynamic="true" />
- <property name="current.build.framework.sign" value="false" />
- <property name="link.sdkdoc.version" value="SDK_v1_1" />
- <property name="link.sdkdoc.web" value="true" />
- <if test="${framework::exists(current.build.framework)}">
- <property name="nant.settings.currentframework"
value="${current.build.framework}" />
- </if>
- </target>
-
<target name="set-netcf-2.0-framework-configuration">
<property name="current.build.framework" value="netcf-2.0" />
<property name="current.build.framework.name" value=".NET Compact
Framework 2.0"/>
@@ -270,18 +246,6 @@
</if>
</target>
- <target name="set-mono-1.0-framework-configuration">
- <property name="current.build.framework" value="mono-1.0" />
- <property name="current.build.framework.name" value="Mono 1.0"/>
- <property name="current.build.defines"
value="${build.defines}MONO,MONO_1_0" dynamic="true" />
- <property name="current.build.framework.sign" value="true" />
- <property name="link.sdkdoc.version" value="SDK_v1_1" />
- <property name="link.sdkdoc.web" value="true" />
- <if test="${framework::exists(current.build.framework)}">
- <property name="nant.settings.currentframework"
value="${current.build.framework}" />
- </if>
- </target>
-
<target name="set-mono-2.0-framework-configuration">
<property name="current.build.framework" value="mono-2.0" />
<property name="current.build.framework.name" value="Mono 2.0"/>
@@ -300,25 +264,19 @@
<target name="compile-all" depends="release-init" description="Compile all
build configurations for all runtime configurations">
<echo message="Compiling all build configurations for all runtime
configurations." />
<call target="set-debug-configuration" />
- <call target="set-net-1.0-framework-configuration" /><call
target="conditional-compile" />
<call target="set-net-1.1-framework-configuration" /><call
target="conditional-compile" />
<call target="set-net-2.0-framework-configuration" /><call
target="conditional-compile" />
<call target="set-net-3.5-framework-configuration" /><call
target="conditional-compile" />
- <call target="set-mono-1.0-framework-configuration" /><call
target="conditional-compile" />
<call target="set-mono-2.0-framework-configuration" /><call
target="conditional-compile" />
- <call target="set-netcf-1.0-framework-configuration"/><call
target="conditional-compile" />
<call target="set-netcf-2.0-framework-configuration"/><call
target="conditional-compile" />
<!-- we can only do a release skip if the Key file is available -->
<if test="${not build.skip.release}">
<call target="set-release-configuration" />
- <call target="set-net-1.0-framework-configuration" /><call
target="conditional-compile" />
<call target="set-net-1.1-framework-configuration" /><call
target="conditional-compile" />
<call target="set-net-2.0-framework-configuration" /><call
target="conditional-compile" />
<call target="set-net-3.5-framework-configuration" /><call
target="conditional-compile" />
- <call target="set-mono-1.0-framework-configuration" /><call
target="conditional-compile" />
<call target="set-mono-2.0-framework-configuration" /><call
target="conditional-compile" />
- <call target="set-netcf-1.0-framework-configuration"/><call
target="conditional-compile" />
<call target="set-netcf-2.0-framework-configuration"/><call
target="conditional-compile" />
</if>
</target>
@@ -453,25 +411,19 @@
<target name="install-all" depends="release-init" description="Install all
build configurations for all runtime configurations">
<echo message="Installing all build configurations for all runtime
configurations." />
<call target="set-debug-configuration" />
- <call target="set-net-1.0-framework-configuration" /><call
target="conditional-install" />
<call target="set-net-1.1-framework-configuration" /><call
target="conditional-install" />
<call target="set-net-2.0-framework-configuration" /><call
target="conditional-install" />
<call target="set-net-3.5-framework-configuration" /><call
target="conditional-install" />
- <call target="set-mono-1.0-framework-configuration" /><call
target="conditional-install" />
<call target="set-mono-2.0-framework-configuration" /><call
target="conditional-install" />
- <call target="set-netcf-1.0-framework-configuration"/><call
target="conditional-install" />
<call target="set-netcf-2.0-framework-configuration"/><call
target="conditional-install" />
<!-- we can only do a release skip if the Key file is available -->
<if test="${not build.skip.release}">
<call target="set-release-configuration" />
- <call target="set-net-1.0-framework-configuration" /><call
target="conditional-install" />
<call target="set-net-1.1-framework-configuration" /><call
target="conditional-install" />
<call target="set-net-2.0-framework-configuration" /><call
target="conditional-install" />
<call target="set-net-3.5-framework-configuration" /><call
target="conditional-install" />
- <call target="set-mono-1.0-framework-configuration" /><call
target="conditional-install" />
<call target="set-mono-2.0-framework-configuration" /><call
target="conditional-install" />
- <call target="set-netcf-1.0-framework-configuration"/><call
target="conditional-install" />
<call target="set-netcf-2.0-framework-configuration"/><call
target="conditional-install" />
</if>
</target>
@@ -505,25 +457,19 @@
<echo message="Deploying all build configurations for all runtime
configurations." />
<call target="set-debug-configuration" />
- <call target="set-net-1.0-framework-configuration" /><call
target="conditional-deploy" />
<call target="set-net-1.1-framework-configuration" /><call
target="conditional-deploy" />
<call target="set-net-2.0-framework-configuration" /><call
target="conditional-deploy" />
<call target="set-net-3.5-framework-configuration" /><call
target="conditional-deploy" />
- <call target="set-mono-1.0-framework-configuration" /><call
target="conditional-deploy" />
<call target="set-mono-2.0-framework-configuration" /><call
target="conditional-deploy" />
- <call target="set-netcf-1.0-framework-configuration"/><call
target="conditional-deploy" />
<call target="set-netcf-2.0-framework-configuration"/><call
target="conditional-deploy" />
<!-- we can only do a release skip if the Key file is available -->
<if test="${not build.skip.release}">
<call target="set-release-configuration" />
- <call target="set-net-1.0-framework-configuration" /><call
target="conditional-deploy" />
<call target="set-net-1.1-framework-configuration" /><call
target="conditional-deploy" />
<call target="set-net-2.0-framework-configuration" /><call
target="conditional-deploy" />
<call target="set-net-3.5-framework-configuration" /><call
target="conditional-deploy" />
- <call target="set-mono-1.0-framework-configuration" /><call
target="conditional-deploy" />
<call target="set-mono-2.0-framework-configuration" /><call
target="conditional-deploy" />
- <call target="set-netcf-1.0-framework-configuration"/><call
target="conditional-deploy" />
<call target="set-netcf-2.0-framework-configuration"/><call
target="conditional-deploy" />
</if>
</target>
Modified: activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/nant.build
URL:
http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/nant.build?rev=684050&r1=684049&r2=684050&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/nant.build (original)
+++ activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/nant.build Fri Aug 8
11:49:28 2008
@@ -34,7 +34,7 @@
value="Apache NMS for MSMQ Class Library (.Net Messaging Library
Implementation): An implementation of the NMS API for MSMQ"/>
<!-- Repository organized as: organization/module/version/plaform/artifact,
platform might be something like 'all' or 'net-2.0/release' -->
- <property name="nunit.dll"
value="org.nunit/nunit/2.2.8/all/nunit.framework.dll"/>
+ <property name="nunit.dll"
value="${basedir}/vendor/Apache.NMS/lib/nunit.framework.dll"/>
<property name="Apache.NMS.dll"
value="${basedir}/vendor/Apache.NMS/build/${current.build.framework}/${current.build.config}/Apache.NMS.dll"
dynamic="true"/>
<property name="Apache.NMS.pdb"
value="${basedir}/vendor/Apache.NMS/build/${current.build.framework}/${current.build.config}/Apache.NMS.pdb"
dynamic="true"/>
<property name="Apache.NMS.xml"
value="${basedir}/vendor/Apache.NMS/build/${current.build.framework}/${current.build.config}/Apache.NMS.xml"
dynamic="true"/>
@@ -43,16 +43,10 @@
<property name="Apache.NMS.Test.xml"
value="${basedir}/vendor/Apache.NMS/build/${current.build.framework}/${current.build.config}/Apache.NMS.Test.xml"
dynamic="true"/>
<!-- Skip certain frameworks, since MSMQ is not supported on those
platforms. -->
- <property name="build.netcf-1.0.skip" value="true"/>
<property name="build.netcf-2.0.skip" value="true"/>
- <property name="build.mono-1.0.skip" value="true"/>
<property name="build.mono-2.0.skip" value="true"/>
<target name="vendor-init" description="Initializes the vendor libraries.">
- <!-- The following does a poor man's maven style dependency install to the
local repo -->
- <property name="repo.task.artifact" value="${nunit.dll}"/>
- <call target="repo-download"/>
-
<nant buildfile="${basedir}/vendor/Apache.NMS/nant.build"/>
</target>
@@ -73,6 +67,7 @@
<assemblyfileset failonempty="true" id="dependencies">
<include name="mscorlib.dll" asis="true"/>
<include name="System.dll" asis="true"/>
+ <include name="System.Xml.dll" asis="true"/>
<include name="${lib.framework.dir}/System.Messaging.dll" />
<include name="${Apache.NMS.dll}"/>
</assemblyfileset>
@@ -80,11 +75,12 @@
<assemblyfileset failonempty="true" id="test.dependencies">
<include name="mscorlib.dll" asis="true"/>
<include name="System.dll" asis="true"/>
+ <include name="System.Xml.dll" asis="true"/>
<include name="${lib.framework.dir}/System.Messaging.dll" />
<include name="${Apache.NMS.dll}"/>
<include name="${Apache.NMS.Test.dll}"/>
<include name="${build.bin.dir}/${project.name}.dll"/>
- <include name="${nant.local.repo}/${nunit.dll}"/>
+ <include name="${nunit.dll}"/>
</assemblyfileset>
<fileset id="content.filenames">
Modified:
activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/MessageProducer.cs
URL:
http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/MessageProducer.cs?rev=684050&r1=684049&r2=684050&view=diff
==============================================================================
---
activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/MessageProducer.cs
(original)
+++
activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/MessageProducer.cs
Fri Aug 8 11:49:28 2008
@@ -16,174 +16,174 @@
*/
using System;
using System.Messaging;
+using System.Threading;
using Apache.NMS;
namespace Apache.NMS.MSMQ
{
- /// <summary>
- /// An object capable of sending messages to some destination
- /// </summary>
- public class MessageProducer : IMessageProducer
- {
-
- private readonly Session session;
- private Destination destination;
-
- //private long messageCounter;
- private bool persistent;
- private TimeSpan timeToLive;
- private byte priority;
- private bool disableMessageID;
- private bool disableMessageTimestamp;
-
- private MessageQueue messageQueue;
- private IMessageConverter messageConverter;
-
- public MessageProducer(Session session, Destination destination)
- {
- this.session = session;
- this.destination = destination;
- MessageConverter = session.MessageConverter;
- if (destination != null)
- {
- messageQueue = openMessageQueue(destination);
- }
- }
-
- private MessageQueue openMessageQueue(Destination dest)
- {
- MessageQueue rc=null;
- try
- {
- if (!MessageQueue.Exists(dest.Path))
- {
- // create the new message queue and make it transactional
- rc = MessageQueue.Create(dest.Path, session.Transacted);
- this.destination.Path = rc.Path;
- } else
- {
- rc = new MessageQueue(dest.Path);
- this.destination.Path = rc.Path;
- if( !rc.CanWrite )
- {
- throw new NMSSecurityException("Do not have write
access to: " + dest);
- }
- }
- }
- catch( Exception e )
- {
- if( rc!=null )
- {
- rc.Dispose();
- }
- throw new NMSException(e.Message+": "+dest, e);
- }
- return rc;
- }
-
- public void Send(IMessage message)
- {
- Send(Destination, message);
- }
+ /// <summary>
+ /// An object capable of sending messages to some destination
+ /// </summary>
+ public class MessageProducer : IMessageProducer
+ {
+
+ private readonly Session session;
+ private Destination destination;
+
+ //private long messageCounter;
+ private bool persistent;
+ private TimeSpan timeToLive;
+ private byte priority;
+ private bool disableMessageID;
+ private bool disableMessageTimestamp;
+
+ private MessageQueue messageQueue;
+ private IMessageConverter messageConverter;
+
+ public MessageProducer(Session session, Destination destination)
+ {
+ this.session = session;
+ this.destination = destination;
+ MessageConverter = session.MessageConverter;
+ if (destination != null)
+ {
+ messageQueue = openMessageQueue(destination);
+ }
+ }
+
+ private MessageQueue openMessageQueue(Destination dest)
+ {
+ MessageQueue rc=null;
+ try
+ {
+ if (!MessageQueue.Exists(dest.Path))
+ {
+ // create the new message queue and
make it transactional
+ rc = MessageQueue.Create(dest.Path,
session.Transacted);
+ this.destination.Path = rc.Path;
+ } else
+ {
+ rc = new MessageQueue(dest.Path);
+ this.destination.Path = rc.Path;
+ if( !rc.CanWrite )
+ {
+ throw new
NMSSecurityException("Do not have write access to: " + dest);
+ }
+ }
+ }
+ catch( Exception e )
+ {
+ if( rc!=null )
+ {
+ rc.Dispose();
+ }
+ throw new NMSException(e.Message+": "+dest, e);
+ }
+ return rc;
+ }
+
+ public void Send(IMessage message)
+ {
+ Send(Destination, message);
+ }
public void Send(IMessage message, bool persistent, byte
priority, TimeSpan timeToLive)
{
Send(Destination, message, persistent, priority,
timeToLive);
}
- public void Send(IDestination destination, IMessage message)
- {
+ public void Send(IDestination destination, IMessage message)
+ {
Send(destination, message, Persistent, Priority,
TimeToLive);
- }
+ }
- public void Send(IDestination destination, IMessage imessage, bool
persistent, byte priority, TimeSpan timeToLive)
- {
- BaseMessage message = (BaseMessage) imessage;
- MessageQueue mq=null;
- MessageQueue responseQueue = null;
- MessageQueueTransaction transaction = null;
- try
- {
- // Locate the MSMQ Queue we will be sending to
- if (messageQueue != null)
- {
- if( destination.Equals(this.destination) )
- {
- mq = messageQueue;
- }
- else
- {
- throw new NMSException("This producer can only be used
to send to: " + destination);
- }
- }
- else
- {
- mq = openMessageQueue((Destination) destination);
- }
+ public void Send(IDestination destination, IMessage imessage,
bool persistent, byte priority, TimeSpan timeToLive)
+ {
+ BaseMessage message = (BaseMessage) imessage;
+ MessageQueue mq=null;
+ MessageQueue responseQueue = null;
+ MessageQueueTransaction transaction = null;
+ try
+ {
+ // Locate the MSMQ Queue we will be sending to
+ if (messageQueue != null)
+ {
+ if(
destination.Equals(this.destination) )
+ {
+ mq = messageQueue;
+ }
+ else
+ {
+ throw new NMSException("This
producer can only be used to send to: " + destination);
+ }
+ }
+ else
+ {
+ mq = openMessageQueue((Destination)
destination);
+ }
- // Convert the Mesasge into a MSMQ message
- message.NMSPersistent = persistent;
- message.NMSTimeToLive = timeToLive;
- message.NMSPriority = priority;
-
- // message.NMSTimestamp = new DateTime().Date.;
- Message msg = messageConverter.ToMsmqMessage(message);
- // TODO: message.NMSMessageId =
- // Now Send the message
- if( mq.Transactional )
- {
- if (session.Transacted)
- {
- mq.Send(msg, session.MessageQueueTransaction);
-
- } else
- {
- // Start our own mini transaction here to send the
message.
- transaction = new MessageQueueTransaction();
- transaction.Begin();
- mq.Send(msg, transaction);
- transaction.Commit();
- }
- } else
- {
- if( session.Transacted )
- {
- // We may want to raise an exception here since app
requested
- // a transeced NMS session, but is using a non
transacted message queue
- // For now silently ignore it.
- }
- mq.Send(msg);
- }
-
- } finally
- {
- // Cleanup
- if(transaction!=null)
- {
- transaction.Dispose();
- }
- if (responseQueue != null)
- {
- responseQueue.Dispose();
- }
- if( mq!=null && mq!=messageQueue )
- {
- mq.Dispose();
- }
- }
- }
-
+ // Convert the Mesasge into a MSMQ message
+ message.NMSPersistent = persistent;
+ message.NMSTimeToLive = timeToLive;
+ message.NMSPriority = priority;
+
+ // message.NMSTimestamp = new DateTime().Date.;
+ Message msg =
messageConverter.ToMsmqMessage(message);
+ // TODO: message.NMSMessageId =
+ // Now Send the message
+ if( mq.Transactional )
+ {
+ if (session.Transacted)
+ {
+ mq.Send(msg,
session.MessageQueueTransaction);
+
+ } else
+ {
+ // Start our own mini
transaction here to send the message.
+ transaction = new
MessageQueueTransaction();
+ transaction.Begin();
+ mq.Send(msg, transaction);
+ transaction.Commit();
+ }
+ } else
+ {
+ if( session.Transacted )
+ {
+ // We may want to raise an
exception here since app requested
+ // a transeced NMS session, but
is using a non transacted message queue
+ // For now silently ignore it.
+ }
+ mq.Send(msg);
+ }
+
+ } finally
+ {
+ // Cleanup
+ if(transaction!=null)
+ {
+ transaction.Dispose();
+ }
+ if (responseQueue != null)
+ {
+ responseQueue.Dispose();
+ }
+ if( mq!=null && mq!=messageQueue )
+ {
+ mq.Dispose();
+ }
+ }
+ }
- public void Dispose()
- {
- if( messageQueue!=null )
- {
- messageQueue.Dispose();
- messageQueue = null;
- }
- }
+ public void Dispose()
+ {
+ if( messageQueue!=null )
+ {
+ messageQueue.Dispose();
+ messageQueue = null;
+ }
+ }
public IMessage CreateMessage()
{
@@ -220,53 +220,59 @@
return session.CreateBytesMessage(body);
}
- public bool Persistent
- {
- get { return persistent; }
- set { persistent = value; }
- }
-
- public TimeSpan TimeToLive
- {
- get { return timeToLive; }
- set { timeToLive = value; }
- }
-
- byte IMessageProducer.Priority
- {
- get { throw new NotImplementedException(); }
- set { throw new NotImplementedException(); }
- }
+ public bool Persistent
+ {
+ get { return persistent; }
+ set { persistent = value; }
+ }
+
+ public TimeSpan TimeToLive
+ {
+ get { return timeToLive; }
+ set { timeToLive = value; }
+ }
+
+ public TimeSpan RequestTimeout
+ {
+ get { return
TimeSpan.FromMilliseconds(Timeout.Infinite); }
+ set { }
+ }
+
+ byte IMessageProducer.Priority
+ {
+ get { return 5; }
+ set { }
+ }
public IDestination Destination
{
- get { return destination; }
- set { destination = (Destination) value; }
+ get { return destination; }
+ set { destination = (Destination) value; }
}
- public byte Priority
- {
- get { return priority; }
- set { priority = value; }
- }
-
- public bool DisableMessageID
- {
- get { return disableMessageID; }
- set { disableMessageID = value; }
- }
-
- public bool DisableMessageTimestamp
- {
- get { return disableMessageTimestamp; }
- set { disableMessageTimestamp = value; }
- }
-
- public IMessageConverter MessageConverter
- {
- get { return messageConverter; }
- set { messageConverter = value; }
- }
+ public byte Priority
+ {
+ get { return priority; }
+ set { priority = value; }
+ }
+
+ public bool DisableMessageID
+ {
+ get { return disableMessageID; }
+ set { disableMessageID = value; }
+ }
+
+ public bool DisableMessageTimestamp
+ {
+ get { return disableMessageTimestamp; }
+ set { disableMessageTimestamp = value; }
+ }
+
+ public IMessageConverter MessageConverter
+ {
+ get { return messageConverter; }
+ set { messageConverter = value; }
+ }
- }
+ }
}
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=684050&r1=684049&r2=684050&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
Fri Aug 8 11:49:28 2008
@@ -20,66 +20,66 @@
namespace Apache.NMS.MSMQ
{
- /// <summary>
- /// MSQM provider of ISession
- /// </summary>
- public class Session : ISession
- {
- private Connection connection;
- private AcknowledgementMode acknowledgementMode;
- private MessageQueueTransaction messageQueueTransaction;
- private IMessageConverter messageConverter;
-
- public Session(Connection connection, AcknowledgementMode
acknowledgementMode)
- {
- this.connection = connection;
- this.acknowledgementMode = acknowledgementMode;
- MessageConverter = connection.MessageConverter;
- if (this.acknowledgementMode == AcknowledgementMode.Transactional)
- {
- MessageQueueTransaction = new MessageQueueTransaction();
- }
- }
-
- public void Dispose()
- {
- if(MessageQueueTransaction!=null)
- {
- MessageQueueTransaction.Dispose();
- }
- }
-
- public IMessageProducer CreateProducer()
- {
- return CreateProducer(null);
- }
+ /// <summary>
+ /// MSQM provider of ISession
+ /// </summary>
+ public class Session : ISession
+ {
+ private Connection connection;
+ private AcknowledgementMode acknowledgementMode;
+ private MessageQueueTransaction messageQueueTransaction;
+ private IMessageConverter messageConverter;
+
+ public Session(Connection connection, AcknowledgementMode
acknowledgementMode)
+ {
+ this.connection = connection;
+ this.acknowledgementMode = acknowledgementMode;
+ MessageConverter = connection.MessageConverter;
+ if (this.acknowledgementMode ==
AcknowledgementMode.Transactional)
+ {
+ MessageQueueTransaction = new
MessageQueueTransaction();
+ }
+ }
+
+ public void Dispose()
+ {
+ if(MessageQueueTransaction!=null)
+ {
+ MessageQueueTransaction.Dispose();
+ }
+ }
+
+ public IMessageProducer CreateProducer()
+ {
+ return CreateProducer(null);
+ }
public IMessageProducer CreateProducer(IDestination destination)
{
return new MessageProducer(this, (Destination)
destination);
}
- public IMessageProducer CreateProducer(IDestination destination,
TimeSpan responseTimeout)
- {
+ public IMessageProducer CreateProducer(IDestination
destination, TimeSpan responseTimeout)
+ {
// Ignore: responseTimeout
return CreateProducer(destination);
- }
-
- public IMessageConsumer CreateConsumer(IDestination destination)
- {
- return CreateConsumer(destination, null);
- }
+ }
+
+ public IMessageConsumer CreateConsumer(IDestination destination)
+ {
+ return CreateConsumer(destination, null);
+ }
public IMessageConsumer CreateConsumer(IDestination
destination, TimeSpan responseTimeout)
{
// Ignore: responseTimeout
return CreateConsumer(destination);
}
-
- public IMessageConsumer CreateConsumer(IDestination destination,
string selector)
- {
- return CreateConsumer(destination, selector, false);
- }
+
+ public IMessageConsumer CreateConsumer(IDestination
destination, string selector)
+ {
+ return CreateConsumer(destination, selector, false);
+ }
public IMessageConsumer CreateConsumer(IDestination
destination, string selector, TimeSpan responseTimeout)
{
@@ -94,8 +94,8 @@
throw new NotImplementedException("Selectors
are not supported by MSMQ");
}
MessageQueue queue =
MessageConverter.ToMsmqDestination(destination);
- return new MessageConsumer(this, acknowledgementMode, queue);
- }
+ return new MessageConsumer(this, acknowledgementMode,
queue);
+ }
public IMessageConsumer CreateConsumer(IDestination
destination, string selector, bool noLocal, TimeSpan responseTimeout)
{
@@ -103,10 +103,10 @@
return CreateConsumer(destination, selector, noLocal);
}
- public IMessageConsumer CreateDurableConsumer(ITopic destination,
string name, string selector, bool noLocal)
- {
- throw new NotImplementedException("Durable Topic subscribers are
not supported by MSMQ");
- }
+ public IMessageConsumer CreateDurableConsumer(ITopic
destination, string name, string selector, bool noLocal)
+ {
+ throw new NotImplementedException("Durable Topic
subscribers are not supported by MSMQ");
+ }
public IMessageConsumer CreateDurableConsumer(ITopic
destination, string name, string selector, bool noLocal, TimeSpan
responseTimeout)
{
@@ -115,63 +115,70 @@
public void DeleteDurableConsumer(string name)
{
+ throw new NotImplementedException("Durable Topic
subscribers are not supported by MSMQ");
+ }
+
+ public void DeleteDurableConsumer(string name, TimeSpan
requestTimeout)
+ {
+ // Ignore: requestTimeout
+ DeleteDurableConsumer(name);
}
public IQueue GetQueue(string name)
- {
- return new Queue(name);
- }
-
- public ITopic GetTopic(string name)
- {
- throw new NotImplementedException("Topics are not supported by
MSMQ");
- }
-
- public ITemporaryQueue CreateTemporaryQueue()
- {
- throw new NotImplementedException("Tempoary Queues are not
supported by MSMQ");
- }
-
- public ITemporaryTopic CreateTemporaryTopic()
- {
- throw new NotImplementedException("Tempoary Topics are not
supported by MSMQ");
- }
-
- public IMessage CreateMessage()
- {
- BaseMessage answer = new BaseMessage();
- return answer;
- }
-
-
- public ITextMessage CreateTextMessage()
- {
- TextMessage answer = new TextMessage();
- return answer;
- }
-
- public ITextMessage CreateTextMessage(string text)
- {
- TextMessage answer = new TextMessage(text);
- return answer;
- }
-
- public IMapMessage CreateMapMessage()
- {
- return new MapMessage();
- }
-
- public IBytesMessage CreateBytesMessage()
- {
- return new BytesMessage();
- }
-
- public IBytesMessage CreateBytesMessage(byte[] body)
- {
- BytesMessage answer = new BytesMessage();
- answer.Content = body;
- return answer;
- }
+ {
+ return new Queue(name);
+ }
+
+ public ITopic GetTopic(string name)
+ {
+ throw new NotImplementedException("Topics are not
supported by MSMQ");
+ }
+
+ public ITemporaryQueue CreateTemporaryQueue()
+ {
+ throw new NotImplementedException("Tempoary Queues are
not supported by MSMQ");
+ }
+
+ public ITemporaryTopic CreateTemporaryTopic()
+ {
+ throw new NotImplementedException("Tempoary Topics are
not supported by MSMQ");
+ }
+
+ public IMessage CreateMessage()
+ {
+ BaseMessage answer = new BaseMessage();
+ return answer;
+ }
+
+
+ public ITextMessage CreateTextMessage()
+ {
+ TextMessage answer = new TextMessage();
+ return answer;
+ }
+
+ public ITextMessage CreateTextMessage(string text)
+ {
+ TextMessage answer = new TextMessage(text);
+ return answer;
+ }
+
+ public IMapMessage CreateMapMessage()
+ {
+ return new MapMessage();
+ }
+
+ public IBytesMessage CreateBytesMessage()
+ {
+ return new BytesMessage();
+ }
+
+ public IBytesMessage CreateBytesMessage(byte[] body)
+ {
+ BytesMessage answer = new BytesMessage();
+ answer.Content = body;
+ return answer;
+ }
public IObjectMessage CreateObjectMessage(Object body)
{
@@ -180,61 +187,61 @@
return answer;
}
- public void Commit()
- {
- if (! Transacted )
- {
- throw new InvalidOperationException("You cannot perform a
Commit() on a non-transacted session. Acknowlegement mode is: " +
acknowledgementMode);
- }
- messageQueueTransaction.Commit();
- }
-
- public void Rollback()
- {
- if (! Transacted)
- {
- throw new InvalidOperationException("You cannot perform a
Commit() on a non-transacted session. Acknowlegement mode is: " +
acknowledgementMode);
- }
- messageQueueTransaction.Abort();
- }
-
- // Properties
- public Connection Connection
- {
- get { return connection; }
- }
-
- public bool Transacted
- {
- get { return acknowledgementMode ==
AcknowledgementMode.Transactional; }
- }
-
- public AcknowledgementMode AcknowledgementMode
- {
- get { throw new NotImplementedException(); }
- }
-
- public MessageQueueTransaction MessageQueueTransaction
- {
- get
- {
- if( messageQueueTransaction.Status !=
MessageQueueTransactionStatus.Pending )
- messageQueueTransaction.Begin();
- return messageQueueTransaction;
- }
- set { messageQueueTransaction = value; }
- }
-
- public IMessageConverter MessageConverter
- {
- get { return messageConverter; }
- set { messageConverter = value; }
- }
-
- public void Close()
- {
- Dispose();
- }
+ public void Commit()
+ {
+ if (! Transacted )
+ {
+ throw new InvalidOperationException("You cannot
perform a Commit() on a non-transacted session. Acknowlegement mode is: " +
acknowledgementMode);
+ }
+ messageQueueTransaction.Commit();
+ }
+
+ public void Rollback()
+ {
+ if (! Transacted)
+ {
+ throw new InvalidOperationException("You cannot
perform a Commit() on a non-transacted session. Acknowlegement mode is: " +
acknowledgementMode);
+ }
+ messageQueueTransaction.Abort();
+ }
+
+ // Properties
+ public Connection Connection
+ {
+ get { return connection; }
+ }
+
+ public bool Transacted
+ {
+ get { return acknowledgementMode ==
AcknowledgementMode.Transactional; }
+ }
+
+ public AcknowledgementMode AcknowledgementMode
+ {
+ get { throw new NotImplementedException(); }
+ }
+
+ public MessageQueueTransaction MessageQueueTransaction
+ {
+ get
+ {
+ if( messageQueueTransaction.Status !=
MessageQueueTransactionStatus.Pending )
+ messageQueueTransaction.Begin();
+ return messageQueueTransaction;
+ }
+ set { messageQueueTransaction = value; }
+ }
+
+ public IMessageConverter MessageConverter
+ {
+ get { return messageConverter; }
+ set { messageConverter = value; }
+ }
+
+ public void Close()
+ {
+ Dispose();
+ }
- }
+ }
}
Modified:
activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/test/csharp/InheritedTests.cs
URL:
http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/test/csharp/InheritedTests.cs?rev=684050&r1=684049&r2=684050&view=diff
==============================================================================
---
activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/test/csharp/InheritedTests.cs
(original)
+++
activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/test/csharp/InheritedTests.cs
Fri Aug 8 11:49:28 2008
@@ -64,7 +64,7 @@
}
[TestFixture]
- public class TextMessage : Apache.NMS.Test.TextMessage
+ public class TextMessageTest : Apache.NMS.Test.TextMessageTest
{
}