summaryrefslogtreecommitdiff
path: root/dotnet/Qpid.Client.Tests/requestreply1/ServiceProvidingClient.cs
diff options
context:
space:
mode:
authorTomas Restrepo <tomasr@apache.org>2007-05-18 00:51:12 +0000
committerTomas Restrepo <tomasr@apache.org>2007-05-18 00:51:12 +0000
commitdbe349500e458cdf38cd4e561d27c9fa24dff7ca (patch)
tree2390c50d9a0d31506b6e9007ab7dfed5bb51ad16 /dotnet/Qpid.Client.Tests/requestreply1/ServiceProvidingClient.cs
parentee94c939a9d77f0de6ae0cb33c782a9015bb8452 (diff)
downloadqpid-python-dbe349500e458cdf38cd4e561d27c9fa24dff7ca.tar.gz
Merged revisions 537954-538078,538080-538083,538085-538097,538099-538108,538110-538239,538241-538881,538883-538906,538908-538911,538913-538921,538923-539191 via svnmerge from
https://svn.apache.org/repos/asf/incubator/qpid/branches/M2 ........ r537954 | tomasr | 2007-05-14 14:10:59 -0500 (Mon, 14 May 2007) | 4 lines * QPID-487 (Contributed by Carlos Medina) Fix QpidConnectionInfo.ToString() * QPID-485 (Contributed by Carlos Medina) Fix AmqBrokerInfo.Equals() * QPID-456 Enforce virtual host names start with '/' ........ r538035 | tomasr | 2007-05-14 20:33:00 -0500 (Mon, 14 May 2007) | 6 lines * QPID-452 Improve message classes API * Add XML documentation to IChannel and IMessage * Add missing BrokerDetailTests * Add new tests for message creation and message factories * Fix wrong default encoding for text messages ........ r539178 | tomasr | 2007-05-17 18:50:50 -0500 (Thu, 17 May 2007) | 6 lines * QPID-492 Fix Race condition in message decoding * QPID-249 Make ServiceRequestingClient and ServiceProvidingClient a single, self contained test * Fix incorrect exception message in Qpid.Buffers, improve tests * Make ContentBody use an sliced buffer to avoid extra data copy * Remove useless tests in Qpid.Client (Blocking IO tests) ........ r539191 | tomasr | 2007-05-17 19:18:26 -0500 (Thu, 17 May 2007) | 1 line QPID-490 (Contributed by Carlos Medina) Implement PurgeQueue and DeleteQueue ........ git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@539198 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'dotnet/Qpid.Client.Tests/requestreply1/ServiceProvidingClient.cs')
-rw-r--r--dotnet/Qpid.Client.Tests/requestreply1/ServiceProvidingClient.cs66
1 files changed, 31 insertions, 35 deletions
diff --git a/dotnet/Qpid.Client.Tests/requestreply1/ServiceProvidingClient.cs b/dotnet/Qpid.Client.Tests/requestreply1/ServiceProvidingClient.cs
index 515ae41e1c..ad5981a5c5 100644
--- a/dotnet/Qpid.Client.Tests/requestreply1/ServiceProvidingClient.cs
+++ b/dotnet/Qpid.Client.Tests/requestreply1/ServiceProvidingClient.cs
@@ -35,16 +35,15 @@ namespace Qpid.Client.Tests
private string _replyToExchangeName;
private string _replyToRoutingKey;
+ const int PACK = 100;
private IMessagePublisher _destinationPublisher;
+ private IMessageConsumer _consumer;
private string _serviceName = "ServiceQ1";
private string _selector = null;
- //private EventWaitHandle _event = new ManualResetEvent(false);
- private AutoResetEvent _event = new AutoResetEvent(false);
-
[SetUp]
public override void Init()
{
@@ -59,36 +58,38 @@ namespace Qpid.Client.Tests
_channel.DeclareQueue(_serviceName, false, false, false);
- IMessageConsumer consumer = _channel.CreateConsumerBuilder(_serviceName)
+ _consumer = _channel.CreateConsumerBuilder(_serviceName)
.WithPrefetchLow(100)
.WithPrefetchHigh(500)
.WithNoLocal(true)
.Create();
- consumer.OnMessage = new MessageReceivedDelegate(OnMessage);
+ _consumer.OnMessage = new MessageReceivedDelegate(OnMessage);
+ }
+
+ public override void Shutdown()
+ {
+ _consumer.Dispose();
+ base.Shutdown();
}
private void OnConnectionException(Exception e)
{
_logger.Info("Connection exception occurred", e);
- _event.Set(); // Shutdown test on error
// XXX: Test still doesn't shutdown when broker terminates. Is there no heartbeat?
}
[Test]
- public void TestFail()
- {
- Assert.Fail("Tests in this class do not run on autopilot, but hang forever, so commented out until can be fixed.");
- }
-
- /*[Test]
public void Test()
{
_connection.Start();
_logger.Info("Waiting...");
- _event.WaitOne();
- }*/
- public void OnMessage(IMessage message)
+ ServiceRequestingClient client = new ServiceRequestingClient();
+ client.Init();
+ client.SendMessages();
+ }
+
+ private void OnMessage(IMessage message)
{
// _logger.Info("Got message '" + message + "'");
@@ -109,9 +110,9 @@ namespace Qpid.Client.Tests
_destinationPublisher = _channel.CreatePublisherBuilder()
.WithExchangeName(_replyToExchangeName)
.WithRoutingKey(_replyToRoutingKey)
+ .WithDeliveryMode(DeliveryMode.NonPersistent)
.Create();
_destinationPublisher.DisableMessageTimestamp = true;
- _destinationPublisher.DeliveryMode = DeliveryMode.NonPersistent;
_logger.Debug("After create a producer");
}
catch (QpidException e)
@@ -120,7 +121,7 @@ namespace Qpid.Client.Tests
throw e;
}
_messageCount++;
- if (_messageCount % 1000 == 0)
+ if (_messageCount % PACK == 0)
{
_logger.Info("Received message total: " + _messageCount);
_logger.Info(string.Format("Sending response to '{0}:{1}'",
@@ -129,25 +130,20 @@ namespace Qpid.Client.Tests
try
{
- String payload = "This is a response: sing together: 'Mahnah mahnah...'" + tm.Text;
- ITextMessage msg = _channel.CreateTextMessage(payload);
- if (tm.Headers.Contains("timeSent"))
- {
-// _logger.Info("timeSent property set on message");
-// _logger.Info("timeSent value is: " + tm.Headers["timeSent"]);
- msg.Headers["timeSent"] = tm.Headers["timeSent"];
- }
- _destinationPublisher.Send(msg);
- if (_messageCount % 1000 == 0)
- {
- _logger.Info(string.Format("Sending response to '{0}:{1}'",
- _replyToExchangeName, _replyToRoutingKey));
- }
- }
- catch (QpidException e)
+ String payload = "This is a response: sing together: 'Mahnah mahnah...'" + tm.Text;
+ ITextMessage msg = _channel.CreateTextMessage(payload);
+ if ( tm.Headers.Contains("timeSent") )
+ {
+ msg.Headers["timeSent"] = tm.Headers["timeSent"];
+ }
+ _destinationPublisher.Send(msg);
+ } catch ( QpidException e )
{
- _logger.Error("Error sending message: " + e, e);
- throw e;
+ _logger.Error("Error sending message: " + e, e);
+ throw e;
+ } finally
+ {
+ _destinationPublisher.Dispose();
}
}
}