Return-Path: Delivered-To: apmail-qpid-commits-archive@www.apache.org Received: (qmail 53496 invoked from network); 3 Dec 2009 22:04:55 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 3 Dec 2009 22:04:55 -0000 Received: (qmail 48753 invoked by uid 500); 3 Dec 2009 22:04:54 -0000 Delivered-To: apmail-qpid-commits-archive@qpid.apache.org Received: (qmail 48738 invoked by uid 500); 3 Dec 2009 22:04:54 -0000 Mailing-List: contact commits-help@qpid.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@qpid.apache.org Delivered-To: mailing list commits@qpid.apache.org Received: (qmail 48729 invoked by uid 99); 3 Dec 2009 22:04:54 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 03 Dec 2009 22:04:54 +0000 X-ASF-Spam-Status: No, hits=-3.5 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 03 Dec 2009 22:04:50 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 69DE62388A6C; Thu, 3 Dec 2009 22:04:02 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: svn commit: r886940 [9/14] - in /qpid/trunk/qpid/dotnet/client-010: ./ addins/ addins/ExcelAddIn/ addins/ExcelAddInMessageProcessor/ addins/ExcelAddInProducer/ client/ client/client/ client/transport/ client/transport/codec/ client/transport/exception/... Date: Thu, 03 Dec 2009 22:03:55 -0000 To: commits@qpid.apache.org From: aidan@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20091203220402.69DE62388A6C@eris.apache.org> Modified: qpid/trunk/qpid/dotnet/client-010/examples/pub-sub/example-pub-sub-Listener/Listener.cs URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/dotnet/client-010/examples/pub-sub/example-pub-sub-Listener/Listener.cs?rev=886940&r1=886939&r2=886940&view=diff ============================================================================== --- qpid/trunk/qpid/dotnet/client-010/examples/pub-sub/example-pub-sub-Listener/Listener.cs (original) +++ qpid/trunk/qpid/dotnet/client-010/examples/pub-sub/example-pub-sub-Listener/Listener.cs Thu Dec 3 22:03:51 2009 @@ -1,138 +1,138 @@ -/* -* 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.IO; -using System.Text; -using System.Threading; -using org.apache.qpid.client; -using org.apache.qpid.transport; - -namespace org.apache.qpid.example.pubsub -{ - /// - /// This program is one of two programs designed to be used - /// together. These programs use the topic exchange. - /// - /// Publisher: - /// - /// Publishes to a broker, specifying a routing key. - /// - /// Listener (this program): - /// - /// Reads from a queue on the broker using a message listener. - /// - /// - internal class Listener - { - public static int _count = 4; - - private static void Main(string[] args) - { - string host = args.Length > 0 ? args[0] : "localhost"; - int port = args.Length > 1 ? Convert.ToInt32(args[1]) : 5672; - Client connection = new Client(); - try - { - connection.connect(host, port, "test", "guest", "guest"); - ClientSession session = connection.createSession(50000); - - //--------- Main body of program -------------------------------------------- - - lock (session) - { - Console.WriteLine("Listening for messages ..."); - // Create a listener - prepareQueue("usa", "usa.#", session); - prepareQueue("europe", "europe.#", session); - prepareQueue("news", "#.news", session); - prepareQueue("weather", "#.weather", session); - while (_count > 0) - { - Monitor.Wait(session); - } - } - - //--------------------------------------------------------------------------- - - connection.close(); - } - catch (Exception e) - { - Console.WriteLine("Error: \n" + e.StackTrace); - } - } - - private static void prepareQueue(string queue, string routing_key, ClientSession session) - { - // Create a unique queue name for this consumer by concatenating - // the queue name parameter with the Session ID. - Console.WriteLine("Declaring queue: " + queue); - session.queueDeclare(queue, Option.EXCLUSIVE, Option.AUTO_DELETE); - - // Route messages to the new queue if they match the routing key. - // Also route any messages to with the "control" routing key to - // this queue so we know when it's time to stop. A publisher sends - // a message with the content "That's all, Folks!", using the - // "control" routing key, when it is finished. - - session.exchangeBind(queue, "amq.topic", routing_key); - session.exchangeBind(queue, "amq.topic", "control"); - - // subscribe the listener to the queue - IMessageListener listener = new MessageListener(session); - session.attachMessageListener(listener, queue); - session.messageSubscribe(queue); - } - } - - public class MessageListener : IMessageListener - { - private readonly ClientSession _session; - private readonly RangeSet _range = new RangeSet(); - - public MessageListener(ClientSession session) - { - _session = session; - } - - public void messageTransfer(IMessage m) - { - BinaryReader reader = new BinaryReader(m.Body, Encoding.UTF8); - byte[] body = new byte[m.Body.Length - m.Body.Position]; - reader.Read(body, 0, body.Length); - ASCIIEncoding enc = new ASCIIEncoding(); - string message = enc.GetString(body); - Console.WriteLine("Message: " + message + " from " + m.Destination); - // Add this message to the list of message to be acknowledged - _range.add(m.Id); - if (message.Equals("That's all, folks!")) - { - Console.WriteLine("Shutting down listener for " + m.DeliveryProperties.getRoutingKey()); - Listener._count--; - // Acknowledge all the received messages - _session.messageAccept(_range); - lock (_session) - { - Monitor.Pulse(_session); - } - } - } - } -} +/* +* 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.IO; +using System.Text; +using System.Threading; +using org.apache.qpid.client; +using org.apache.qpid.transport; + +namespace org.apache.qpid.example.pubsub +{ + /// + /// This program is one of two programs designed to be used + /// together. These programs use the topic exchange. + /// + /// Publisher: + /// + /// Publishes to a broker, specifying a routing key. + /// + /// Listener (this program): + /// + /// Reads from a queue on the broker using a message listener. + /// + /// + internal class Listener + { + public static int _count = 4; + + private static void Main(string[] args) + { + string host = args.Length > 0 ? args[0] : "localhost"; + int port = args.Length > 1 ? Convert.ToInt32(args[1]) : 5672; + Client connection = new Client(); + try + { + connection.connect(host, port, "test", "guest", "guest"); + ClientSession session = connection.createSession(50000); + + //--------- Main body of program -------------------------------------------- + + lock (session) + { + Console.WriteLine("Listening for messages ..."); + // Create a listener + prepareQueue("usa", "usa.#", session); + prepareQueue("europe", "europe.#", session); + prepareQueue("news", "#.news", session); + prepareQueue("weather", "#.weather", session); + while (_count > 0) + { + Monitor.Wait(session); + } + } + + //--------------------------------------------------------------------------- + + connection.close(); + } + catch (Exception e) + { + Console.WriteLine("Error: \n" + e.StackTrace); + } + } + + private static void prepareQueue(string queue, string routing_key, ClientSession session) + { + // Create a unique queue name for this consumer by concatenating + // the queue name parameter with the Session ID. + Console.WriteLine("Declaring queue: " + queue); + session.queueDeclare(queue, Option.EXCLUSIVE, Option.AUTO_DELETE); + + // Route messages to the new queue if they match the routing key. + // Also route any messages to with the "control" routing key to + // this queue so we know when it's time to stop. A publisher sends + // a message with the content "That's all, Folks!", using the + // "control" routing key, when it is finished. + + session.exchangeBind(queue, "amq.topic", routing_key); + session.exchangeBind(queue, "amq.topic", "control"); + + // subscribe the listener to the queue + IMessageListener listener = new MessageListener(session); + session.attachMessageListener(listener, queue); + session.messageSubscribe(queue); + } + } + + public class MessageListener : IMessageListener + { + private readonly ClientSession _session; + private readonly RangeSet _range = new RangeSet(); + + public MessageListener(ClientSession session) + { + _session = session; + } + + public void messageTransfer(IMessage m) + { + BinaryReader reader = new BinaryReader(m.Body, Encoding.UTF8); + byte[] body = new byte[m.Body.Length - m.Body.Position]; + reader.Read(body, 0, body.Length); + ASCIIEncoding enc = new ASCIIEncoding(); + string message = enc.GetString(body); + Console.WriteLine("Message: " + message + " from " + m.Destination); + // Add this message to the list of message to be acknowledged + _range.add(m.Id); + if (message.Equals("That's all, folks!")) + { + Console.WriteLine("Shutting down listener for " + m.DeliveryProperties.getRoutingKey()); + Listener._count--; + // Acknowledge all the received messages + _session.messageAccept(_range); + lock (_session) + { + Monitor.Pulse(_session); + } + } + } + } +} Modified: qpid/trunk/qpid/dotnet/client-010/examples/pub-sub/example-pub-sub-Listener/example-pub-sub-Listener.csproj URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/dotnet/client-010/examples/pub-sub/example-pub-sub-Listener/example-pub-sub-Listener.csproj?rev=886940&r1=886939&r2=886940&view=diff ============================================================================== --- qpid/trunk/qpid/dotnet/client-010/examples/pub-sub/example-pub-sub-Listener/example-pub-sub-Listener.csproj (original) +++ qpid/trunk/qpid/dotnet/client-010/examples/pub-sub/example-pub-sub-Listener/example-pub-sub-Listener.csproj Thu Dec 3 22:03:51 2009 @@ -1,59 +1,59 @@ - - - - Debug - AnyCPU - 8.0.50727 - 2.0 - {2BCDC2CC-5BDA-4CC7-944D-2899AD8A53C7} - Exe - Properties - example_pub_sub_Listener - example-pub-sub-Listener - - - 2.0 - - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - {B911FFD7-754F-4735-A188-218D5065BE79} - Client - - - + + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {2BCDC2CC-5BDA-4CC7-944D-2899AD8A53C7} + Exe + Properties + example_pub_sub_Listener + example-pub-sub-Listener + + + 2.0 + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + {B911FFD7-754F-4735-A188-218D5065BE79} + Client + + + + --> \ No newline at end of file Modified: qpid/trunk/qpid/dotnet/client-010/examples/pub-sub/example-pub-sub-Publisher/Publisher.cs URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/dotnet/client-010/examples/pub-sub/example-pub-sub-Publisher/Publisher.cs?rev=886940&r1=886939&r2=886940&view=diff ============================================================================== --- qpid/trunk/qpid/dotnet/client-010/examples/pub-sub/example-pub-sub-Publisher/Publisher.cs (original) +++ qpid/trunk/qpid/dotnet/client-010/examples/pub-sub/example-pub-sub-Publisher/Publisher.cs Thu Dec 3 22:03:51 2009 @@ -1,93 +1,93 @@ -/* -* 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.Text; -using org.apache.qpid.client; - -namespace org.apache.qpid.example.pubsub -{ - /// - /// This program is one of two programs designed to be used - /// together. These programs use the topic exchange. - /// - /// Publisher (this program): - /// - /// Publishes to a broker, specifying a routing key. - /// - /// Listener: - /// - /// Reads from a queue on the broker using a message listener. - /// - /// - internal class Publisher - { - private static void Main(string[] args) - { - string host = args.Length > 0 ? args[0] : "localhost"; - int port = args.Length > 1 ? Convert.ToInt32(args[1]) : 5672; - Client connection = new Client(); - try - { - connection.connect(host, port, "test", "guest", "guest"); - ClientSession session = connection.createSession(50000); - - //--------- Main body of program -------------------------------------------- - - publishMessages(session, "usa.news"); - publishMessages(session, "usa.weather"); - publishMessages(session, "europe.news"); - publishMessages(session, "europe.weather"); - - noMoreMessages(session); - - //----------------------------------------------------------------------------- - - connection.close(); - } - catch (Exception e) - { - Console.WriteLine("Error: \n" + e.StackTrace); - } - } - - private static void publishMessages(ClientSession session, string routing_key) - { - IMessage message = new Message(); - // Asynchronous transfer sends messages as quickly as - // possible without waiting for confirmation. - for (int i = 0; i < 10; i++) - { - message.clearData(); - message.appendData(Encoding.UTF8.GetBytes("Message " + i)); - session.messageTransfer("amq.topic", routing_key, message); - } - } - - private static void noMoreMessages(ClientSession session) - { - IMessage message = new Message(); - // And send a syncrhonous final message to indicate termination. - message.clearData(); - message.appendData(Encoding.UTF8.GetBytes("That's all, folks!")); - session.messageTransfer("amq.topic", "control", message); - session.sync(); - } - } -} +/* +* 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.Text; +using org.apache.qpid.client; + +namespace org.apache.qpid.example.pubsub +{ + /// + /// This program is one of two programs designed to be used + /// together. These programs use the topic exchange. + /// + /// Publisher (this program): + /// + /// Publishes to a broker, specifying a routing key. + /// + /// Listener: + /// + /// Reads from a queue on the broker using a message listener. + /// + /// + internal class Publisher + { + private static void Main(string[] args) + { + string host = args.Length > 0 ? args[0] : "localhost"; + int port = args.Length > 1 ? Convert.ToInt32(args[1]) : 5672; + Client connection = new Client(); + try + { + connection.connect(host, port, "test", "guest", "guest"); + ClientSession session = connection.createSession(50000); + + //--------- Main body of program -------------------------------------------- + + publishMessages(session, "usa.news"); + publishMessages(session, "usa.weather"); + publishMessages(session, "europe.news"); + publishMessages(session, "europe.weather"); + + noMoreMessages(session); + + //----------------------------------------------------------------------------- + + connection.close(); + } + catch (Exception e) + { + Console.WriteLine("Error: \n" + e.StackTrace); + } + } + + private static void publishMessages(ClientSession session, string routing_key) + { + IMessage message = new Message(); + // Asynchronous transfer sends messages as quickly as + // possible without waiting for confirmation. + for (int i = 0; i < 10; i++) + { + message.clearData(); + message.appendData(Encoding.UTF8.GetBytes("Message " + i)); + session.messageTransfer("amq.topic", routing_key, message); + } + } + + private static void noMoreMessages(ClientSession session) + { + IMessage message = new Message(); + // And send a syncrhonous final message to indicate termination. + message.clearData(); + message.appendData(Encoding.UTF8.GetBytes("That's all, folks!")); + session.messageTransfer("amq.topic", "control", message); + session.sync(); + } + } +} Modified: qpid/trunk/qpid/dotnet/client-010/examples/pub-sub/example-pub-sub-Publisher/example-pub-sub-Publisher.csproj URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/dotnet/client-010/examples/pub-sub/example-pub-sub-Publisher/example-pub-sub-Publisher.csproj?rev=886940&r1=886939&r2=886940&view=diff ============================================================================== --- qpid/trunk/qpid/dotnet/client-010/examples/pub-sub/example-pub-sub-Publisher/example-pub-sub-Publisher.csproj (original) +++ qpid/trunk/qpid/dotnet/client-010/examples/pub-sub/example-pub-sub-Publisher/example-pub-sub-Publisher.csproj Thu Dec 3 22:03:51 2009 @@ -1,59 +1,59 @@ - - - - Debug - AnyCPU - 8.0.50727 - 2.0 - {F8857634-A134-44E7-A953-F2B22688C599} - Exe - Properties - example_pub_sub_Publisher - example-pub-sub-Publisher - - - 2.0 - - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - {B911FFD7-754F-4735-A188-218D5065BE79} - Client - - - + + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {F8857634-A134-44E7-A953-F2B22688C599} + Exe + Properties + example_pub_sub_Publisher + example-pub-sub-Publisher + + + 2.0 + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + {B911FFD7-754F-4735-A188-218D5065BE79} + Client + + + + --> \ No newline at end of file Modified: qpid/trunk/qpid/dotnet/client-010/examples/request-response/example-request-response-Client/Client.cs URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/dotnet/client-010/examples/request-response/example-request-response-Client/Client.cs?rev=886940&r1=886939&r2=886940&view=diff ============================================================================== --- qpid/trunk/qpid/dotnet/client-010/examples/request-response/example-request-response-Client/Client.cs (original) +++ qpid/trunk/qpid/dotnet/client-010/examples/request-response/example-request-response-Client/Client.cs Thu Dec 3 22:03:51 2009 @@ -1,137 +1,137 @@ -/* -* 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.IO; -using System.Text; -using System.Threading; -using org.apache.qpid.client; -using org.apache.qpid.transport; - -namespace org.apache.qpid.example.requestresponse -{ - /// - /// This program is one of two programs that illustrate the - /// request/response pattern. - /// - /// Client (this program): - /// Make requests of a service, print the response. - /// - /// Server: - /// Accept requests, set the letters to uppercase in each message, and - /// return it as a response. - /// - /// - internal class Client - { - private static void Main(string[] args) - { - string host = args.Length > 0 ? args[0] : "localhost"; - int port = args.Length > 1 ? Convert.ToInt32(args[1]) : 5672; - client.Client connection = new client.Client(); - try - { - connection.connect(host, port, "test", "guest", "guest"); - ClientSession session = connection.createSession(50000); - IMessage request = new Message(); - - //--------- Main body of program -------------------------------------------- - // Create a response queue so the server can send us responses - // to our requests. Use the client's session ID as the name - // of the response queue. - string response_queue = "client" + session.getName(); - // Use the name of the response queue as the routing key - session.queueDeclare(response_queue); - session.exchangeBind(response_queue, "amq.direct", response_queue); - - // Each client sends the name of their own response queue so - // the service knows where to route messages. - request.DeliveryProperties.setRoutingKey("request"); - request.MessageProperties.setReplyTo(new ReplyTo("amq.direct", response_queue)); - - lock (session) - { - // Create a listener for the response queue and listen for response messages. - Console.WriteLine("Activating response queue listener for: " + response_queue); - IMessageListener listener = new ClientMessageListener(session); - session.attachMessageListener(listener, response_queue); - session.messageSubscribe(response_queue); - - // Now send some requests ... - string[] strs = { - "Twas brillig, and the slithy toves", - "Did gire and gymble in the wabe.", - "All mimsy were the borogroves,", - "And the mome raths outgrabe.", - "That's all, folks!" - }; - foreach (string s in strs) - { - request.clearData(); - request.appendData(Encoding.UTF8.GetBytes(s)); - session.messageTransfer("amq.direct", request); - } - Console.WriteLine("Waiting for all responses to arrive ..."); - Monitor.Wait(session); - } - //--------------------------------------------------------------------------- - - connection.close(); - } - catch (Exception e) - { - Console.WriteLine("Error: \n" + e.StackTrace); - } - } - } - - public class ClientMessageListener : IMessageListener - { - private readonly ClientSession _session; - private readonly RangeSet _range = new RangeSet(); - private int _counter; - public ClientMessageListener(ClientSession session) - { - _session = session; - } - - public void messageTransfer(IMessage m) - { - _counter++; - BinaryReader reader = new BinaryReader(m.Body, Encoding.UTF8); - byte[] body = new byte[m.Body.Length - m.Body.Position]; - reader.Read(body, 0, body.Length); - ASCIIEncoding enc = new ASCIIEncoding(); - string message = enc.GetString(body); - Console.WriteLine("Response: " + message); - // Add this message to the list of message to be acknowledged - _range.add(m.Id); - if (_counter == 4) - { - Console.WriteLine("Shutting down listener for " + m.DeliveryProperties.getRoutingKey()); - // Acknowledge all the received messages - _session.messageAccept(_range); - lock (_session) - { - Monitor.Pulse(_session); - } - } - } - } -} +/* +* 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.IO; +using System.Text; +using System.Threading; +using org.apache.qpid.client; +using org.apache.qpid.transport; + +namespace org.apache.qpid.example.requestresponse +{ + /// + /// This program is one of two programs that illustrate the + /// request/response pattern. + /// + /// Client (this program): + /// Make requests of a service, print the response. + /// + /// Server: + /// Accept requests, set the letters to uppercase in each message, and + /// return it as a response. + /// + /// + internal class Client + { + private static void Main(string[] args) + { + string host = args.Length > 0 ? args[0] : "localhost"; + int port = args.Length > 1 ? Convert.ToInt32(args[1]) : 5672; + client.Client connection = new client.Client(); + try + { + connection.connect(host, port, "test", "guest", "guest"); + ClientSession session = connection.createSession(50000); + IMessage request = new Message(); + + //--------- Main body of program -------------------------------------------- + // Create a response queue so the server can send us responses + // to our requests. Use the client's session ID as the name + // of the response queue. + string response_queue = "client" + session.getName(); + // Use the name of the response queue as the routing key + session.queueDeclare(response_queue); + session.exchangeBind(response_queue, "amq.direct", response_queue); + + // Each client sends the name of their own response queue so + // the service knows where to route messages. + request.DeliveryProperties.setRoutingKey("request"); + request.MessageProperties.setReplyTo(new ReplyTo("amq.direct", response_queue)); + + lock (session) + { + // Create a listener for the response queue and listen for response messages. + Console.WriteLine("Activating response queue listener for: " + response_queue); + IMessageListener listener = new ClientMessageListener(session); + session.attachMessageListener(listener, response_queue); + session.messageSubscribe(response_queue); + + // Now send some requests ... + string[] strs = { + "Twas brillig, and the slithy toves", + "Did gire and gymble in the wabe.", + "All mimsy were the borogroves,", + "And the mome raths outgrabe.", + "That's all, folks!" + }; + foreach (string s in strs) + { + request.clearData(); + request.appendData(Encoding.UTF8.GetBytes(s)); + session.messageTransfer("amq.direct", request); + } + Console.WriteLine("Waiting for all responses to arrive ..."); + Monitor.Wait(session); + } + //--------------------------------------------------------------------------- + + connection.close(); + } + catch (Exception e) + { + Console.WriteLine("Error: \n" + e.StackTrace); + } + } + } + + public class ClientMessageListener : IMessageListener + { + private readonly ClientSession _session; + private readonly RangeSet _range = new RangeSet(); + private int _counter; + public ClientMessageListener(ClientSession session) + { + _session = session; + } + + public void messageTransfer(IMessage m) + { + _counter++; + BinaryReader reader = new BinaryReader(m.Body, Encoding.UTF8); + byte[] body = new byte[m.Body.Length - m.Body.Position]; + reader.Read(body, 0, body.Length); + ASCIIEncoding enc = new ASCIIEncoding(); + string message = enc.GetString(body); + Console.WriteLine("Response: " + message); + // Add this message to the list of message to be acknowledged + _range.add(m.Id); + if (_counter == 4) + { + Console.WriteLine("Shutting down listener for " + m.DeliveryProperties.getRoutingKey()); + // Acknowledge all the received messages + _session.messageAccept(_range); + lock (_session) + { + Monitor.Pulse(_session); + } + } + } + } +} Modified: qpid/trunk/qpid/dotnet/client-010/examples/request-response/example-request-response-Client/example-request-response-Client.csproj URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/dotnet/client-010/examples/request-response/example-request-response-Client/example-request-response-Client.csproj?rev=886940&r1=886939&r2=886940&view=diff ============================================================================== --- qpid/trunk/qpid/dotnet/client-010/examples/request-response/example-request-response-Client/example-request-response-Client.csproj (original) +++ qpid/trunk/qpid/dotnet/client-010/examples/request-response/example-request-response-Client/example-request-response-Client.csproj Thu Dec 3 22:03:51 2009 @@ -1,59 +1,59 @@ - - - - Debug - AnyCPU - 8.0.50727 - 2.0 - {1BC63815-4029-4039-9207-35E7E06ECC99} - Exe - Properties - example_request_response_Client - example-request-response-Client - - - 2.0 - - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - {B911FFD7-754F-4735-A188-218D5065BE79} - Client - - - + + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {1BC63815-4029-4039-9207-35E7E06ECC99} + Exe + Properties + example_request_response_Client + example-request-response-Client + + + 2.0 + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + {B911FFD7-754F-4735-A188-218D5065BE79} + Client + + + + --> \ No newline at end of file Modified: qpid/trunk/qpid/dotnet/client-010/examples/request-response/example-request-response-Server/Server.cs URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/dotnet/client-010/examples/request-response/example-request-response-Server/Server.cs?rev=886940&r1=886939&r2=886940&view=diff ============================================================================== --- qpid/trunk/qpid/dotnet/client-010/examples/request-response/example-request-response-Server/Server.cs (original) +++ qpid/trunk/qpid/dotnet/client-010/examples/request-response/example-request-response-Server/Server.cs Thu Dec 3 22:03:51 2009 @@ -1,136 +1,136 @@ -/* -* 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.IO; -using System.Text; -using System.Threading; -using org.apache.qpid.client; -using org.apache.qpid.transport; - -namespace org.apache.qpid.example.requestresponse -{ - /// - /// This program is one of two programs that illustrate the - /// request/response pattern. - /// - /// Client: - /// Make requests of a service, print the response. - /// - /// Server (this program): - /// Accept requests, set the letters to uppercase in each message, and - /// return it as a response. - /// - /// - class Server - { - static void Main(string[] args) - { - string host = args.Length > 0 ? args[0] : "localhost"; - int port = args.Length > 1 ? Convert.ToInt32(args[1]) : 5672; - client.Client connection = new client.Client(); - try - { - connection.connect(host, port, "test", "guest", "guest"); - ClientSession session = connection.createSession(50000); - - //--------- Main body of program -------------------------------------------- - // Create a request queue for clients to use when making - // requests. - const string request_queue = "request"; - // Use the name of the request queue as the routing key - session.queueDeclare(request_queue); - session.exchangeBind(request_queue, "amq.direct", request_queue); - - lock (session) - { - // Create a listener and subscribe it to the request_queue - IMessageListener listener = new MessageListener(session); - session.attachMessageListener(listener, request_queue); - session.messageSubscribe(request_queue); - // Receive messages until all messages are received - Console.WriteLine("Waiting for requests"); - Monitor.Wait(session); - } - - //--------------------------------------------------------------------------- - - connection.close(); - } - catch (Exception e) - { - Console.WriteLine("Error: \n" + e.StackTrace); - } - } - } - - public class MessageListener : IMessageListener - { - private readonly ClientSession _session; - private readonly RangeSet _range = new RangeSet(); - public MessageListener(ClientSession session) - { - _session = session; - } - - public void messageTransfer(IMessage request) - { - IMessage response = new Message(); - - // Get routing key for response from the request's replyTo property - string routingKey; - if( request.MessageProperties.hasReplyTo() ) - { - routingKey = request.MessageProperties.getReplyTo().getRoutingKey(); - } - else - { - Console.WriteLine("Error: \n No routing key for request " + request); - return; - } - - BinaryReader reader = new BinaryReader(request.Body, Encoding.UTF8); - byte[] body = new byte[request.Body.Length - request.Body.Position]; - reader.Read(body, 0, body.Length); - ASCIIEncoding enc = new ASCIIEncoding(); - string message = enc.GetString(body); - Console.WriteLine("Request: " + message); - - // Transform message content to upper case - string responseBody = message.ToUpper(); - - // Send it back to the user - response.clearData(); - response.appendData(Encoding.UTF8.GetBytes(responseBody)); - _session.messageTransfer("amq.direct", routingKey, response); - - // Add this message to the list of message to be acknowledged - _range.add(request.Id); - if (message.Equals("That's all, folks!")) - { - // Acknowledge all the received messages - _session.messageAccept(_range); - lock (_session) - { - Monitor.Pulse(_session); - } - } - } - } -} +/* +* 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.IO; +using System.Text; +using System.Threading; +using org.apache.qpid.client; +using org.apache.qpid.transport; + +namespace org.apache.qpid.example.requestresponse +{ + /// + /// This program is one of two programs that illustrate the + /// request/response pattern. + /// + /// Client: + /// Make requests of a service, print the response. + /// + /// Server (this program): + /// Accept requests, set the letters to uppercase in each message, and + /// return it as a response. + /// + /// + class Server + { + static void Main(string[] args) + { + string host = args.Length > 0 ? args[0] : "localhost"; + int port = args.Length > 1 ? Convert.ToInt32(args[1]) : 5672; + client.Client connection = new client.Client(); + try + { + connection.connect(host, port, "test", "guest", "guest"); + ClientSession session = connection.createSession(50000); + + //--------- Main body of program -------------------------------------------- + // Create a request queue for clients to use when making + // requests. + const string request_queue = "request"; + // Use the name of the request queue as the routing key + session.queueDeclare(request_queue); + session.exchangeBind(request_queue, "amq.direct", request_queue); + + lock (session) + { + // Create a listener and subscribe it to the request_queue + IMessageListener listener = new MessageListener(session); + session.attachMessageListener(listener, request_queue); + session.messageSubscribe(request_queue); + // Receive messages until all messages are received + Console.WriteLine("Waiting for requests"); + Monitor.Wait(session); + } + + //--------------------------------------------------------------------------- + + connection.close(); + } + catch (Exception e) + { + Console.WriteLine("Error: \n" + e.StackTrace); + } + } + } + + public class MessageListener : IMessageListener + { + private readonly ClientSession _session; + private readonly RangeSet _range = new RangeSet(); + public MessageListener(ClientSession session) + { + _session = session; + } + + public void messageTransfer(IMessage request) + { + IMessage response = new Message(); + + // Get routing key for response from the request's replyTo property + string routingKey; + if( request.MessageProperties.hasReplyTo() ) + { + routingKey = request.MessageProperties.getReplyTo().getRoutingKey(); + } + else + { + Console.WriteLine("Error: \n No routing key for request " + request); + return; + } + + BinaryReader reader = new BinaryReader(request.Body, Encoding.UTF8); + byte[] body = new byte[request.Body.Length - request.Body.Position]; + reader.Read(body, 0, body.Length); + ASCIIEncoding enc = new ASCIIEncoding(); + string message = enc.GetString(body); + Console.WriteLine("Request: " + message); + + // Transform message content to upper case + string responseBody = message.ToUpper(); + + // Send it back to the user + response.clearData(); + response.appendData(Encoding.UTF8.GetBytes(responseBody)); + _session.messageTransfer("amq.direct", routingKey, response); + + // Add this message to the list of message to be acknowledged + _range.add(request.Id); + if (message.Equals("That's all, folks!")) + { + // Acknowledge all the received messages + _session.messageAccept(_range); + lock (_session) + { + Monitor.Pulse(_session); + } + } + } + } +} Modified: qpid/trunk/qpid/dotnet/client-010/examples/request-response/example-request-response-Server/example-request-response-Server.csproj URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/dotnet/client-010/examples/request-response/example-request-response-Server/example-request-response-Server.csproj?rev=886940&r1=886939&r2=886940&view=diff ============================================================================== --- qpid/trunk/qpid/dotnet/client-010/examples/request-response/example-request-response-Server/example-request-response-Server.csproj (original) +++ qpid/trunk/qpid/dotnet/client-010/examples/request-response/example-request-response-Server/example-request-response-Server.csproj Thu Dec 3 22:03:51 2009 @@ -1,59 +1,59 @@ - - - - Debug - AnyCPU - 8.0.50727 - 2.0 - {922FBA9C-E483-4AEF-ABE8-AC87421E829B} - Exe - Properties - example_request_response_Server - example-request-response-Server - - - 2.0 - - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - {B911FFD7-754F-4735-A188-218D5065BE79} - Client - - - + + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {922FBA9C-E483-4AEF-ABE8-AC87421E829B} + Exe + Properties + example_request_response_Server + example-request-response-Server + + + 2.0 + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + {B911FFD7-754F-4735-A188-218D5065BE79} + Client + + + + --> \ No newline at end of file Modified: qpid/trunk/qpid/dotnet/client-010/gentool/build.xml URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/dotnet/client-010/gentool/build.xml?rev=886940&r1=886939&r2=886940&view=diff ============================================================================== --- qpid/trunk/qpid/dotnet/client-010/gentool/build.xml (original) +++ qpid/trunk/qpid/dotnet/client-010/gentool/build.xml Thu Dec 3 22:03:51 2009 @@ -1,52 +1,52 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + --------------------------------------------------------------------- Apache Qpid - AMQP Messaging Implementation Project: http://qpid.apache.org Use/Interact: mailto:commits-subscribe@qpid.apache.org