From 054094d1d805e5812e7c7c3a534515f57ea1c606 Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Mon, 10 May 2010 20:33:19 +0000 Subject: 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 --- .../csharp.direct.receiver.cs | 57 ++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 cpp/bindings/qpid/dotnet/examples/csharp.direct.receiver/csharp.direct.receiver.cs (limited to 'cpp/bindings/qpid/dotnet/examples/csharp.direct.receiver/csharp.direct.receiver.cs') 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 -- cgit v1.2.1