summaryrefslogtreecommitdiff
path: root/qpid
diff options
context:
space:
mode:
authorArnaud Simon <arnaudsimon@apache.org>2008-09-30 12:54:47 +0000
committerArnaud Simon <arnaudsimon@apache.org>2008-09-30 12:54:47 +0000
commitc24d35355273da642c86c6649f6728a6ee8fe783 (patch)
treea7dcbee7e7bd9c7cf1c831518878f9d6b16f9b2f /qpid
parentd83e19e1dc7cc2fae827892dc0ed9e7ad6107ee2 (diff)
downloadqpid-python-c24d35355273da642c86c6649f6728a6ee8fe783.tar.gz
qpid-1277: Added examples
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@700439 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid')
-rw-r--r--qpid/dotnet/client-010/client/Client.csproj2
-rw-r--r--qpid/dotnet/client-010/client/client/ClientSession.cs36
-rw-r--r--qpid/dotnet/client-010/client/client/IMessage.cs2
-rw-r--r--qpid/dotnet/client-010/client/client/Message.cs5
-rw-r--r--qpid/dotnet/client-010/client/transport/Session.cs10
-rw-r--r--qpid/dotnet/client-010/default.build61
-rw-r--r--qpid/dotnet/client-010/demo/Program.cs5
-rw-r--r--qpid/dotnet/client-010/examples/direct/example-direct-Listener/Listener.cs112
-rw-r--r--qpid/dotnet/client-010/examples/direct/example-direct-Listener/Properties/AssemblyInfo.cs33
-rw-r--r--qpid/dotnet/client-010/examples/direct/example-direct-Listener/default.build26
-rw-r--r--qpid/dotnet/client-010/examples/direct/example-direct-Listener/example-direct-Listener.csproj53
-rw-r--r--qpid/dotnet/client-010/examples/direct/example-direct-producer/Producer.cs87
-rw-r--r--qpid/dotnet/client-010/examples/direct/example-direct-producer/Properties/AssemblyInfo.cs33
-rw-r--r--qpid/dotnet/client-010/examples/direct/example-direct-producer/default.build26
-rw-r--r--qpid/dotnet/client-010/examples/direct/example-direct-producer/example-direct-producer.csproj53
-rw-r--r--qpid/dotnet/client-010/examples/fanout/example-fanout-Listener/Listener.cs121
-rw-r--r--qpid/dotnet/client-010/examples/fanout/example-fanout-Listener/Properties/AssemblyInfo.cs33
-rw-r--r--qpid/dotnet/client-010/examples/fanout/example-fanout-Listener/default.build26
-rw-r--r--qpid/dotnet/client-010/examples/fanout/example-fanout-Listener/example-fanout-Listener.csproj53
-rw-r--r--qpid/dotnet/client-010/examples/fanout/example-fanout-Producer/Producer.cs84
-rw-r--r--qpid/dotnet/client-010/examples/fanout/example-fanout-Producer/Properties/AssemblyInfo.cs33
-rw-r--r--qpid/dotnet/client-010/examples/fanout/example-fanout-Producer/default.build26
-rw-r--r--qpid/dotnet/client-010/examples/fanout/example-fanout-Producer/example-fanout-Producer.csproj53
-rw-r--r--qpid/dotnet/client-010/examples/pub-sub/example-pub-sub-Listener/Listener.cs138
-rw-r--r--qpid/dotnet/client-010/examples/pub-sub/example-pub-sub-Listener/Properties/AssemblyInfo.cs33
-rw-r--r--qpid/dotnet/client-010/examples/pub-sub/example-pub-sub-Listener/default.build26
-rw-r--r--qpid/dotnet/client-010/examples/pub-sub/example-pub-sub-Listener/example-pub-sub-Listener.csproj53
-rw-r--r--qpid/dotnet/client-010/examples/pub-sub/example-pub-sub-Publisher/Properties/AssemblyInfo.cs33
-rw-r--r--qpid/dotnet/client-010/examples/pub-sub/example-pub-sub-Publisher/Publisher.cs93
-rw-r--r--qpid/dotnet/client-010/examples/pub-sub/example-pub-sub-Publisher/default.build26
-rw-r--r--qpid/dotnet/client-010/examples/pub-sub/example-pub-sub-Publisher/example-pub-sub-Publisher.csproj53
-rw-r--r--qpid/dotnet/client-010/examples/request-response/example-request-response-Client/Client.cs137
-rw-r--r--qpid/dotnet/client-010/examples/request-response/example-request-response-Client/Properties/AssemblyInfo.cs33
-rw-r--r--qpid/dotnet/client-010/examples/request-response/example-request-response-Client/default.build26
-rw-r--r--qpid/dotnet/client-010/examples/request-response/example-request-response-Client/example-request-response-Client.csproj53
-rw-r--r--qpid/dotnet/client-010/examples/request-response/example-request-response-Server/Properties/AssemblyInfo.cs33
-rw-r--r--qpid/dotnet/client-010/examples/request-response/example-request-response-Server/Server.cs136
-rw-r--r--qpid/dotnet/client-010/examples/request-response/example-request-response-Server/default.build26
-rw-r--r--qpid/dotnet/client-010/examples/request-response/example-request-response-Server/example-request-response-Server.csproj53
-rw-r--r--qpid/dotnet/client-010/test/Test.csproj3
-rw-r--r--qpid/dotnet/client-010/test/interop/Message.cs6
-rw-r--r--qpid/dotnet/client-010/test/test.config2
42 files changed, 1912 insertions, 24 deletions
diff --git a/qpid/dotnet/client-010/client/Client.csproj b/qpid/dotnet/client-010/client/Client.csproj
index a54e6a4d61..35d8fae114 100644
--- a/qpid/dotnet/client-010/client/Client.csproj
+++ b/qpid/dotnet/client-010/client/Client.csproj
@@ -44,6 +44,8 @@
<Compile Include="client\ClientInterface.cs" />
<Compile Include="client\ClosedListenerInterface.cs" />
<Compile Include="client\ErrorCode.cs" />
+ <Compile Include="client\IMessage.cs" />
+ <Compile Include="client\Message.cs" />
<Compile Include="client\MessageListenerInterface.cs" />
<Compile Include="generated\Acquired.cs" />
<Compile Include="generated\ConnectionClose.cs" />
diff --git a/qpid/dotnet/client-010/client/client/ClientSession.cs b/qpid/dotnet/client-010/client/client/ClientSession.cs
index 2f107dc0b2..ccd906f854 100644
--- a/qpid/dotnet/client-010/client/client/ClientSession.cs
+++ b/qpid/dotnet/client-010/client/client/ClientSession.cs
@@ -43,17 +43,47 @@ namespace org.apache.qpid.client
}
public void messageTransfer(String destination, string routingkey, IMessage message)
- {
+ {
+ message.DeliveryProperties.setRoutingKey(routingkey);
+ messageTransfer(destination, message);
+ }
+
+ public void messageTransfer(String destination, IMessage message)
+ {
byte[] body = new byte[message.Body.Position];
message.Body.Seek(0, SeekOrigin.Begin);
message.Body.Read(body, 0, body.Length);
message.MessageProperties.setMessageId(UUID.randomUUID());
- message.DeliveryProperties.setRoutingKey(routingkey);
messageTransfer(destination,
MessageAcceptMode.NONE,
MessageAcquireMode.PRE_ACQUIRED,
message.Header,
- body);
+ body);
+ }
+
+ public void queueDeclare(String queue)
+ {
+ queueDeclare(queue, null, null);
}
+
+ public void queueDeclare(String queue, params Option[] options)
+ {
+ queueDeclare(queue, null, null, options);
+ }
+
+ public void exchangeBind(String queue, String exchange, String bindingKey)
+ {
+ exchangeBind(queue, exchange, bindingKey, null);
+ }
+
+ public void messageSubscribe(String queue)
+ {
+ messageSubscribe(queue, queue, MessageAcceptMode.EXPLICIT, MessageAcquireMode.PRE_ACQUIRED, null, 0, null);
+ // issue credits
+ messageSetFlowMode(queue, MessageFlowMode.WINDOW);
+ messageFlow(queue, MessageCreditUnit.BYTE, ClientSession.MESSAGE_FLOW_MAX_BYTES);
+ messageFlow(queue, MessageCreditUnit.MESSAGE, 10000);
+ }
+
}
} \ No newline at end of file
diff --git a/qpid/dotnet/client-010/client/client/IMessage.cs b/qpid/dotnet/client-010/client/client/IMessage.cs
index b669867ebb..10b92de7ff 100644
--- a/qpid/dotnet/client-010/client/client/IMessage.cs
+++ b/qpid/dotnet/client-010/client/client/IMessage.cs
@@ -41,6 +41,8 @@ namespace org.apache.qpid.client
MemoryStream Body { get; }
+ string Destination { get; }
+
void clearData();
}
}
diff --git a/qpid/dotnet/client-010/client/client/Message.cs b/qpid/dotnet/client-010/client/client/Message.cs
index 934ce60e68..3e18b4d7b7 100644
--- a/qpid/dotnet/client-010/client/client/Message.cs
+++ b/qpid/dotnet/client-010/client/client/Message.cs
@@ -117,5 +117,10 @@ namespace org.apache.qpid.client
{
get { return _message.Id; }
}
+
+ public string Destination
+ {
+ get{ return _message.getDestination();}
+ }
}
}
diff --git a/qpid/dotnet/client-010/client/transport/Session.cs b/qpid/dotnet/client-010/client/transport/Session.cs
index 69afb68046..5de379ab45 100644
--- a/qpid/dotnet/client-010/client/transport/Session.cs
+++ b/qpid/dotnet/client-010/client/transport/Session.cs
@@ -21,6 +21,7 @@
using System;
using System.Collections.Generic;
using System.IO;
+using System.Text;
using System.Threading;
using org.apache.qpid.transport.util;
using Frame = org.apache.qpid.transport.network.Frame;
@@ -98,6 +99,15 @@ namespace org.apache.qpid.transport
}
}
+ public string Name
+ {
+ get
+ {
+ ASCIIEncoding enc = new ASCIIEncoding();
+ return enc.GetString(_name);
+ }
+ }
+
public Session(byte[] name)
{
_name = name;
diff --git a/qpid/dotnet/client-010/default.build b/qpid/dotnet/client-010/default.build
index 74d53f1f35..99d8e239a3 100644
--- a/qpid/dotnet/client-010/default.build
+++ b/qpid/dotnet/client-010/default.build
@@ -19,9 +19,21 @@
<!-- Fileset with build files for each 'core' assembly. -->
<fileset id="src.builds">
<include name="client/default.build" />
- <include name="demo/default.build" />
+ <include name="demo/default.build" />
</fileset>
+ <!-- Fileset with build files for each 'core' assembly. -->
+ <fileset id="examples.builds">
+ <include name="examples/request-response/example-request-response-Client/default.build" />
+ <include name="examples/request-response/example-request-response-Server/default.build" />
+ <include name="examples/direct/example-direct-Listener/default.build" />
+ <include name="examples/direct/example-direct-producer/default.build" />
+ <include name="examples/fanout/example-fanout-Listener/default.build" />
+ <include name="examples/fanout/example-fanout-Producer/default.build" />
+ <include name="examples/pub-sub/example-pub-sub-Listener/default.build" />
+ <include name="examples/pub-sub/example-pub-sub-Publisher/default.build" />
+ </fileset>
+
<!-- Fileset with build files for 'integration' test assemblies. -->
<fileset id="tests.builds">
<include name="test/default.build" />
@@ -152,9 +164,14 @@
<!-- Compile test assemblies. -->
<nant target="build">
+ <buildfiles refid="examples.builds" />
+ </nant>
+
+ <!-- Compile test assemblies. -->
+ <nant target="build">
<buildfiles refid="tests.builds" />
</nant>
-
+
<!-- copy config files over to the output dir -->
<copy todir="${build.dir}" file="test/test.config"/>
<copy todir="${build.dir}" file="log.xml"/>
@@ -180,22 +197,40 @@
<property name="build.date" value="${datetime::now()}"/>
<zip zipfile="${build.dir}/Qpid.NET-${framework::get-target-framework()}-${datetime::get-year(build.date)}${datetime::get-month(build.date)}${datetime::get-day(build.date)}.zip">
- <fileset basedir="${build.dir}">
+ <fileset basedir="${build.dir}" prefix="qpid/lib">
<include name="**/*.*"/>
<exclude name="**/*.tests.*"/>
+ <exclude name="**/example*.*"/>
<exclude name="**/nunit.framework.dll"/>
- <exclude name="**/*.exe"/>
+ <exclude name="**/*.exe"/>
+ <exclude name="**/*.pdb"/>
</fileset>
-
- <fileset basedir="${base.dir}/..">
- <include name="LICENSE.txt"/>
- <include name="NOTICE.txt"/>
- <include name="RELEASE_NOTES.txt"/>
- <include name="DISCLAIMER"/>
+
+ <fileset basedir="${build.dir}" prefix="qpid/examples/direct">
+ <include name="**/example*direct*.exe"/>
</fileset>
-
-
- <fileset basedir="${base.dir}">
+
+ <fileset basedir="${build.dir}" prefix="qpid/examples/fanout">
+ <include name="**/example*fanout*.exe"/>
+ </fileset>
+
+ <fileset basedir="${build.dir}" prefix="qpid/examples/pub-sub">
+ <include name="**/example*pub-sub*.exe"/>
+ </fileset>
+
+ <fileset basedir="${build.dir}" prefix="qpid/examples/request-response">
+ <include name="**/example*request-response*.exe"/>
+ </fileset>
+
+ <fileset basedir="${base.dir}/.." prefix="qpid">
+ <include name="LICENSE.txt"/>
+ <include name="NOTICE.txt"/>
+ <include name="RELEASE_NOTES.txt"/>
+ <include name="DISCLAIMER"/>
+ </fileset>
+
+
+ <fileset basedir="${base.dir}" prefix="qpid">
<include name="README.txt"/>
</fileset>
</zip>
diff --git a/qpid/dotnet/client-010/demo/Program.cs b/qpid/dotnet/client-010/demo/Program.cs
index 429fe1bf69..4affadb9df 100644
--- a/qpid/dotnet/client-010/demo/Program.cs
+++ b/qpid/dotnet/client-010/demo/Program.cs
@@ -2,7 +2,6 @@ using System;
using System.IO;
using System.Text;
using System.Threading;
-using client.client;
using log4net.Config;
using org.apache.qpid.client;
using org.apache.qpid.transport;
@@ -64,7 +63,7 @@ namespace WindowsClient
}
}
- class MyListener : MessageListener
+ class MyListener : IMessageListener
{
private readonly Object _wl;
private ClientSession _session;
@@ -77,7 +76,7 @@ namespace WindowsClient
_count = 0;
}
- public void messageTransfer(MessageTransfer m)
+ public void messageTransfer(IMessage m)
{
BinaryReader reader = new BinaryReader(m.Body, Encoding.UTF8);
byte[] body = new byte[m.Body.Length - m.Body.Position];
diff --git a/qpid/dotnet/client-010/examples/direct/example-direct-Listener/Listener.cs b/qpid/dotnet/client-010/examples/direct/example-direct-Listener/Listener.cs
new file mode 100644
index 0000000000..dd044e8aed
--- /dev/null
+++ b/qpid/dotnet/client-010/examples/direct/example-direct-Listener/Listener.cs
@@ -0,0 +1,112 @@
+/*
+* 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.direct
+{
+ /// <summary>
+ /// This program is one of three programs designed to be used
+ /// together. These programs use the "amq.direct" exchange.
+ ///
+ /// Producer:
+ ///
+ /// Publishes to a broker, specifying a routing key.
+ ///
+ /// Listener (this program):
+ ///
+ /// Reads from a queue on the broker using a message listener.
+ ///
+ /// </summary>
+ public class Listener
+ {
+ 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 --------------------------------------------
+ // Create a queue named "message_queue", and route all messages whose
+ // routing key is "routing_key" to this newly created queue.
+
+ session.queueDeclare("message_queue");
+ session.exchangeBind("message_queue", "amq.direct", "routing_key");
+
+ lock (session)
+ {
+ // Create a listener and subscribe it to the queue named "message_queue"
+ IMessageListener listener = new MessageListener(session);
+ session.attachMessageListener(listener, "message_queue");
+ session.messageSubscribe("message_queue");
+ // Receive messages until all messages are received
+ 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 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);
+ // Add this message to the list of message to be acknowledged
+ _range.add(m.Id);
+ if( message.Equals("That's all, folks!") )
+ {
+ // Acknowledge all the received messages
+ _session.messageAccept(_range);
+ lock(_session)
+ {
+ Monitor.Pulse(_session);
+ }
+ }
+ }
+ }
+}
diff --git a/qpid/dotnet/client-010/examples/direct/example-direct-Listener/Properties/AssemblyInfo.cs b/qpid/dotnet/client-010/examples/direct/example-direct-Listener/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000000..07db227255
--- /dev/null
+++ b/qpid/dotnet/client-010/examples/direct/example-direct-Listener/Properties/AssemblyInfo.cs
@@ -0,0 +1,33 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("example-direct-Listener")]
+[assembly: AssemblyDescription("Built from svn revision number: ")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Apache Software Foundation")]
+[assembly: AssemblyProduct("example-direct-Listener")]
+[assembly: AssemblyCopyright("Apache Software Foundation")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("6a24bfe4-4714-4d2a-acf4-96cf9a678a06")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+[assembly: AssemblyVersion("0.10.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/qpid/dotnet/client-010/examples/direct/example-direct-Listener/default.build b/qpid/dotnet/client-010/examples/direct/example-direct-Listener/default.build
new file mode 100644
index 0000000000..f684a60990
--- /dev/null
+++ b/qpid/dotnet/client-010/examples/direct/example-direct-Listener/default.build
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<project name="example-direct-Listener" default="build">
+ <!--
+ Properties that come from master build file
+ - build.dir: root directory for build
+ - build.debug: true if building debug release
+ - build.defines: variables to define during build
+ -->
+
+ <target name="build">
+ <csc target="exe"
+ define="${build.defines}"
+ debug="${build.debug}"
+ output="${build.dir}/${project::get-name()}.exe">
+
+ <sources>
+ <include name="**/*.cs" />
+ </sources>
+ <references>
+ <include name="${build.dir}/log4net.dll" />
+ <include name="${build.dir}/qpid.client.dll" />
+ </references>
+ </csc>
+ </target>
+</project>
+
diff --git a/qpid/dotnet/client-010/examples/direct/example-direct-Listener/example-direct-Listener.csproj b/qpid/dotnet/client-010/examples/direct/example-direct-Listener/example-direct-Listener.csproj
new file mode 100644
index 0000000000..17675cb479
--- /dev/null
+++ b/qpid/dotnet/client-010/examples/direct/example-direct-Listener/example-direct-Listener.csproj
@@ -0,0 +1,53 @@
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.50727</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{AE65B1B9-8779-4CB1-91AF-E7F6C7A736D7}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>example_direct_Listener</RootNamespace>
+ <AssemblyName>example-direct-Listener</AssemblyName>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Listener.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\..\..\client\Client.csproj">
+ <Project>{B911FFD7-754F-4735-A188-218D5065BE79}</Project>
+ <Name>Client</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project> \ No newline at end of file
diff --git a/qpid/dotnet/client-010/examples/direct/example-direct-producer/Producer.cs b/qpid/dotnet/client-010/examples/direct/example-direct-producer/Producer.cs
new file mode 100644
index 0000000000..c9f1a475a4
--- /dev/null
+++ b/qpid/dotnet/client-010/examples/direct/example-direct-producer/Producer.cs
@@ -0,0 +1,87 @@
+/*
+* 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.direct
+{
+ /// <summary>
+ /// This program is one of three programs designed to be used
+ /// together. These programs use the "amq.direct" exchange.
+ ///
+ /// Producer (this program):
+ ///
+ /// Publishes to a broker, specifying a routing key.
+ ///
+ /// Listener:
+ ///
+ /// Reads from a queue on the broker using a message listener.
+ ///
+ /// </summary>
+ class Producer
+ {
+ 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 --------------------------------------------
+
+ IMessage message = new Message();
+
+ // The routing key is a message property. We will use the same
+ // routing key for each message, so we'll set this property
+ // just once. (In most simple cases, there is no need to set
+ // other message properties.)
+
+ message.DeliveryProperties.setRoutingKey("routing_key");
+
+ // 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.direct", message);
+ }
+
+ // And send a syncrhonous final message to indicate termination.
+ message.clearData();
+ message.appendData(Encoding.UTF8.GetBytes("That's all, folks!"));
+ session.messageTransfer("amq.direct", "routing_key", message);
+ session.sync();
+
+ //-----------------------------------------------------------------------------
+
+ connection.close();
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("Error: \n" + e.StackTrace);
+ }
+ }
+ }
+}
diff --git a/qpid/dotnet/client-010/examples/direct/example-direct-producer/Properties/AssemblyInfo.cs b/qpid/dotnet/client-010/examples/direct/example-direct-producer/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000000..e72701e44b
--- /dev/null
+++ b/qpid/dotnet/client-010/examples/direct/example-direct-producer/Properties/AssemblyInfo.cs
@@ -0,0 +1,33 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("example-direct-producer")]
+[assembly: AssemblyDescription("Built from svn revision number: ")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Apache Software Foundation")]
+[assembly: AssemblyProduct("example-direct-producer")]
+[assembly: AssemblyCopyright("Apache Software Foundation")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("006144c2-5e45-4543-8e16-c09cd4309ed7")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+[assembly: AssemblyVersion("0.10.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/qpid/dotnet/client-010/examples/direct/example-direct-producer/default.build b/qpid/dotnet/client-010/examples/direct/example-direct-producer/default.build
new file mode 100644
index 0000000000..58ac97b0d0
--- /dev/null
+++ b/qpid/dotnet/client-010/examples/direct/example-direct-producer/default.build
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<project name="example-direct-Producer" default="build">
+ <!--
+ Properties that come from master build file
+ - build.dir: root directory for build
+ - build.debug: true if building debug release
+ - build.defines: variables to define during build
+ -->
+
+ <target name="build">
+ <csc target="exe"
+ define="${build.defines}"
+ debug="${build.debug}"
+ output="${build.dir}/${project::get-name()}.exe">
+
+ <sources>
+ <include name="**/*.cs" />
+ </sources>
+ <references>
+ <include name="${build.dir}/log4net.dll" />
+ <include name="${build.dir}/qpid.client.dll" />
+ </references>
+ </csc>
+ </target>
+</project>
+
diff --git a/qpid/dotnet/client-010/examples/direct/example-direct-producer/example-direct-producer.csproj b/qpid/dotnet/client-010/examples/direct/example-direct-producer/example-direct-producer.csproj
new file mode 100644
index 0000000000..deafad1728
--- /dev/null
+++ b/qpid/dotnet/client-010/examples/direct/example-direct-producer/example-direct-producer.csproj
@@ -0,0 +1,53 @@
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.50727</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{96FCB250-8142-40EE-9BDD-CA839EE21021}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>example_direct_producer</RootNamespace>
+ <AssemblyName>example-direct-producer</AssemblyName>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Producer.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\..\..\client\Client.csproj">
+ <Project>{B911FFD7-754F-4735-A188-218D5065BE79}</Project>
+ <Name>Client</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project> \ No newline at end of file
diff --git a/qpid/dotnet/client-010/examples/fanout/example-fanout-Listener/Listener.cs b/qpid/dotnet/client-010/examples/fanout/example-fanout-Listener/Listener.cs
new file mode 100644
index 0000000000..4d3da690a9
--- /dev/null
+++ b/qpid/dotnet/client-010/examples/fanout/example-fanout-Listener/Listener.cs
@@ -0,0 +1,121 @@
+/*
+* 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.fanout
+{
+ /// <summary>
+ /// This program is one of two programs designed to be used
+ /// together.
+ ///
+ /// Producer (this program):
+ ///
+ /// Publishes to a broker, specifying a routing key.
+ ///
+ /// Listener:
+ ///
+ /// Reads from a queue on the broker using a message listener.
+ ///
+ /// </summary>
+ public class Listener
+ {
+ 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 --------------------------------------------
+ // Each client creates its own private queue, using the
+ // session id to guarantee a unique name. It then routes
+ // all messages from the fanout exchange to its own queue
+ // by binding to the queue.
+ //
+ // The binding specifies a binding key, but for a fanout
+ // exchange, the binding key is optional and is not used
+ // for routing decisions. It can be useful for tracking
+ // messages and routing in logs.
+
+ string myQueue = session.Name;
+ session.queueDeclare(myQueue, Option.EXCLUSIVE, Option.AUTO_DELETE);
+ session.exchangeBind(myQueue, "amq.fanout", "my-key");
+
+ lock (session)
+ {
+ Console.WriteLine("Listening");
+ // Create a listener and subscribe it to my queue.
+ IMessageListener listener = new MessageListener(session);
+ session.attachMessageListener(listener, myQueue);
+ session.messageSubscribe(myQueue);
+ // Receive messages until all messages are received
+ 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 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);
+ // Add this message to the list of message to be acknowledged
+ _range.add(m.Id);
+ if (message.Equals("That's all, folks!"))
+ {
+ // Acknowledge all the received messages
+ _session.messageAccept(_range);
+ lock (_session)
+ {
+ Monitor.Pulse(_session);
+ }
+ }
+ }
+ }
+}
diff --git a/qpid/dotnet/client-010/examples/fanout/example-fanout-Listener/Properties/AssemblyInfo.cs b/qpid/dotnet/client-010/examples/fanout/example-fanout-Listener/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000000..9e8adf557f
--- /dev/null
+++ b/qpid/dotnet/client-010/examples/fanout/example-fanout-Listener/Properties/AssemblyInfo.cs
@@ -0,0 +1,33 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("example-fanout-Listener")]
+[assembly: AssemblyDescription("Built from svn revision number: ")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Apache Software Foundation")]
+[assembly: AssemblyProduct("example-fanout-Listener")]
+[assembly: AssemblyCopyright("Apache Software Foundation")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("68686ef9-aa0a-4334-9c52-d7e6fc507bec")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+[assembly: AssemblyVersion("0.10.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/qpid/dotnet/client-010/examples/fanout/example-fanout-Listener/default.build b/qpid/dotnet/client-010/examples/fanout/example-fanout-Listener/default.build
new file mode 100644
index 0000000000..cbd5113ae1
--- /dev/null
+++ b/qpid/dotnet/client-010/examples/fanout/example-fanout-Listener/default.build
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<project name="example-fanout-Listener" default="build">
+ <!--
+ Properties that come from master build file
+ - build.dir: root directory for build
+ - build.debug: true if building debug release
+ - build.defines: variables to define during build
+ -->
+
+ <target name="build">
+ <csc target="exe"
+ define="${build.defines}"
+ debug="${build.debug}"
+ output="${build.dir}/${project::get-name()}.exe">
+
+ <sources>
+ <include name="**/*.cs" />
+ </sources>
+ <references>
+ <include name="${build.dir}/log4net.dll" />
+ <include name="${build.dir}/qpid.client.dll" />
+ </references>
+ </csc>
+ </target>
+</project>
+
diff --git a/qpid/dotnet/client-010/examples/fanout/example-fanout-Listener/example-fanout-Listener.csproj b/qpid/dotnet/client-010/examples/fanout/example-fanout-Listener/example-fanout-Listener.csproj
new file mode 100644
index 0000000000..27b785e081
--- /dev/null
+++ b/qpid/dotnet/client-010/examples/fanout/example-fanout-Listener/example-fanout-Listener.csproj
@@ -0,0 +1,53 @@
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.50727</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{18A0792B-DC3A-4EC5-93D6-DB8A111D8F15}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>example_fanout_Listener</RootNamespace>
+ <AssemblyName>example-fanout-Listener</AssemblyName>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Listener.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\..\..\client\Client.csproj">
+ <Project>{B911FFD7-754F-4735-A188-218D5065BE79}</Project>
+ <Name>Client</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project> \ No newline at end of file
diff --git a/qpid/dotnet/client-010/examples/fanout/example-fanout-Producer/Producer.cs b/qpid/dotnet/client-010/examples/fanout/example-fanout-Producer/Producer.cs
new file mode 100644
index 0000000000..f2818a4099
--- /dev/null
+++ b/qpid/dotnet/client-010/examples/fanout/example-fanout-Producer/Producer.cs
@@ -0,0 +1,84 @@
+/*
+* 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.fanout
+{
+ /// <summary>
+ /// This program is one of two programs designed to be used
+ /// together. These programs do not specify the exchange type - the
+ /// default exchange type is the direct exchange.
+ ///
+ ///
+ /// Producer (this program):
+ ///
+ /// Publishes to a broker, specifying a routing key.
+ ///
+ /// Listener:
+ ///
+ /// Reads from a queue on the broker using a message listener.
+ ///
+ /// </summary>
+ class Producer
+ {
+ 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 --------------------------------------------
+
+ // Unlike topic exchanges and direct exchanges, a fanout
+ // exchange need not set a 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.fanout", message);
+ }
+
+ // And send a syncrhonous final message to indicate termination.
+ message.clearData();
+ message.appendData(Encoding.UTF8.GetBytes("That's all, folks!"));
+ session.messageTransfer("amq.fanout", message);
+ session.sync();
+
+ //-----------------------------------------------------------------------------
+
+ connection.close();
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("Error: \n" + e.StackTrace);
+ }
+ }
+ }
+}
diff --git a/qpid/dotnet/client-010/examples/fanout/example-fanout-Producer/Properties/AssemblyInfo.cs b/qpid/dotnet/client-010/examples/fanout/example-fanout-Producer/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000000..d35f3522d2
--- /dev/null
+++ b/qpid/dotnet/client-010/examples/fanout/example-fanout-Producer/Properties/AssemblyInfo.cs
@@ -0,0 +1,33 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("example-fanout-Producer")]
+[assembly: AssemblyDescription("Built from svn revision number: ")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Apache Software Foundation")]
+[assembly: AssemblyProduct("example-fanout-Producer")]
+[assembly: AssemblyCopyright("Apache Software Foundation")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("01c0ba10-2f23-409b-9adc-bc514a13131a")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+[assembly: AssemblyVersion("0.10.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/qpid/dotnet/client-010/examples/fanout/example-fanout-Producer/default.build b/qpid/dotnet/client-010/examples/fanout/example-fanout-Producer/default.build
new file mode 100644
index 0000000000..0eec886470
--- /dev/null
+++ b/qpid/dotnet/client-010/examples/fanout/example-fanout-Producer/default.build
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<project name="example-fanout-Producer" default="build">
+ <!--
+ Properties that come from master build file
+ - build.dir: root directory for build
+ - build.debug: true if building debug release
+ - build.defines: variables to define during build
+ -->
+
+ <target name="build">
+ <csc target="exe"
+ define="${build.defines}"
+ debug="${build.debug}"
+ output="${build.dir}/${project::get-name()}.exe">
+
+ <sources>
+ <include name="**/*.cs" />
+ </sources>
+ <references>
+ <include name="${build.dir}/log4net.dll" />
+ <include name="${build.dir}/qpid.client.dll" />
+ </references>
+ </csc>
+ </target>
+</project>
+
diff --git a/qpid/dotnet/client-010/examples/fanout/example-fanout-Producer/example-fanout-Producer.csproj b/qpid/dotnet/client-010/examples/fanout/example-fanout-Producer/example-fanout-Producer.csproj
new file mode 100644
index 0000000000..ebafee7f1a
--- /dev/null
+++ b/qpid/dotnet/client-010/examples/fanout/example-fanout-Producer/example-fanout-Producer.csproj
@@ -0,0 +1,53 @@
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.50727</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{4513BF94-D54A-42FE-8506-FE2CD57B2C51}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>example_fanout_Producer</RootNamespace>
+ <AssemblyName>example-fanout-Producer</AssemblyName>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Producer.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\..\..\client\Client.csproj">
+ <Project>{B911FFD7-754F-4735-A188-218D5065BE79}</Project>
+ <Name>Client</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project> \ No newline at end of file
diff --git a/qpid/dotnet/client-010/examples/pub-sub/example-pub-sub-Listener/Listener.cs b/qpid/dotnet/client-010/examples/pub-sub/example-pub-sub-Listener/Listener.cs
new file mode 100644
index 0000000000..0f09307cd4
--- /dev/null
+++ b/qpid/dotnet/client-010/examples/pub-sub/example-pub-sub-Listener/Listener.cs
@@ -0,0 +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
+{
+ /// <summary>
+ /// 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.
+ ///
+ /// </summary>
+ 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);
+ }
+ }
+ }
+ }
+}
diff --git a/qpid/dotnet/client-010/examples/pub-sub/example-pub-sub-Listener/Properties/AssemblyInfo.cs b/qpid/dotnet/client-010/examples/pub-sub/example-pub-sub-Listener/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000000..f6ff3a3c82
--- /dev/null
+++ b/qpid/dotnet/client-010/examples/pub-sub/example-pub-sub-Listener/Properties/AssemblyInfo.cs
@@ -0,0 +1,33 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("example-pub-sub-Listener")]
+[assembly: AssemblyDescription("Built from svn revision number: ")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Apache Software Foundation")]
+[assembly: AssemblyProduct("example-pub-sub-Listener")]
+[assembly: AssemblyCopyright("Apache Software Foundation")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("74ab02ae-95d1-4bad-a7cf-9964005b9b05")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+[assembly: AssemblyVersion("0.10.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/qpid/dotnet/client-010/examples/pub-sub/example-pub-sub-Listener/default.build b/qpid/dotnet/client-010/examples/pub-sub/example-pub-sub-Listener/default.build
new file mode 100644
index 0000000000..564e099f55
--- /dev/null
+++ b/qpid/dotnet/client-010/examples/pub-sub/example-pub-sub-Listener/default.build
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<project name="example-pub-sub-Listener" default="build">
+ <!--
+ Properties that come from master build file
+ - build.dir: root directory for build
+ - build.debug: true if building debug release
+ - build.defines: variables to define during build
+ -->
+
+ <target name="build">
+ <csc target="exe"
+ define="${build.defines}"
+ debug="${build.debug}"
+ output="${build.dir}/${project::get-name()}.exe">
+
+ <sources>
+ <include name="**/*.cs" />
+ </sources>
+ <references>
+ <include name="${build.dir}/log4net.dll" />
+ <include name="${build.dir}/qpid.client.dll" />
+ </references>
+ </csc>
+ </target>
+</project>
+
diff --git a/qpid/dotnet/client-010/examples/pub-sub/example-pub-sub-Listener/example-pub-sub-Listener.csproj b/qpid/dotnet/client-010/examples/pub-sub/example-pub-sub-Listener/example-pub-sub-Listener.csproj
new file mode 100644
index 0000000000..df58bfa6c4
--- /dev/null
+++ b/qpid/dotnet/client-010/examples/pub-sub/example-pub-sub-Listener/example-pub-sub-Listener.csproj
@@ -0,0 +1,53 @@
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.50727</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{2BCDC2CC-5BDA-4CC7-944D-2899AD8A53C7}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>example_pub_sub_Listener</RootNamespace>
+ <AssemblyName>example-pub-sub-Listener</AssemblyName>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Listener.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\..\..\client\Client.csproj">
+ <Project>{B911FFD7-754F-4735-A188-218D5065BE79}</Project>
+ <Name>Client</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project> \ No newline at end of file
diff --git a/qpid/dotnet/client-010/examples/pub-sub/example-pub-sub-Publisher/Properties/AssemblyInfo.cs b/qpid/dotnet/client-010/examples/pub-sub/example-pub-sub-Publisher/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000000..209db5d17e
--- /dev/null
+++ b/qpid/dotnet/client-010/examples/pub-sub/example-pub-sub-Publisher/Properties/AssemblyInfo.cs
@@ -0,0 +1,33 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("example-pub-sub-Publisher")]
+[assembly: AssemblyDescription("Built from svn revision number: ")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Apache Software Foundation")]
+[assembly: AssemblyProduct("example-pub-sub-Publisher")]
+[assembly: AssemblyCopyright("Apache Software Foundation")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("f6d282a0-9dc5-46cf-a4cd-44ae402d667f")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+[assembly: AssemblyVersion("0.10.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/qpid/dotnet/client-010/examples/pub-sub/example-pub-sub-Publisher/Publisher.cs b/qpid/dotnet/client-010/examples/pub-sub/example-pub-sub-Publisher/Publisher.cs
new file mode 100644
index 0000000000..6c78eb5193
--- /dev/null
+++ b/qpid/dotnet/client-010/examples/pub-sub/example-pub-sub-Publisher/Publisher.cs
@@ -0,0 +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
+{
+ /// <summary>
+ /// 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.
+ ///
+ /// </summary>
+ 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();
+ }
+ }
+}
diff --git a/qpid/dotnet/client-010/examples/pub-sub/example-pub-sub-Publisher/default.build b/qpid/dotnet/client-010/examples/pub-sub/example-pub-sub-Publisher/default.build
new file mode 100644
index 0000000000..c85b2672a4
--- /dev/null
+++ b/qpid/dotnet/client-010/examples/pub-sub/example-pub-sub-Publisher/default.build
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<project name="example-pub-sub-Publisher" default="build">
+ <!--
+ Properties that come from master build file
+ - build.dir: root directory for build
+ - build.debug: true if building debug release
+ - build.defines: variables to define during build
+ -->
+
+ <target name="build">
+ <csc target="exe"
+ define="${build.defines}"
+ debug="${build.debug}"
+ output="${build.dir}/${project::get-name()}.exe">
+
+ <sources>
+ <include name="**/*.cs" />
+ </sources>
+ <references>
+ <include name="${build.dir}/log4net.dll" />
+ <include name="${build.dir}/qpid.client.dll" />
+ </references>
+ </csc>
+ </target>
+</project>
+
diff --git a/qpid/dotnet/client-010/examples/pub-sub/example-pub-sub-Publisher/example-pub-sub-Publisher.csproj b/qpid/dotnet/client-010/examples/pub-sub/example-pub-sub-Publisher/example-pub-sub-Publisher.csproj
new file mode 100644
index 0000000000..ecdf2a5d44
--- /dev/null
+++ b/qpid/dotnet/client-010/examples/pub-sub/example-pub-sub-Publisher/example-pub-sub-Publisher.csproj
@@ -0,0 +1,53 @@
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.50727</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{F8857634-A134-44E7-A953-F2B22688C599}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>example_pub_sub_Publisher</RootNamespace>
+ <AssemblyName>example-pub-sub-Publisher</AssemblyName>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Publisher.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\..\..\client\Client.csproj">
+ <Project>{B911FFD7-754F-4735-A188-218D5065BE79}</Project>
+ <Name>Client</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project> \ No newline at end of file
diff --git a/qpid/dotnet/client-010/examples/request-response/example-request-response-Client/Client.cs b/qpid/dotnet/client-010/examples/request-response/example-request-response-Client/Client.cs
new file mode 100644
index 0000000000..1d361199f1
--- /dev/null
+++ b/qpid/dotnet/client-010/examples/request-response/example-request-response-Client/Client.cs
@@ -0,0 +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
+{
+ /// <summary>
+ /// 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.
+ ///
+ /// </summary>
+ 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);
+ }
+ }
+ }
+ }
+}
diff --git a/qpid/dotnet/client-010/examples/request-response/example-request-response-Client/Properties/AssemblyInfo.cs b/qpid/dotnet/client-010/examples/request-response/example-request-response-Client/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000000..d1ac2473de
--- /dev/null
+++ b/qpid/dotnet/client-010/examples/request-response/example-request-response-Client/Properties/AssemblyInfo.cs
@@ -0,0 +1,33 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("example-request-response-Client")]
+[assembly: AssemblyDescription("Built from svn revision number: ")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Apache Software Foundation")]
+[assembly: AssemblyProduct("example-request-response-Client")]
+[assembly: AssemblyCopyright("Apache Software Foundation")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("08bf6aed-bf79-4d16-9a28-6363d5322cdd")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+[assembly: AssemblyVersion("0.10.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/qpid/dotnet/client-010/examples/request-response/example-request-response-Client/default.build b/qpid/dotnet/client-010/examples/request-response/example-request-response-Client/default.build
new file mode 100644
index 0000000000..760419b325
--- /dev/null
+++ b/qpid/dotnet/client-010/examples/request-response/example-request-response-Client/default.build
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<project name="example-request-response-Client" default="build">
+ <!--
+ Properties that come from master build file
+ - build.dir: root directory for build
+ - build.debug: true if building debug release
+ - build.defines: variables to define during build
+ -->
+
+ <target name="build">
+ <csc target="exe"
+ define="${build.defines}"
+ debug="${build.debug}"
+ output="${build.dir}/${project::get-name()}.exe">
+
+ <sources>
+ <include name="**/*.cs" />
+ </sources>
+ <references>
+ <include name="${build.dir}/log4net.dll" />
+ <include name="${build.dir}/qpid.client.dll" />
+ </references>
+ </csc>
+ </target>
+</project>
+
diff --git a/qpid/dotnet/client-010/examples/request-response/example-request-response-Client/example-request-response-Client.csproj b/qpid/dotnet/client-010/examples/request-response/example-request-response-Client/example-request-response-Client.csproj
new file mode 100644
index 0000000000..2d32dd6b66
--- /dev/null
+++ b/qpid/dotnet/client-010/examples/request-response/example-request-response-Client/example-request-response-Client.csproj
@@ -0,0 +1,53 @@
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.50727</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{1BC63815-4029-4039-9207-35E7E06ECC99}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>example_request_response_Client</RootNamespace>
+ <AssemblyName>example-request-response-Client</AssemblyName>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Client.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\..\..\client\Client.csproj">
+ <Project>{B911FFD7-754F-4735-A188-218D5065BE79}</Project>
+ <Name>Client</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project> \ No newline at end of file
diff --git a/qpid/dotnet/client-010/examples/request-response/example-request-response-Server/Properties/AssemblyInfo.cs b/qpid/dotnet/client-010/examples/request-response/example-request-response-Server/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000000..ae96a64eb0
--- /dev/null
+++ b/qpid/dotnet/client-010/examples/request-response/example-request-response-Server/Properties/AssemblyInfo.cs
@@ -0,0 +1,33 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("example-request-response-Server")]
+[assembly: AssemblyDescription("Built from svn revision number: ")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Apache Software Foundation")]
+[assembly: AssemblyProduct("example-request-response-Server")]
+[assembly: AssemblyCopyright("Apache Software Foundation")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("ef3456e2-7c19-47aa-8dd6-aeaa88c5c4ad")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+[assembly: AssemblyVersion("0.10.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/qpid/dotnet/client-010/examples/request-response/example-request-response-Server/Server.cs b/qpid/dotnet/client-010/examples/request-response/example-request-response-Server/Server.cs
new file mode 100644
index 0000000000..2ce493626f
--- /dev/null
+++ b/qpid/dotnet/client-010/examples/request-response/example-request-response-Server/Server.cs
@@ -0,0 +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
+{
+ /// <summary>
+ /// 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.
+ ///
+ /// </summary>
+ 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);
+ }
+ }
+ }
+ }
+}
diff --git a/qpid/dotnet/client-010/examples/request-response/example-request-response-Server/default.build b/qpid/dotnet/client-010/examples/request-response/example-request-response-Server/default.build
new file mode 100644
index 0000000000..d17410a7a9
--- /dev/null
+++ b/qpid/dotnet/client-010/examples/request-response/example-request-response-Server/default.build
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<project name="example-request-response-Server" default="build">
+ <!--
+ Properties that come from master build file
+ - build.dir: root directory for build
+ - build.debug: true if building debug release
+ - build.defines: variables to define during build
+ -->
+
+ <target name="build">
+ <csc target="exe"
+ define="${build.defines}"
+ debug="${build.debug}"
+ output="${build.dir}/${project::get-name()}.exe">
+
+ <sources>
+ <include name="**/*.cs" />
+ </sources>
+ <references>
+ <include name="${build.dir}/log4net.dll" />
+ <include name="${build.dir}/qpid.client.dll" />
+ </references>
+ </csc>
+ </target>
+</project>
+
diff --git a/qpid/dotnet/client-010/examples/request-response/example-request-response-Server/example-request-response-Server.csproj b/qpid/dotnet/client-010/examples/request-response/example-request-response-Server/example-request-response-Server.csproj
new file mode 100644
index 0000000000..080b2458b8
--- /dev/null
+++ b/qpid/dotnet/client-010/examples/request-response/example-request-response-Server/example-request-response-Server.csproj
@@ -0,0 +1,53 @@
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.50727</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{922FBA9C-E483-4AEF-ABE8-AC87421E829B}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>example_request_response_Server</RootNamespace>
+ <AssemblyName>example-request-response-Server</AssemblyName>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Server.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\..\..\client\Client.csproj">
+ <Project>{B911FFD7-754F-4735-A188-218D5065BE79}</Project>
+ <Name>Client</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project> \ No newline at end of file
diff --git a/qpid/dotnet/client-010/test/Test.csproj b/qpid/dotnet/client-010/test/Test.csproj
index a5d6e2c45f..841e2385a0 100644
--- a/qpid/dotnet/client-010/test/Test.csproj
+++ b/qpid/dotnet/client-010/test/Test.csproj
@@ -41,7 +41,10 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
+ <Compile Include="interop\Admin.cs" />
+ <Compile Include="interop\Message.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="interop\TestCase.cs" />
<Compile Include="transport\util\UUIDTest.cs" />
</ItemGroup>
<ItemGroup>
diff --git a/qpid/dotnet/client-010/test/interop/Message.cs b/qpid/dotnet/client-010/test/interop/Message.cs
index 79c22e0acf..3267af9c0c 100644
--- a/qpid/dotnet/client-010/test/interop/Message.cs
+++ b/qpid/dotnet/client-010/test/interop/Message.cs
@@ -19,10 +19,8 @@
*
*/
using System;
-using System.IO;
using System.Text;
using System.Threading;
-using client.client;
using NUnit.Framework;
using org.apache.qpid.client;
using org.apache.qpid.transport;
@@ -139,7 +137,7 @@ namespace test.interop
- private class MyListener : MessageListener
+ private class MyListener : IMessageListener
{
private static readonly Logger _log = Logger.get(typeof (MyListener));
private readonly Object _wl;
@@ -152,7 +150,7 @@ namespace test.interop
_count = count;
}
- public void messageTransfer(MessageTransfer m)
+ public void messageTransfer(IMessage m)
{
byte[] body = new byte[m.Body.Length - m.Body.Position];
_log.debug("Got a message of size: " + body.Length + " count = " + _count);
diff --git a/qpid/dotnet/client-010/test/test.config b/qpid/dotnet/client-010/test/test.config
index dc284f25f1..0499eddfbc 100644
--- a/qpid/dotnet/client-010/test/test.config
+++ b/qpid/dotnet/client-010/test/test.config
@@ -2,7 +2,7 @@
<configuration>
<appSettings>
<add key="UserMame" value="guest"/>
- <add key="Password" value="password"/>
+ <add key="Password" value="guest"/>
<add key="Host" value="192.168.1.14"/>
<add key="Port" value="5673"/>
<add key="VirtualHost" value="test"/>