Skip to content

Commit

Permalink
Merge pull request #98 from rabbitmq/dotnet-core-4.0.0
Browse files Browse the repository at this point in the history
Update dotnet tutorial to use dotnet core instead of mono
  • Loading branch information
michaelklishin committed Aug 19, 2016
2 parents 17632af + 6dac939 commit 979f519
Show file tree
Hide file tree
Showing 28 changed files with 292 additions and 121 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,8 @@ ruby*/rubygems*

java*/.idea/workspace.xml
java*/.idea/encodings.xml
*~
*~

.vscode/
obj/
bin/
File renamed without changes.
20 changes: 20 additions & 0 deletions dotnet/EmitLog/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"version": "1.0.0-*",
"buildOptions": {
"debugType": "portable",
"emitEntryPoint": true
},
"dependencies": {},
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
},
"RabbitMQ.Client": "4.0.*"
},
"imports": "dnxcore50"
}
}
}
File renamed without changes.
20 changes: 20 additions & 0 deletions dotnet/EmitLogDirect/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"version": "1.0.0-*",
"buildOptions": {
"debugType": "portable",
"emitEntryPoint": true
},
"dependencies": {},
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
},
"RabbitMQ.Client": "4.0.*"
},
"imports": "dnxcore50"
}
}
}
File renamed without changes.
20 changes: 20 additions & 0 deletions dotnet/EmitLogTopic/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"version": "1.0.0-*",
"buildOptions": {
"debugType": "portable",
"emitEntryPoint": true
},
"dependencies": {},
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
},
"RabbitMQ.Client": "4.0.*"
},
"imports": "dnxcore50"
}
}
}
File renamed without changes.
20 changes: 20 additions & 0 deletions dotnet/NewTask/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"version": "1.0.0-*",
"buildOptions": {
"debugType": "portable",
"emitEntryPoint": true
},
"dependencies": {},
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
},
"RabbitMQ.Client": "4.0.*"
},
"imports": "dnxcore50"
}
}
}
131 changes: 19 additions & 112 deletions dotnet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,140 +9,47 @@ To successfully use the examples you will need a running RabbitMQ server.

### Requirements on Windows

You need the RabbitMQ dotnet client.

