summaryrefslogtreecommitdiff
path: root/qpid/cpp/bindings/qpid/dotnet/examples/csharp.example.drain
diff options
context:
space:
mode:
Diffstat (limited to 'qpid/cpp/bindings/qpid/dotnet/examples/csharp.example.drain')
-rw-r--r--qpid/cpp/bindings/qpid/dotnet/examples/csharp.example.drain/Options.cs175
-rw-r--r--qpid/cpp/bindings/qpid/dotnet/examples/csharp.example.drain/Properties/AssemblyInfo.cs57
-rw-r--r--qpid/cpp/bindings/qpid/dotnet/examples/csharp.example.drain/csharp.example.drain.cs88
-rw-r--r--qpid/cpp/bindings/qpid/dotnet/examples/csharp.example.drain/csharp.example.drain.csproj103
4 files changed, 423 insertions, 0 deletions
diff --git a/qpid/cpp/bindings/qpid/dotnet/examples/csharp.example.drain/Options.cs b/qpid/cpp/bindings/qpid/dotnet/examples/csharp.example.drain/Options.cs
new file mode 100644
index 0000000000..6059f76442
--- /dev/null
+++ b/qpid/cpp/bindings/qpid/dotnet/examples/csharp.example.drain/Options.cs
@@ -0,0 +1,175 @@
+/*
+* 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.
+*/
+
+namespace Org.Apache.Qpid.Messaging.Examples
+{
+ using System;
+
+ public class Options
+ {
+ private string url;
+ private string address;
+ private UInt64 timeout;
+ private int count;
+ private string id;
+ private string replyTo;
+ //private string[] properties;
+ //private string[] entries;
+ private string content;
+ private string connectionOptions;
+ private bool forever;
+
+ public Options(string[] args)
+ {
+ this.url = "amqp:tcp:127.0.0.1:5672";
+ this.address = "";
+ this.timeout = 0;
+ this.count = 1;
+ this.id = "";
+ this.replyTo = "";
+ this.content = "";
+ this.connectionOptions = "";
+ this.forever = false;
+ Parse(args);
+ }
+
+ private void Parse(string[] args)
+ {
+ int argCount = args.Length;
+ int current = 0;
+
+ while ((current + 1) < argCount)
+ {
+ string arg = args[current];
+ if (arg == "--broker")
+ {
+ this.url = args[++current];
+ }
+ else if (arg == "--address")
+ {
+ this.address = args[++current];
+ }
+ else if (arg == "--timeout")
+ {
+ arg = args[++current];
+ UInt64 i = UInt64.Parse(arg);
+ if (i >= 0)
+ {
+ this.timeout = i;
+ }
+ }
+ else if (arg == "--count")
+ {
+ arg = args[++current];
+ int i = int.Parse(arg);
+ if (i >= 0)
+ {
+ this.count = i;
+ }
+ }
+ else if (arg == "--id")
+ {
+ this.id = args[++current];
+ }
+ else if (arg == "--reply-to")
+ {
+ this.replyTo = args[++current];
+ }
+ else if (arg == "--properties")
+ {
+ throw new ArgumentException("TODO: properties not implemented");
+ }
+ else if (arg == "--entries")
+ {
+ throw new ArgumentException("TODO: entries not implemented");
+ }
+ else if (arg == "--content")
+ {
+ this.content = args[++current];
+ }
+ else if (arg == "--connection-options")
+ {
+ this.connectionOptions = args[++current];
+ }
+ else if (arg == "--forever")
+ {
+ this.forever = true;
+ }
+ else
+ {
+ throw new ArgumentException(String.Format("unknown argument \"{0}\"", arg));
+ }
+
+ current++;
+ }
+
+ if (current == argCount)
+ {
+ throw new ArgumentException("missing argument: address");
+ }
+
+ address = args[current];
+ }
+
+ public string Url
+ {
+ get { return this.url; }
+ }
+
+ public string Address
+ {
+ get { return this.address; }
+ }
+
+ public UInt64 Timeout
+ {
+ get { return this.timeout; }
+ }
+
+ public int Count
+ {
+ get { return this.count; }
+ }
+
+ public string Id
+ {
+ get { return this.id; }
+ }
+
+ public string ReplyTo
+ {
+ get { return this.replyTo; }
+ }
+
+ public string Content
+ {
+ get { return content; }
+ }
+
+ public string ConnectionOptions
+ {
+ get { return this.connectionOptions; }
+ }
+
+ public bool Forever
+ {
+ get { return this.forever; }
+ }
+ }
+}
diff --git a/qpid/cpp/bindings/qpid/dotnet/examples/csharp.example.drain/Properties/AssemblyInfo.cs b/qpid/cpp/bindings/qpid/dotnet/examples/csharp.example.drain/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000000..d949dde644
--- /dev/null
+++ b/qpid/cpp/bindings/qpid/dotnet/examples/csharp.example.drain/Properties/AssemblyInfo.cs
@@ -0,0 +1,57 @@
+/*
+ *
+ * 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.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("csharp.example.drain")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("csharp.example.drain")]
+[assembly: AssemblyCopyright("Copyright ? 2010")]
+[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("c60b17ab-a82c-4edf-ba95-1e88bd4c3e75")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/qpid/cpp/bindings/qpid/dotnet/examples/csharp.example.drain/csharp.example.drain.cs b/qpid/cpp/bindings/qpid/dotnet/examples/csharp.example.drain/csharp.example.drain.cs
new file mode 100644
index 0000000000..da8218bbf7
--- /dev/null
+++ b/qpid/cpp/bindings/qpid/dotnet/examples/csharp.example.drain/csharp.example.drain.cs
@@ -0,0 +1,88 @@
+/*
+ *
+ * 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.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using Org.Apache.Qpid.Messaging;
+
+namespace Org.Apache.Qpid.Messaging.Examples {
+ class Drain {
+ //
+ // Sample invocation: csharp.example.drain.exe --broker localhost:5672 --timeout 30 my-queue
+ //
+ static int Main(string[] args) {
+ Options options = new Options(args);
+
+ Connection connection = null;
+ try
+ {
+ connection = new Connection(options.Url, options.ConnectionOptions);
+ connection.Open();
+ Session session = connection.CreateSession();
+ Receiver receiver = session.CreateReceiver(options.Address);
+ Duration timeout = options.Forever ?
+ DurationConstants.FORVER :
+ DurationConstants.SECOND * options.Timeout;
+ Message message = new Message();
+
+ while (receiver.Fetch(ref message, timeout))
+ {
+ Dictionary<string, object> properties = new Dictionary<string, object>();
+ properties = message.Properties;
+ Console.Write("Message(properties={0}, content='",
+ message.MapAsString(properties));
+
+ if ("amqp/map" == message.ContentType)
+ {
+ Dictionary<string, object> content = new Dictionary<string, object>();
+ message.GetContent(content);
+ Console.Write(message.MapAsString(content));
+ }
+ else if ("amqp/list" == message.ContentType)
+ {
+ Collection<object> content = new Collection<object>();
+ message.GetContent(content);
+ Console.Write(message.ListAsString(content));
+ }
+ else
+ {
+ Console.Write(message.GetContent());
+ }
+ Console.WriteLine("')");
+ session.Acknowledge();
+ }
+ receiver.Close();
+ session.Close();
+ connection.Close();
+ return 0;
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("Exception {0}.", e);
+ if (null != connection)
+ connection.Close();
+ }
+ return 1;
+ }
+ }
+}
diff --git a/qpid/cpp/bindings/qpid/dotnet/examples/csharp.example.drain/csharp.example.drain.csproj b/qpid/cpp/bindings/qpid/dotnet/examples/csharp.example.drain/csharp.example.drain.csproj
new file mode 100644
index 0000000000..75f419d0c5
--- /dev/null
+++ b/qpid/cpp/bindings/qpid/dotnet/examples/csharp.example.drain/csharp.example.drain.csproj
@@ -0,0 +1,103 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+
+ 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.
+
+-->
+<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
+ <ProductVersion>9.0.21022</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{C43DEB69-8088-420B-B0CA-C699535E6D08}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>csharp.example.drain</RootNamespace>
+ <AssemblyName>csharp.example.drain</AssemblyName>
+ <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
+ <DebugSymbols>true</DebugSymbols>
+ <OutputPath>$(QPID_BUILD_ROOT)\src\$(Configuration)\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <DebugType>full</DebugType>
+ <PlatformTarget>x86</PlatformTarget>
+ <ErrorReport>prompt</ErrorReport>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
+ <OutputPath>$(QPID_BUILD_ROOT)\src\$(Configuration)\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <Optimize>true</Optimize>
+ <DebugType>pdbonly</DebugType>
+ <PlatformTarget>x86</PlatformTarget>
+ <ErrorReport>prompt</ErrorReport>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'RelWithDebInfo|x86' ">
+ <OutputPath>$(QPID_BUILD_ROOT)\src\$(Configuration)\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <Optimize>true</Optimize>
+ <DebugType>pdbonly</DebugType>
+ <PlatformTarget>x86</PlatformTarget>
+ <ErrorReport>prompt</ErrorReport>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
+ <DebugSymbols>true</DebugSymbols>
+ <OutputPath>$(QPID_BUILD_ROOT)\src\$(Configuration)\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <DebugType>full</DebugType>
+ <PlatformTarget>x64</PlatformTarget>
+ <ErrorReport>prompt</ErrorReport>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
+ <OutputPath>$(QPID_BUILD_ROOT)\src\$(Configuration)\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <Optimize>true</Optimize>
+ <DebugType>pdbonly</DebugType>
+ <PlatformTarget>x64</PlatformTarget>
+ <ErrorReport>prompt</ErrorReport>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'RelWithDebInfo|x64' ">
+ <OutputPath>$(QPID_BUILD_ROOT)\src\$(Configuration)\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <Optimize>true</Optimize>
+ <DebugType>pdbonly</DebugType>
+ <PlatformTarget>x64</PlatformTarget>
+ <ErrorReport>prompt</ErrorReport>
+ </PropertyGroup>
+ <ItemGroup>
+ <Compile Include="csharp.example.drain.cs" />
+ <Compile Include="Options.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\..\src\org.apache.qpid.messaging.vcproj">
+ <Project>{AA5A3B83-5F98-406D-A01C-5A921467A57D}</Project>
+ <Name>Org.Apache.Qpid.Messaging</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\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