diff --git a/examples/dotnet/.DS_Store b/examples/dotnet/.DS_Store new file mode 100644 index 0000000000..5eb69ec107 Binary files /dev/null and b/examples/dotnet/.DS_Store differ diff --git a/examples/dotnet/amqp/.DS_Store b/examples/dotnet/amqp/.DS_Store new file mode 100644 index 0000000000..d92dbd4cea Binary files /dev/null and b/examples/dotnet/amqp/.DS_Store differ diff --git a/examples/protocols/amqp/dotnet/.vscode/launch.json b/examples/protocols/amqp/dotnet/.vscode/launch.json new file mode 100644 index 0000000000..13d3214e67 --- /dev/null +++ b/examples/protocols/amqp/dotnet/.vscode/launch.json @@ -0,0 +1,40 @@ +/** + * 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. + */ + +{ + "version": "0.2.0", + "configurations": [ + { + "name": ".NET Core Launch (console)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + "program": "${workspaceRoot}/bin/Debug/netcoreapp1.1/queue.dll", + "args": [], + "cwd": "${workspaceRoot}", + "externalConsole": false, + "stopAtEntry": false, + "internalConsoleOptions": "openOnSessionStart" + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach", + "processId": "${command.pickProcess}" + } + ] +} diff --git a/examples/protocols/amqp/dotnet/.vscode/tasks.json b/examples/protocols/amqp/dotnet/.vscode/tasks.json new file mode 100644 index 0000000000..f53eedd41d --- /dev/null +++ b/examples/protocols/amqp/dotnet/.vscode/tasks.json @@ -0,0 +1,33 @@ +/** + * 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. + */ + +{ + "version": "0.1.0", + "command": "dotnet", + "isShellCommand": true, + "args": [], + "tasks": [ + { + "taskName": "build", + "args": [ + "${workspaceRoot}/project.json" + ], + "isBuildCommand": true, + "problemMatcher": "$msCompile" + } + ] +} diff --git a/examples/protocols/amqp/dotnet/Program.cs b/examples/protocols/amqp/dotnet/Program.cs new file mode 100755 index 0000000000..264570ed27 --- /dev/null +++ b/examples/protocols/amqp/dotnet/Program.cs @@ -0,0 +1,39 @@ +/** + * 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 Amqp; +namespace ConsoleApplication +{ + public class Program + { + public static void Main(string[] args) + { + string address = "amqp://a:a@localhost:5672"; + + Connection connection = new Connection(new Address(address)); + Session session = new Session(connection); + SenderLink sender = new SenderLink(session, "test-sender", "q1"); + + Message message1 = new Message("Hello AMQP!"); + sender.Send(message1); + + + Console.WriteLine("Message sent into queue q1"); + } + } +} diff --git a/examples/protocols/amqp/dotnet/project.json b/examples/protocols/amqp/dotnet/project.json new file mode 100755 index 0000000000..7df8f24dd8 --- /dev/null +++ b/examples/protocols/amqp/dotnet/project.json @@ -0,0 +1,36 @@ +/** + * 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. + */ + +{ + "version": "1.0.0-*", + "buildOptions": { + "debugType": "portable", + "emitEntryPoint": true + }, + "dependencies": {"AMQPNetLite": "1.2.2"}, + "frameworks": { + "netcoreapp1.1": { + "dependencies": { + "Microsoft.NETCore.App": { + "type": "platform", + "version": "1.1.0" + } + }, + "imports": "dnxcore50" + } + } +} diff --git a/examples/protocols/amqp/dotnet/readme.md b/examples/protocols/amqp/dotnet/readme.md new file mode 100644 index 0000000000..6a6297772b --- /dev/null +++ b/examples/protocols/amqp/dotnet/readme.md @@ -0,0 +1,50 @@ +# Running the .NET AMQP example + + +# Pre-requisites: + +All of this can be done on Linux, Mac and... Windows + +- Install .NET + +https://www.microsoft.com/net/core + + +- Visual Studio Code is free and may be useful: + +https://code.visualstudio.com + + +- Powershell might be also useful: + +https://github.com/PowerShell/PowerShell/ + + + +# running the example + +- Create the broker, by running: + +``` +../../../../bin/artemis create ./server1 --user a --password a --role a --allow-anonymous --force +./server1/bin/artemis-service start +``` + +Or simply use the start-broker.sh script on this directory + + +- Compile the code + +You need to restore the package, build and run so .NET may download your packages from NuGET: + +```sh +dotnet restore +dotnet build +dotnet run +``` + +Or simply use the run-example.sh script on this directory + +- Debugging + +Visual Studio Code will make it fairly easy to do it diff --git a/examples/protocols/amqp/dotnet/run-example.sh b/examples/protocols/amqp/dotnet/run-example.sh new file mode 100755 index 0000000000..efcd53bc9e --- /dev/null +++ b/examples/protocols/amqp/dotnet/run-example.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env sh +# 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. + +echo "Make sure you run start-broker.sh first" + +dotnet restore +dotnet build +dotnet run diff --git a/examples/protocols/amqp/dotnet/start-broker.sh b/examples/protocols/amqp/dotnet/start-broker.sh new file mode 100755 index 0000000000..1f193dac48 --- /dev/null +++ b/examples/protocols/amqp/dotnet/start-broker.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env sh +# 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. + +# if you are using a source distribution you will have to create and start the broker manually +# Use this as a reference! +../../../../bin/artemis create ./server1 --user a --password a --role a --allow-anonymous --force +./server1/bin/artemis-service start