* Download [RabbitMQ .NET client](https://github.com/rabbitmq/rabbitmq-server/releases/download/rabbitmq_v3_5_4/rabbitmq-dotnet-client-3.5.4-dotnet-4.0.zip)
* Extract it and copy "RabbitMQ.Client.dll" to your working folder.

You also need to ensure your system can find the C# compiler `csc.exe`,
you may need to add `;C:\Windows\Microsoft.NET\Framework\v4.0.30319` (change .NET version
to fit your installation) to your `PATH`.
* [dotnet core](https://www.microsoft.com/net/core)

We're using the command line (start->run cmd.exe) to
compile and run the code. Alternatively you could [use Visual Studio](https://github.com/rabbitmq/rabbitmq-tutorials/tree/master/dotnet-visual-studio) and [NuGet package](https://www.nuget.org/packages/RabbitMQ.Client/), but
this set of tutorials assumes the command line.
compile and run -p the code. Alternatively you could [use Visual Studio](https://github.com/rabbitmq/rabbitmq-tutorials/tree/master/dotnet-visual-studio) and [NuGet package](https://www.nuget.org/packages/RabbitMQ.Client/), but this set of tutorials assumes
the command line.

### Requirements on Linux

You need Mono and RabbitMQ dotnet client.

sudo apt-get install mono-devel
mkdir lib
cd lib
wget https://github.com/rabbitmq/rabbitmq-server/releases/download/rabbitmq_v3_5_4/rabbitmq-dotnet-client-3.5.4-dotnet-4.0.zip
unzip rabbitmq-dotnet-client-3.5.4-dotnet-4.0.zip
cd ..

* [dotnet core](https://www.microsoft.com/net/core)

## Code

#### [Tutorial one: "Hello World!"](http://www.rabbitmq.com/tutorial-one-dotnet.html)

##### Windows

csc /r:"RabbitMQ.Client.dll" Send.cs
csc /r:"RabbitMQ.Client.dll" Receive.cs

Send.exe
Receive.exe

##### Linux

gmcs -r:lib/bin/RabbitMQ.Client.dll Send.cs
gmcs -r:lib/bin/RabbitMQ.Client.dll Receive.cs
Each command is best run -p in a separate console/terminal instance run from the root
of the tutorial directory.

MONO_PATH=lib/bin mono Send.exe
MONO_PATH=lib/bin mono Receive.exe
#### [Tutorial one: "Hello World!"](http://www.rabbitmq.com/tutorial-one-dotnet.html)

dotnet run -p Receive
dotnet run -p Send

#### [Tutorial two: Work Queues](http://www.rabbitmq.com/tutorial-two-dotnet.html)


##### Windows

csc /r:"RabbitMQ.Client.dll" NewTask.cs
csc /r:"RabbitMQ.Client.dll" Worker.cs

NewTask.exe
Worker.exe

##### Linux

gmcs -r:lib/bin/RabbitMQ.Client.dll NewTask.cs
gmcs -r:lib/bin/RabbitMQ.Client.dll Worker.cs

MONO_PATH=lib/bin mono NewTask.exe
MONO_PATH=lib/bin mono Worker.exe
dotnet run -p Worker
dotnet run -p NewTask

#### [Tutorial three: Publish/Subscribe](http://www.rabbitmq.com/tutorial-three-dotnet.html)

##### Windows

csc /r:"RabbitMQ.Client.dll" ReceiveLogs.cs
csc /r:"RabbitMQ.Client.dll" EmitLog.cs

ReceiveLogs.exe
EmitLog.exe

##### Linux

gmcs -r:lib/bin/RabbitMQ.Client.dll ReceiveLogs.cs
gmcs -r:lib/bin/RabbitMQ.Client.dll EmitLog.cs

MONO_PATH=lib/bin mono ReceiveLogs.exe
MONO_PATH=lib/bin mono EmitLog.exe
dotnet run -p ReceiveLogs
dotnet run -p EmitLog

#### [Tutorial four: Routing](http://www.rabbitmq.com/tutorial-four-dotnet.html)

##### Windows

csc /r:"RabbitMQ.Client.dll" ReceiveLogsDirect.cs
csc /r:"RabbitMQ.Client.dll" EmitLogDirect.cs

ReceiveLogsDirect.exe
EmitLogDirect.exe

##### Linux

gmcs -r:lib/bin/RabbitMQ.Client.dll ReceiveLogsDirect.cs
gmcs -r:lib/bin/RabbitMQ.Client.dll EmitLogDirect.cs

MONO_PATH=lib/bin mono ReceiveLogsDirect.exe
MONO_PATH=lib/bin mono EmitLogDirect.exe
dotnet run -p ReceiveLogsDirect info
dotnet run -p EmitLogDirect

#### [Tutorial five: Topics](http://www.rabbitmq.com/tutorial-five-dotnet.html)

##### Windows

csc /r:"RabbitMQ.Client.dll" ReceiveLogsTopic.cs
csc /r:"RabbitMQ.Client.dll" EmitLogTopic.cs

ReceiveLogsTopic.exe
EmitLogTopic.exe

##### Linux

gmcs -r:lib/bin/RabbitMQ.Client.dll ReceiveLogsTopic.cs
gmcs -r:lib/bin/RabbitMQ.Client.dll EmitLogTopic.cs

MONO_PATH=lib/bin mono ReceiveLogsTopic.exe
MONO_PATH=lib/bin mono EmitLogTopic.exe
dotnet run -p ReceiveLogsTopic anonymous.info
dotnet run -p EmitLogTopic

#### [Tutorial six: RPC](http://www.rabbitmq.com/tutorial-six-dotnet.html)

##### Windows

csc /r:"RabbitMQ.Client.dll" RPCServer.cs
csc /r:"RabbitMQ.Client.dll" RPCClient.cs

RPCServer.exe
RPCClient.exe

##### Linux

gmcs -r:lib/bin/RabbitMQ.Client.dll RPCServer.cs
gmcs -r:lib/bin/RabbitMQ.Client.dll RPCClient.cs

MONO_PATH=lib/bin mono RPCServer.exe
MONO_PATH=lib/bin mono RPCClient.exe

dotnet run -p RPCServer
dotnet run -p RPCClient
File renamed without changes.
20 changes: 20 additions & 0 deletions dotnet/RPCClient/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"version": "1.0.0-*",
"buildOptions": {
"debugType": "portable",
"emitEntryPoint": true
},
"dependencies": {},
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
},
"RabbitMQ.Client": "4.0.*"
},
"imports": "dnxcore50"
}
}
}
File renamed without changes.
20 changes: 20 additions & 0 deletions dotnet/RPCServer/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"version": "1.0.0-*",
"buildOptions": {
"debugType": "portable",
"emitEntryPoint": true
},
"dependencies": {},
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
},
"RabbitMQ.Client": "4.0.*"
},
"imports": "dnxcore50"
}
}
}
File renamed without changes.
20 changes: 20 additions & 0 deletions dotnet/Receive/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"version": "1.0.0-*",
"buildOptions": {
"debugType": "portable",
"emitEntryPoint": true
},
"dependencies": {},
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
},
"RabbitMQ.Client": "4.0.*"
},
"imports": "dnxcore50"
}
}
}
File renamed without changes.
20 changes: 20 additions & 0 deletions dotnet/ReceiveLogs/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"version": "1.0.0-*",
"buildOptions": {
"debugType": "portable",
"emitEntryPoint": true
},
"dependencies": {},
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
},
"RabbitMQ.Client": "4.0.*"
},
"imports": "dnxcore50"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class ReceiveLogsDirect
{
public static void Main(string[] args)
public static int Main(string[] args)
{
var factory = new ConnectionFactory() { HostName = "localhost" };
using(var connection = factory.CreateConnection())
Expand All @@ -19,8 +19,7 @@ public static void Main(string[] args)
Console.Error.WriteLine("Usage: {0} [info] [warning] [error]", Environment.GetCommandLineArgs()[0]);
Console.WriteLine(" Press [enter] to exit.");
Console.ReadLine();
Environment.ExitCode = 1;
return;
return 1;
}

foreach(var severity in args)
Expand All @@ -42,6 +41,7 @@ public static void Main(string[] args)

Console.WriteLine(" Press [enter] to exit.");
Console.ReadLine();
return 0;
}
}
}
20 changes: 20 additions & 0 deletions dotnet/ReceiveLogsDirect/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"version": "1.0.0-*",
"buildOptions": {
"debugType": "portable",
"emitEntryPoint": true
},
"dependencies": {},
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
},
"RabbitMQ.Client": "4.0.*"
},
"imports": "dnxcore50"
}
}
}
Loading

0 comments on commit 979f519

Please sign in to comment.