From 49653e2d5fb3e5416460f81af75ee3761859f870 Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Fri, 14 May 2010 14:08:30 +0000 Subject: QPID-2589 1) Added map-message examples 2) Added license text to example sources git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@944270 13f79535-47bb-0310-9956-ffa450edef68 --- .../csharp.direct.receiver.cs | 21 ++++++ .../csharp.direct.sender/csharp.direct.sender.cs | 21 ++++++ .../csharp.map.receiver/Properties/AssemblyInfo.cs | 36 +++++++++ .../csharp.map.receiver/csharp.map.receiver.csproj | 63 ++++++++++++++++ .../csharp.map.receiver/csharp.map.recevier.cs | 75 +++++++++++++++++++ .../csharp.map.sender/Properties/AssemblyInfo.cs | 36 +++++++++ .../csharp.map.sender/csharp.map.sender.cs | 87 ++++++++++++++++++++++ .../csharp.map.sender/csharp.map.sender.csproj | 63 ++++++++++++++++ .../qpid/dotnet/org.apache.qpid.messaging.sln | 29 ++++++++ 9 files changed, 431 insertions(+) create mode 100644 cpp/bindings/qpid/dotnet/examples/csharp.map.receiver/Properties/AssemblyInfo.cs create mode 100644 cpp/bindings/qpid/dotnet/examples/csharp.map.receiver/csharp.map.receiver.csproj create mode 100644 cpp/bindings/qpid/dotnet/examples/csharp.map.receiver/csharp.map.recevier.cs create mode 100644 cpp/bindings/qpid/dotnet/examples/csharp.map.sender/Properties/AssemblyInfo.cs create mode 100644 cpp/bindings/qpid/dotnet/examples/csharp.map.sender/csharp.map.sender.cs create mode 100644 cpp/bindings/qpid/dotnet/examples/csharp.map.sender/csharp.map.sender.csproj (limited to 'cpp') diff --git a/cpp/bindings/qpid/dotnet/examples/csharp.direct.receiver/csharp.direct.receiver.cs b/cpp/bindings/qpid/dotnet/examples/csharp.direct.receiver/csharp.direct.receiver.cs index db54600882..6cc2a5e0a5 100644 --- a/cpp/bindings/qpid/dotnet/examples/csharp.direct.receiver/csharp.direct.receiver.cs +++ b/cpp/bindings/qpid/dotnet/examples/csharp.direct.receiver/csharp.direct.receiver.cs @@ -1,3 +1,24 @@ +/* + * + * 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.Generic; using System.Linq; diff --git a/cpp/bindings/qpid/dotnet/examples/csharp.direct.sender/csharp.direct.sender.cs b/cpp/bindings/qpid/dotnet/examples/csharp.direct.sender/csharp.direct.sender.cs index 3ad6c58a2c..bf49787f9b 100644 --- a/cpp/bindings/qpid/dotnet/examples/csharp.direct.sender/csharp.direct.sender.cs +++ b/cpp/bindings/qpid/dotnet/examples/csharp.direct.sender/csharp.direct.sender.cs @@ -1,3 +1,24 @@ +/* + * + * 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.Generic; using System.Linq; diff --git a/cpp/bindings/qpid/dotnet/examples/csharp.map.receiver/Properties/AssemblyInfo.cs b/cpp/bindings/qpid/dotnet/examples/csharp.map.receiver/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..c4f2f04ab2 --- /dev/null +++ b/cpp/bindings/qpid/dotnet/examples/csharp.map.receiver/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +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.map.receiver")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("csharp.map.receiver")] +[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("002049f9-41c5-420f-9ff6-45bb652dded6")] + +// 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/cpp/bindings/qpid/dotnet/examples/csharp.map.receiver/csharp.map.receiver.csproj b/cpp/bindings/qpid/dotnet/examples/csharp.map.receiver/csharp.map.receiver.csproj new file mode 100644 index 0000000000..a491274c62 --- /dev/null +++ b/cpp/bindings/qpid/dotnet/examples/csharp.map.receiver/csharp.map.receiver.csproj @@ -0,0 +1,63 @@ + + + + Debug + AnyCPU + 9.0.30729 + 2.0 + {AD9E53D7-DB10-4DA2-84D2-A81BE09B04E9} + Exe + Properties + csharp.map.receiver + csharp.map.receiver + v3.5 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + False + ..\..\bin\Debug\org.apache.qpid.messagingd.dll + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + \ No newline at end of file diff --git a/cpp/bindings/qpid/dotnet/examples/csharp.map.receiver/csharp.map.recevier.cs b/cpp/bindings/qpid/dotnet/examples/csharp.map.receiver/csharp.map.recevier.cs new file mode 100644 index 0000000000..461708ee16 --- /dev/null +++ b/cpp/bindings/qpid/dotnet/examples/csharp.map.receiver/csharp.map.recevier.cs @@ -0,0 +1,75 @@ +/* + * + * 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.Generic; +using org.apache.qpid.messaging; + +namespace org.apache.qpid.messaging.examples +{ + class MapReceiver + { + static void Main(string[] args) + { +// string url = "amqp:tcp:localhost:5672"; + string url = "10.16.18.254:5672"; + if (args.Length > 0) + url = args[0]; + + // + // Create and open an AMQP connection to the broker URL + // + Connection connection = new Connection(url); + connection.open(); + + // + // Create a session and a receiver fir the direct exchange using the + // routing key "map_example". + // + Session session = connection.createSession(); + Receiver receiver = session.createReceiver("amq.direct/map_example"); + + // + // Fetch the message from the broker (wait indefinitely by default) + // + Message message = receiver.fetch(new Duration(60000)); + + // + // Extract the structured content from the message. + // + Dictionary content = new Dictionary(); + message.getContent(content); + Console.WriteLine("Received: {0}", content); + + // + // Acknowledge the receipt of all received messages. + // + session.acknowledge(); + + // + // Close the receiver and the connection. + // + receiver.close(); + connection.close(); + } + } +} + diff --git a/cpp/bindings/qpid/dotnet/examples/csharp.map.sender/Properties/AssemblyInfo.cs b/cpp/bindings/qpid/dotnet/examples/csharp.map.sender/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..855d162517 --- /dev/null +++ b/cpp/bindings/qpid/dotnet/examples/csharp.map.sender/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +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.map.sender")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("csharp.map.sender")] +[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("1eec2eca-adbd-4394-8b01-f4c4645bb122")] + +// 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/cpp/bindings/qpid/dotnet/examples/csharp.map.sender/csharp.map.sender.cs b/cpp/bindings/qpid/dotnet/examples/csharp.map.sender/csharp.map.sender.cs new file mode 100644 index 0000000000..2890367599 --- /dev/null +++ b/cpp/bindings/qpid/dotnet/examples/csharp.map.sender/csharp.map.sender.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.Collections.Generic; +using System.Linq; +using System.Text; +using org.apache.qpid.messaging; + +namespace org.apache.qpid.messaging.examples +{ + class MapSender + { + static void Main(string[] args) + { + string url = "amqp:tcp:localhost:5672"; + if (args.Length > 0) + url = args[0]; + + // + // Create and open an AMQP connection to the broker URL + // + Connection connection = new Connection(url); + connection.open(); + + // + // Create a session and a sender to the direct exchange using the + // routing key "map_example". + // + Session session = connection.createSession(); + Sender sender = session.createSender("amq.direct/map_example"); + + // + // Create structured content for the message. This example builds a + // map of items including a nested map and a list of values. + // + Dictionary content = new Dictionary(); + Dictionary subMap = new Dictionary(); + List colors = new List(); + + content["id"] = 987654321; + content["name"] = "Widget"; + content["percent"] = 0.99; + + subMap["name"] = "Smith"; + subMap["number"] = 354; + + content["nested"] = subMap; + + colors.Add("red"); + colors.Add("green"); + colors.Add("white"); + + content["colors"] = colors; + + // + // Construct a message with the map content and send it synchronously + // via the sender. + // + Message message = new Message(content); + sender.send(message, true); + + // + // Close the connection. + // + connection.close(); + } + } +} diff --git a/cpp/bindings/qpid/dotnet/examples/csharp.map.sender/csharp.map.sender.csproj b/cpp/bindings/qpid/dotnet/examples/csharp.map.sender/csharp.map.sender.csproj new file mode 100644 index 0000000000..d647509474 --- /dev/null +++ b/cpp/bindings/qpid/dotnet/examples/csharp.map.sender/csharp.map.sender.csproj @@ -0,0 +1,63 @@ + + + + Debug + AnyCPU + 9.0.30729 + 2.0 + {5D8252F5-E1D3-44A0-94C7-7CB75E843C10} + Exe + Properties + csharp.map.sender + csharp.map.sender + v3.5 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + False + ..\..\bin\Debug\org.apache.qpid.messagingd.dll + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + \ No newline at end of file diff --git a/cpp/bindings/qpid/dotnet/org.apache.qpid.messaging.sln b/cpp/bindings/qpid/dotnet/org.apache.qpid.messaging.sln index 9708b38f97..0619727239 100644 --- a/cpp/bindings/qpid/dotnet/org.apache.qpid.messaging.sln +++ b/cpp/bindings/qpid/dotnet/org.apache.qpid.messaging.sln @@ -25,6 +25,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "messaging.test", "test\mess {AA5A3B83-5F98-406D-A01C-5A921467A57D} = {AA5A3B83-5F98-406D-A01C-5A921467A57D} EndProjectSection EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "StructuredMessage", "StructuredMessage", "{E99FEFEE-B866-4BBA-9AA3-79DDF1C92960}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "csharp.map.sender", "examples\csharp.map.sender\csharp.map.sender.csproj", "{5D8252F5-E1D3-44A0-94C7-7CB75E843C10}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "csharp.map.receiver", "examples\csharp.map.receiver\csharp.map.receiver.csproj", "{AD9E53D7-DB10-4DA2-84D2-A81BE09B04E9}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -75,6 +81,26 @@ Global {AF2FBC78-266C-430C-BC29-9477AB596A36}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {AF2FBC78-266C-430C-BC29-9477AB596A36}.Release|Mixed Platforms.Build.0 = Release|Any CPU {AF2FBC78-266C-430C-BC29-9477AB596A36}.Release|Win32.ActiveCfg = Release|Any CPU + {5D8252F5-E1D3-44A0-94C7-7CB75E843C10}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5D8252F5-E1D3-44A0-94C7-7CB75E843C10}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5D8252F5-E1D3-44A0-94C7-7CB75E843C10}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {5D8252F5-E1D3-44A0-94C7-7CB75E843C10}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {5D8252F5-E1D3-44A0-94C7-7CB75E843C10}.Debug|Win32.ActiveCfg = Debug|Any CPU + {5D8252F5-E1D3-44A0-94C7-7CB75E843C10}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5D8252F5-E1D3-44A0-94C7-7CB75E843C10}.Release|Any CPU.Build.0 = Release|Any CPU + {5D8252F5-E1D3-44A0-94C7-7CB75E843C10}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {5D8252F5-E1D3-44A0-94C7-7CB75E843C10}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {5D8252F5-E1D3-44A0-94C7-7CB75E843C10}.Release|Win32.ActiveCfg = Release|Any CPU + {AD9E53D7-DB10-4DA2-84D2-A81BE09B04E9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AD9E53D7-DB10-4DA2-84D2-A81BE09B04E9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AD9E53D7-DB10-4DA2-84D2-A81BE09B04E9}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {AD9E53D7-DB10-4DA2-84D2-A81BE09B04E9}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {AD9E53D7-DB10-4DA2-84D2-A81BE09B04E9}.Debug|Win32.ActiveCfg = Debug|Any CPU + {AD9E53D7-DB10-4DA2-84D2-A81BE09B04E9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AD9E53D7-DB10-4DA2-84D2-A81BE09B04E9}.Release|Any CPU.Build.0 = Release|Any CPU + {AD9E53D7-DB10-4DA2-84D2-A81BE09B04E9}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {AD9E53D7-DB10-4DA2-84D2-A81BE09B04E9}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {AD9E53D7-DB10-4DA2-84D2-A81BE09B04E9}.Release|Win32.ActiveCfg = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -82,8 +108,11 @@ Global GlobalSection(NestedProjects) = preSolution {DE58D329-10DC-4C8D-9EFA-230A57314089} = {34C477FB-B0CC-4AB9-A346-EA7B055469AC} {878FDDF8-A870-41D6-9E36-0A050EC5ACAB} = {34C477FB-B0CC-4AB9-A346-EA7B055469AC} + {E99FEFEE-B866-4BBA-9AA3-79DDF1C92960} = {34C477FB-B0CC-4AB9-A346-EA7B055469AC} {7B71CE78-8E78-4632-ADBE-F4D5DFAE0068} = {DE58D329-10DC-4C8D-9EFA-230A57314089} {52F880E7-D677-4C91-8516-D679CE0F46A8} = {DE58D329-10DC-4C8D-9EFA-230A57314089} {AF2FBC78-266C-430C-BC29-9477AB596A36} = {39E9D1BF-3A0B-4D86-BF6B-F463E1A2245A} + {5D8252F5-E1D3-44A0-94C7-7CB75E843C10} = {E99FEFEE-B866-4BBA-9AA3-79DDF1C92960} + {AD9E53D7-DB10-4DA2-84D2-A81BE09B04E9} = {E99FEFEE-B866-4BBA-9AA3-79DDF1C92960} EndGlobalSection EndGlobal -- cgit v1.2.1