Added ConnectionMetaData support to the EMS and MSMQ provider implementations.
Fixes [AMQNET-96]. (See https://issues.apache.org/activemq/browse/AMQNET-96)
diff --git a/src/main/csharp/Connection.cs b/src/main/csharp/Connection.cs
index bd1d772..9fa89be 100644
--- a/src/main/csharp/Connection.cs
+++ b/src/main/csharp/Connection.cs
@@ -29,6 +29,7 @@
private AcknowledgementMode acknowledgementMode = AcknowledgementMode.AutoAcknowledge;
private IMessageConverter messageConverter = new DefaultMessageConverter();
+ private ConnectionMetaData metaData = null;
private bool connected;
private bool closed;
private string clientId;
@@ -114,6 +115,11 @@
}
}
+ public IConnectionMetaData MetaData
+ {
+ get { return this.metaData ?? (this.metaData = new ConnectionMetaData()); }
+ }
+
public event ExceptionListener ExceptionListener;
protected void CheckConnected()
diff --git a/src/main/csharp/ConnectionMetaData.cs b/src/main/csharp/ConnectionMetaData.cs
new file mode 100644
index 0000000..5a305c0
--- /dev/null
+++ b/src/main/csharp/ConnectionMetaData.cs
@@ -0,0 +1,107 @@
+/*
+ * 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.Reflection;
+
+namespace Apache.NMS.MSMQ
+{
+ /// <summary>
+ /// Implements the Connection Meta-Data feature for Apache.NMS.MSMQ
+ /// </summary>
+ public class ConnectionMetaData : IConnectionMetaData
+ {
+ private int nmsMajorVersion;
+ private int nmsMinorVersion;
+
+ private string nmsProviderName;
+ private string nmsVersion;
+
+ private int providerMajorVersion;
+ private int providerMinorVersion;
+ private string providerVersion;
+
+ private string[] nmsxProperties;
+
+ public ConnectionMetaData()
+ {
+ Assembly self = Assembly.GetExecutingAssembly();
+ AssemblyName asmName = self.GetName();
+
+ this.nmsProviderName = asmName.Name;
+ this.providerMajorVersion = asmName.Version.Major;
+ this.providerMinorVersion = asmName.Version.Minor;
+ this.providerVersion = asmName.Version.ToString();
+
+ this.nmsxProperties = new String[] { };
+
+ foreach(AssemblyName name in self.GetReferencedAssemblies())
+ {
+ if(0 == string.Compare(name.Name, "Apache.NMS", true))
+ {
+ this.nmsMajorVersion = name.Version.Major;
+ this.nmsMinorVersion = name.Version.Minor;
+ this.nmsVersion = name.Version.ToString();
+
+ return;
+ }
+ }
+
+ throw new NMSException("Could not find a reference to the Apache.NMS Assembly.");
+ }
+
+ public int NMSMajorVersion
+ {
+ get { return this.nmsMajorVersion; }
+ }
+
+ public int NMSMinorVersion
+ {
+ get { return this.nmsMinorVersion; }
+ }
+
+ public string NMSProviderName
+ {
+ get { return this.nmsProviderName; }
+ }
+
+ public string NMSVersion
+ {
+ get { return this.nmsVersion; }
+ }
+
+ public string[] NMSXPropertyNames
+ {
+ get { return this.nmsxProperties; }
+ }
+
+ public int ProviderMajorVersion
+ {
+ get { return this.providerMajorVersion; }
+ }
+
+ public int ProviderMinorVersion
+ {
+ get { return this.providerMinorVersion; }
+ }
+
+ public string ProviderVersion
+ {
+ get { return this.providerVersion; }
+ }
+ }
+}
diff --git a/vs2008-msmq.csproj b/vs2008-msmq.csproj
index 2d54f9a..6221c67 100644
--- a/vs2008-msmq.csproj
+++ b/vs2008-msmq.csproj
@@ -61,6 +61,7 @@
<HintPath>lib\Apache.NMS\net-2.0\Apache.NMS.dll</HintPath>
</Reference>
<Reference Include="System" />
+ <Reference Include="System.Data" />
<Reference Include="System.Messaging" />
<Reference Include="System.Xml" />
</ItemGroup>
@@ -70,6 +71,7 @@
<Compile Include="src\main\csharp\CommonAssemblyInfo.cs" />
<Compile Include="src\main\csharp\Connection.cs" />
<Compile Include="src\main\csharp\ConnectionFactory.cs" />
+ <Compile Include="src\main\csharp\ConnectionMetaData.cs" />
<Compile Include="src\main\csharp\DefaultMessageConverter.cs" />
<Compile Include="src\main\csharp\Destination.cs" />
<Compile Include="src\main\csharp\IMessageConverter.cs" />