SPRNET-1233 - Support for sending to remote private queue. Clean up debug logging that would cause issues with remote private queues.
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
#region License
|
||||
|
||||
/*
|
||||
* Copyright <20> 2002-2007 the original author or authors.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#endregion
|
||||
|
||||
#region Imports
|
||||
|
||||
using NUnit.Framework;
|
||||
using Spring.Testing.NUnit;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace Spring.Messaging.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// This class contains tests for MessageQueueTemplate
|
||||
/// </summary>
|
||||
/// <author>Mark Pollack</author>
|
||||
[TestFixture]
|
||||
public class MessageQueueMetadataCacheTests : AbstractDependencyInjectionSpringContextTests
|
||||
{
|
||||
protected override string[] ConfigLocations
|
||||
{
|
||||
get { return new[] {"assembly://Spring.Messaging.Tests/Spring.Messaging.Core/MessageQueueTemplateTests.xml"}; }
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void InitialzeMessageQueueMetadata()
|
||||
{
|
||||
var cache = new MessageQueueMetadataCache(applicationContext);
|
||||
Assert.AreEqual(0, cache.Count);
|
||||
cache.Initialize();
|
||||
Assert.IsTrue(cache.Initalized);
|
||||
Assert.AreEqual(4, cache.Count);
|
||||
MessageQueueMetadata md = cache.Get(@".\Private$\testqueue");
|
||||
cache.Remove(@".\Private$\testqueue");
|
||||
Assert.AreEqual(3, cache.Count);
|
||||
Assert.IsNull(cache.Get(@".\Private$\testqueue"));
|
||||
|
||||
var paths = new[]
|
||||
{
|
||||
@".\Private$\testtxqueue",
|
||||
@"FormatName:Direct=TCP:192.168.1.105\Private$\testtxqueue",
|
||||
@"FormatName:Direct=TCP:192.168.1.105\Private$\testqueue"
|
||||
};
|
||||
|
||||
Assert.That(paths, Is.EquivalentTo(cache.Paths));
|
||||
paths = new[] {@".\Private$\testtxqueue", @"FormatName:Direct=TCP:192.168.1.105\Private$\testtxqueue"};
|
||||
cache.RemoveAll(paths);
|
||||
Assert.AreEqual(1, cache.Count);
|
||||
cache.Clear();
|
||||
Assert.AreEqual(0, cache.Count);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<objects xmlns="http://www.springframework.net">
|
||||
|
||||
|
||||
<object id='testqueue' type='Spring.Messaging.Support.MessageQueueFactoryObject, Spring.Messaging'>
|
||||
<property name='Path' value='.\Private$\testqueue'/>
|
||||
<property name='DenySharedReceive' value='true'/>
|
||||
<property name='AccessMode' value='Receive'/>
|
||||
<property name='EnableCache' value='true'/>
|
||||
<property name='ProductTemplate'>
|
||||
<object>
|
||||
<property name='Label' value='MyLabel'/>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
|
||||
<object id='testtxqueue' type='Spring.Messaging.Support.MessageQueueFactoryObject, Spring.Messaging'>
|
||||
<property name='Path' value='.\Private$\testtxqueue'/>
|
||||
<property name='ProductTemplate'>
|
||||
<object>
|
||||
<property name='Label' value='MyTxLabel'/>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
|
||||
|
||||
<object id='testremotetxqueue' type='Spring.Messaging.Support.MessageQueueFactoryObject, Spring.Messaging'>
|
||||
<property name='Path' value='FormatName:Direct=TCP:192.168.1.105\Private$\testtxqueue'/>
|
||||
<property name='RemoteQueue' value="true"/>
|
||||
<property name="RemoteQueueIsTransactional" value="true"/>
|
||||
</object>
|
||||
|
||||
<object id='testremotequeue' type='Spring.Messaging.Support.MessageQueueFactoryObject, Spring.Messaging'>
|
||||
<property name='Path' value='FormatName:Direct=TCP:192.168.1.105\Private$\testqueue'/>
|
||||
<property name='RemoteQueue' value="true"/>
|
||||
</object>
|
||||
|
||||
|
||||
|
||||
<object id='msqueue' type='Spring.Messaging.Support.MessageQueueFactoryObject, Spring.Messaging'>
|
||||
<property name='Path' value='.\Private$\testqueue'/>
|
||||
<property name='ProductTemplate'>
|
||||
<object>
|
||||
<property name='Label' value='MyLabel'/>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
|
||||
</objects>
|
||||
@@ -37,7 +37,7 @@ using Spring.Util;
|
||||
namespace Spring.Messaging.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// This class contains tests for
|
||||
/// This class contains tests for MessageQueueTemplate
|
||||
/// </summary>
|
||||
/// <author>Mark Pollack</author>
|
||||
[TestFixture]
|
||||
@@ -102,6 +102,8 @@ namespace Spring.Messaging.Core
|
||||
mqt.MessageQueueFactory.RegisterMessageQueue("fooQueueDefinition", sc.CreateQueue );
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
public class SimpleCreator
|
||||
{
|
||||
@@ -139,16 +141,6 @@ namespace Spring.Messaging.Core
|
||||
Assert.AreEqual(q.DefaultMessageQueue, q.MessageQueueFactory.CreateMessageQueue(q.DefaultMessageQueueObjectName));
|
||||
}
|
||||
|
||||
[Test, Ignore("obsolete test. If necessary, registers a default message converter on first use")]
|
||||
[ExpectedException(typeof (InvalidOperationException),
|
||||
ExpectedMessage = "No MessageConverter registered. Check configuration of MessageQueueTemplate.")]
|
||||
public void MessageConverterNotRegistered()
|
||||
{
|
||||
MessageQueueTemplate q = applicationContext["queue-noconverter"] as MessageQueueTemplate;
|
||||
Assert.IsNotNull(q);
|
||||
IMessageConverter c = q.MessageConverter;
|
||||
}
|
||||
|
||||
#region Integration Tests - to be moved to another test assembly
|
||||
|
||||
[Test]
|
||||
@@ -160,6 +152,15 @@ namespace Spring.Messaging.Core
|
||||
ReceiveHelloWorld(null,q,1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SendAndReceiveNonTransactionalRemotePrivateQueue()
|
||||
{
|
||||
MessageQueueTemplate q = applicationContext["queueTemplate-remote"] as MessageQueueTemplate;
|
||||
Assert.IsNotNull(q);
|
||||
q.ConvertAndSend("Hello World 1");
|
||||
//ReceiveHelloWorld(null, q, 1);
|
||||
}
|
||||
|
||||
private static void ReceiveHelloWorld(string messageQueueObjectName, MessageQueueTemplate q, int index)
|
||||
{
|
||||
object o = null;
|
||||
@@ -201,6 +202,7 @@ namespace Spring.Messaging.Core
|
||||
Receive(null,q);
|
||||
}
|
||||
|
||||
|
||||
private static void SendAndReceive(MessageQueueTemplate q)
|
||||
{
|
||||
SendAndReceive(null, q);
|
||||
@@ -255,7 +257,31 @@ namespace Spring.Messaging.Core
|
||||
|
||||
#endregion
|
||||
|
||||
[Test, Ignore("What's the purpose of this test?")]
|
||||
protected override string[] ConfigLocations
|
||||
{
|
||||
get { return new string[] { "assembly://Spring.Messaging.Tests/Spring.Messaging.Core/MessageQueueTemplateTests.xml" }; }
|
||||
}
|
||||
|
||||
|
||||
#region Some simple driver code for debugging
|
||||
public void SimpleRemoteConsumption()
|
||||
{
|
||||
string connectionWorking = @"FormatName:Direct=OS:MARKT60\Private$\testqueue";
|
||||
|
||||
//TCP:IP doesn't work...
|
||||
MessageQueue rmQ = new MessageQueue(@"FormatName:Direct=TCP:192.168.1.105\Private$\testqueue");
|
||||
|
||||
rmQ.Send("Hello Simple");
|
||||
|
||||
rmQ.Formatter = new XmlMessageFormatter(new Type[] { typeof(string) });
|
||||
|
||||
Message msg = rmQ.Receive();
|
||||
|
||||
Assert.IsNotNull(msg);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void GetAllFromQueue()
|
||||
{
|
||||
MessageQueueTemplate q = applicationContext["queue"] as MessageQueueTemplate;
|
||||
@@ -265,9 +291,7 @@ namespace Spring.Messaging.Core
|
||||
Console.WriteLine(q.ReceiveAndConvert());
|
||||
}
|
||||
}
|
||||
protected override string[] ConfigLocations
|
||||
{
|
||||
get { return new string[] {"assembly://Spring.Messaging.Tests/Spring.Messaging.Core/MessageQueueTemplateTests.xml"}; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@@ -23,16 +23,18 @@
|
||||
</property>
|
||||
</object>
|
||||
|
||||
|
||||
<object id='msqueue' type='Spring.Messaging.Support.MessageQueueFactoryObject, Spring.Messaging'>
|
||||
<property name='Path' value='.\Private$\testqueue'/>
|
||||
<property name='ProductTemplate'>
|
||||
<object>
|
||||
<property name='Label' value='MyLabel'/>
|
||||
</object>
|
||||
</property>
|
||||
<object id='testremotetxqueue' type='Spring.Messaging.Support.MessageQueueFactoryObject, Spring.Messaging'>
|
||||
<property name='Path' value='FormatName:Direct=OS:MARKT60\Private$\testqueue'/>
|
||||
<property name='RemoteQueue' value="true"/>
|
||||
<property name="RemoteQueueIsTransactional" value="true"/>
|
||||
</object>
|
||||
|
||||
<object id='testremotequeue' type='Spring.Messaging.Support.MessageQueueFactoryObject, Spring.Messaging'>
|
||||
<property name='Path' value='FormatName:Direct=OS:MARKT60\Private$\testqueue'/>
|
||||
<property name='RemoteQueue' value="true"/>
|
||||
</object>
|
||||
|
||||
|
||||
<object id="queue" type="Spring.Messaging.Core.MessageQueueTemplate, Spring.Messaging">
|
||||
<property name="DefaultMessageQueueObjectName" value="testtxqueue"/>
|
||||
<property name="MessageConverterObjectName" value="messageConverter"/>
|
||||
@@ -49,9 +51,32 @@
|
||||
<property name="MessageConverterObjectName" value="messageConverter"/>
|
||||
</object>
|
||||
|
||||
|
||||
<object id="queueTemplate-remote" type="Spring.Messaging.Core.MessageQueueTemplate, Spring.Messaging">
|
||||
<property name="DefaultMessageQueueObjectName" value="testremotequeue"/>
|
||||
<property name="MessageConverterObjectName" value="messageConverter"/>
|
||||
</object>
|
||||
|
||||
|
||||
<object id="queueTemplate-remote-tx" type="Spring.Messaging.Core.MessageQueueTemplate, Spring.Messaging">
|
||||
<property name="DefaultMessageQueueObjectName" value="testremotetxqueue"/>
|
||||
<property name="MessageConverterObjectName" value="messageConverter"/>
|
||||
</object>
|
||||
|
||||
|
||||
<object id="messageConverter" type="Spring.Messaging.Support.Converters.XmlMessageConverter, Spring.Messaging"
|
||||
singleton="false">
|
||||
<property name="TargetTypes" value="System.String"/>
|
||||
</object>
|
||||
|
||||
|
||||
|
||||
<object id='msqueue' type='Spring.Messaging.Support.MessageQueueFactoryObject, Spring.Messaging'>
|
||||
<property name='Path' value='.\Private$\testqueue'/>
|
||||
<property name='ProductTemplate'>
|
||||
<object>
|
||||
<property name='Label' value='MyLabel'/>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
|
||||
</objects>
|
||||
@@ -84,15 +84,19 @@ namespace Spring.Messaging.Listener
|
||||
[Test]
|
||||
public void SendAndAsyncReceive()
|
||||
{
|
||||
MessageQueueTemplate q = applicationContext["testQueueTemplate"] as MessageQueueTemplate;
|
||||
//MessageQueueTemplate q = applicationContext["testQueueTemplate"] as MessageQueueTemplate;
|
||||
MessageQueueTemplate q = applicationContext["testRemoteTemplate"] as MessageQueueTemplate;
|
||||
Assert.IsNotNull(q);
|
||||
|
||||
/*
|
||||
q.ConvertAndSend("Hello World 1");
|
||||
q.ConvertAndSend("Hello World 2");
|
||||
q.ConvertAndSend("Hello World 3");
|
||||
q.ConvertAndSend("Hello World 4");
|
||||
q.ConvertAndSend("Hello World 5");
|
||||
*/
|
||||
|
||||
|
||||
Assert.AreEqual(0, listener.MessageCount);
|
||||
|
||||
container.Start();
|
||||
@@ -104,6 +108,7 @@ namespace Spring.Messaging.Listener
|
||||
container.Stop();
|
||||
container.Shutdown();
|
||||
Thread.Sleep(2500);
|
||||
|
||||
}
|
||||
|
||||
protected override string[] ConfigLocations
|
||||
|
||||
@@ -33,8 +33,18 @@
|
||||
</property>
|
||||
</object>
|
||||
|
||||
<object id='testremotequeue' type='Spring.Messaging.Support.MessageQueueFactoryObject, Spring.Messaging'>
|
||||
<property name='Path' value='FormatName:Direct=OS:MARKT60\Private$\testqueue'/>
|
||||
<property name='RemoteQueue' value="true"/>
|
||||
</object>
|
||||
|
||||
<object id="testRemoteTemplate" type="Spring.Messaging.Core.MessageQueueTemplate, Spring.Messaging">
|
||||
<property name="DefaultMessageQueueObjectName" value="testremotequeue"/>
|
||||
<property name="MessageConverterObjectName" value="messageConverter"/>
|
||||
</object>
|
||||
|
||||
<object id="testQueueTemplate" type="Spring.Messaging.Core.MessageQueueTemplate, Spring.Messaging">
|
||||
<property name="MessageQueueObjectName" value="msmqTestQueue"/>
|
||||
<property name="DefaultMessageQueueObjectName" value="msmqTestQueue"/>
|
||||
<property name="MessageConverterObjectName" value="messageConverter"/>
|
||||
</object>
|
||||
|
||||
@@ -44,7 +54,7 @@
|
||||
</object>
|
||||
|
||||
<object id="nonTransactionalMessageListenerContainer" type="Spring.Messaging.Listener.NonTransactionalMessageListenerContainer, Spring.Messaging">
|
||||
<property name="MessageQueueObjectName" value="msmqTestQueue"/>
|
||||
<property name="MessageQueueObjectName" value="testremotequeue"/>
|
||||
<property name="MaxConcurrentListeners" value="2"/>
|
||||
<property name="ListenerTimeLimit" value="20s"/>
|
||||
<property name="MessageListener" ref="messageListenerAdapter"/>
|
||||
|
||||
@@ -17,6 +17,10 @@ namespace Spring.Messaging.Listener
|
||||
|
||||
private string stateVariable;
|
||||
|
||||
public SimpleHandler()
|
||||
{
|
||||
this.stateVariable = "hello";
|
||||
}
|
||||
public SimpleHandler(string stateVariable)
|
||||
{
|
||||
this.stateVariable = stateVariable;
|
||||
|
||||
@@ -80,11 +80,13 @@
|
||||
<EmbeddedResource Include="Messaging\queue-context.xml" />
|
||||
<EmbeddedResource Include="Messaging\Core\MessageQueueTemplateTests.xml" />
|
||||
<EmbeddedResource Include="Messaging\Listener\DistributedTxMessageListenerContainerTests.xml" />
|
||||
<EmbeddedResource Include="Messaging\Core\MessageQueueMetadataCacheTests.xml" />
|
||||
<Content Include="Spring.Messaging.Tests.dll.config">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Messaging\Core\MessageQueueMetadataCacheTests.cs" />
|
||||
<Compile Include="Messaging\Core\ThreadingTests.cs" />
|
||||
<Compile Include="Messaging\Listener\DistributedTxMessageListenerContainerTests.cs" />
|
||||
<Compile Include="Messaging\Listener\LoggingExceptionHandler.cs" />
|
||||
|
||||
Reference in New Issue
Block a user