summaryrefslogtreecommitdiff
path: root/cpp/bindings/qpid/dotnet/examples/csharp.direct.receiver/csharp.direct.receiver.cs
diff options
context:
space:
mode:
authorTed Ross <tross@apache.org>2010-05-10 20:33:19 +0000
committerTed Ross <tross@apache.org>2010-05-10 20:33:19 +0000
commit054094d1d805e5812e7c7c3a534515f57ea1c606 (patch)
tree8e8f2de1ac885232e46b7f3f40d2f5dd894c4a22 /cpp/bindings/qpid/dotnet/examples/csharp.direct.receiver/csharp.direct.receiver.cs
parentfe64caba89452ef43cc872c7f15faa655cc8a7da (diff)
downloadqpid-python-054094d1d805e5812e7c7c3a534515f57ea1c606.tar.gz
QPID-2589 - Applied patch from Chuck Rolke.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@942892 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/bindings/qpid/dotnet/examples/csharp.direct.receiver/csharp.direct.receiver.cs')
-rw-r--r--cpp/bindings/qpid/dotnet/examples/csharp.direct.receiver/csharp.direct.receiver.cs57
1 files changed, 57 insertions, 0 deletions
diff --git a/cpp/bindings/qpid/dotnet/examples/csharp.direct.receiver/csharp.direct.receiver.cs b/cpp/bindings/qpid/dotnet/examples/csharp.direct.receiver/csharp.direct.receiver.cs
new file mode 100644
index 0000000000..db54600882
--- /dev/null
+++ b/cpp/bindings/qpid/dotnet/examples/csharp.direct.receiver/csharp.direct.receiver.cs
@@ -0,0 +1,57 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using org.apache.qpid.messaging;
+
+namespace CSharpDirect
+{
+ class Program
+ {
+ // Direct receiver example
+ //
+ // Receive 10 messages from localhost:5672, amq.direct/key
+ //
+ static void Main(string[] args)
+ {
+ String host = "localhost:5672";
+ String addr = "amq.direct/key";
+ int nMsg = 10;
+
+ Connection conn = new Connection(host);
+
+ conn.open();
+
+ if (!conn.isOpen())
+ {
+ Console.WriteLine("Failed to open connection to host : {0}", host);
+ }
+ else
+ {
+
+ Session sess = conn.createSession();
+
+ Duration dur = new Duration(1000 * 3600 * 24); // Wait one day
+
+ Receiver rcv = sess.createReceiver(addr);
+
+ Message msg = new Message("");
+
+ for (int i = 0; i < nMsg; i++)
+ {
+ try
+ {
+ Message msg2 = rcv.fetch(dur);
+ Console.WriteLine("Rcvd msg {0} : {1}", i, msg2.getContent());
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("Exception {0}.", e);
+ }
+ }
+
+ conn.close();
+ }
+ }
+ }
+} \ No newline at end of file