|
3 | 3 | Here you can find C# code examples for [RabbitMQ
|
4 | 4 | tutorials](http://www.rabbitmq.com/getstarted.html).
|
5 | 5 |
|
6 |
| -You'll need erlang installed, and also access to a [RabbitMQ server](http://www.rabbitmq.com/server.html). |
7 |
| -These are easy to [install](http://www.rabbitmq.com/install.html). |
| 6 | +## Requirements |
8 | 7 |
|
| 8 | +### Requirements on Windows |
9 | 9 |
|
10 |
| -## Requirements |
| 10 | +You need the RabbitMQ dotnet client. |
| 11 | + |
| 12 | +* Download [rabbitmq-dotnet-client-2.4.1-dotnet-3.0.zip](http://www.rabbitmq.com/releases/rabbitmq-dotnet-client/v2.4.1/rabbitmq-dotnet-client-2.4.1-dotnet-3.0.zip) |
| 13 | +* Extract it and copy "RabbitMQ.Client.dll" to your working folder. |
| 14 | + |
| 15 | +You also need to nsure your system can find the C# compiler `csc.exe`, |
| 16 | +you may need to add `;C:\WINDOWS\Microsoft.NET\Framework\v3.5` to your |
| 17 | +Path. |
| 18 | + |
| 19 | +We're suggesting to use the command line (start->run cmd.exe) to |
| 20 | +compile and run the code. Alternatively you could use Visual Studio, but |
| 21 | +due to the nature of examples command line is a preferred interface. |
| 22 | + |
| 23 | +### Requirements on Linux |
11 | 24 |
|
12 |
| -### Mono on Linux |
13 | 25 | You need Mono and RabbitMQ dotnet client.
|
14 | 26 |
|
15 | 27 | sudo apt-get install mono-devel
|
16 | 28 | mkdir lib
|
17 | 29 | cd lib
|
18 |
| - wget http://www.rabbitmq.com/releases/rabbitmq-dotnet-client/v2.1.1/rabbitmq-dotnet-client-2.1.1-dotnet-3.0.zip |
19 |
| - unzip rabbitmq-dotnet-client-2.1.1-dotnet-3.0.zip |
| 30 | + wget http://www.rabbitmq.com/releases/rabbitmq-dotnet-client/v2.4.1/rabbitmq-dotnet-client-2.4.1-dotnet-3.0.zip |
| 31 | + unzip rabbitmq-dotnet-client-2.4.1-dotnet-3.0.zip |
20 | 32 | cd ..
|
21 | 33 |
|
22 |
| - |
23 |
| -### Windows |
24 |
| -You need the RabbitMQ dotnet client. |
25 |
| - |
26 |
| - Go to http://www.rabbitmq.com/releases/rabbitmq-dotnet-client/v2.1.1 |
27 |
| - Download rabbitmq-dotnet-client-2.1.1-dotnet-3.0.zip |
28 |
| - Extract it to rabbitmq-dotnet-client-2.1.1-dotnet-3.0 in your working folder |
29 | 34 |
|
30 |
| - |
31 | 35 | ## Code
|
32 | 36 |
|
33 |
| -For background, you can refer to [Tutorial one: "Hello World!"](http://www.rabbitmq.com/tutorial-one-python.html): |
| 37 | +#### [Tutorial one: "Hello World!"](http://www.rabbitmq.com/tutorial-one-python.html) |
34 | 38 |
|
| 39 | +##### Windows |
35 | 40 |
|
36 |
| -### Compile and run the C# examples using Mono on Linux. |
| 41 | + csc /r:"RabbitMQ.Client.dll" Send.cs |
| 42 | + csc /r:"RabbitMQ.Client.dll" Receive.cs |
37 | 43 |
|
38 |
| - gmcs -r:lib/bin/RabbitMQ.Client.dll Send.cs |
39 |
| - MONO_PATH=lib/bin mono Send.exe |
| 44 | + Send.exe |
| 45 | + Receive.exe |
40 | 46 |
|
| 47 | +##### Linux |
| 48 | + |
| 49 | + gmcs -r:lib/bin/RabbitMQ.Client.dll Send.cs |
41 | 50 | gmcs -r:lib/bin/RabbitMQ.Client.dll Receive.cs
|
| 51 | + |
| 52 | + MONO_PATH=lib/bin mono Send.exe |
42 | 53 | MONO_PATH=lib/bin mono Receive.exe
|
43 |
| - |
44 |
| - |
45 |
| -### Compile the C# examples on Windows |
46 | 54 |
|
47 |
| -Ensure your system can find the c# compiler `csc.exe` |
48 | 55 |
|
49 |
| - e.g. Add `;C:\WINDOWS\Microsoft.NET\Framework\v3.5` to your Path |
50 |
| - |
51 |
| -If you put the whole client directory in your working directory: |
| 56 | +#### [Tutorial two: Work Queues](http://www.rabbitmq.com/tutorial-two-python.html): |
52 | 57 |
|
53 |
| - csc /r:".\rabbitmq-dotnet-client-2.1.1-dotnet-3.0\bin\RabbitMQ.Client.dll" Send.cs |
54 |
| - csc /r:".\rabbitmq-dotnet-client-2.1.1-dotnet-3.0\bin\RabbitMQ.Client.dll" Receive.cs |
| 58 | +##### Windows |
55 | 59 |
|
56 |
| -or, if you just copy the RabbitMQ.Client.dll client library to your working directory: |
| 60 | + csc /r:"RabbitMQ.Client.dll" NewTask.cs |
| 61 | + csc /r:"RabbitMQ.Client.dll" Worker.cs |
57 | 62 |
|
58 |
| - csc /r:"RabbitMQ.Client.dll" Send.cs |
59 |
| - csc /r:"RabbitMQ.Client.dll" Receive.cs |
| 63 | + NewTask.exe |
| 64 | + Worker.exe |
60 | 65 |
|
61 |
| -or you could use MS Visual Studio. |
| 66 | +##### Linux |
62 | 67 |
|
| 68 | + gmcs -r:lib/bin/RabbitMQ.Client.dll NewTask.cs |
| 69 | + gmcs -r:lib/bin/RabbitMQ.Client.dll Worker.cs |
63 | 70 |
|
64 |
| -### Run the example programs on Windows |
| 71 | + MONO_PATH=lib/bin mono NewTask.exe |
| 72 | + MONO_PATH=lib/bin mono Worker.exe |
65 | 73 |
|
66 |
| -Open 3 Command Prompt windows Start > Run... cmd |
| 74 | +[Tutorial three: Publish/Subscribe](http://www.rabbitmq.com/tutorial-three-python.html) |
67 | 75 |
|
68 |
| -Use `rabbitmqctl status` to check the server is running, |
69 |
| -and `rabbitmqctl list_queues` to inspect the queue. |
| 76 | +##### Windows |
70 | 77 |
|
71 |
| -In the other two windows, navigate to your working directory to run the example client programs. |
| 78 | + csc /r:"RabbitMQ.Client.dll" ReceiveLogs.cs |
| 79 | + csc /r:"RabbitMQ.Client.dll" EmitLog.cs |
72 | 80 |
|
73 |
| -In another cmd window, send a message: |
74 |
| - |
75 |
| - Send.exe |
| 81 | + ReceiveLogs.exe |
| 82 | + EmitLog.exe |
76 | 83 |
|
77 |
| -Check queue identified as "hello" has 1 message. |
78 |
| -In the final cmd window, set the listener going: |
| 84 | +##### Linux |
79 | 85 |
|
80 |
| - Receive.exe |
| 86 | + gmcs -r:lib/bin/RabbitMQ.Client.dll ReceiveLogs.cs |
| 87 | + gmcs -r:lib/bin/RabbitMQ.Client.dll EmitLog.cs |
81 | 88 |
|
82 |
| -This will keep listening (Ctrl-C in this window will stop it) for messages. |
83 |
| -You should now see the first message, and the queue should be empty. |
84 |
| -The Receive view should get any further messages you Send. |
| 89 | + MONO_PATH=lib/bin mono ReceiveLogs.exe |
| 90 | + MONO_PATH=lib/bin mono EmitLog.exe |
0 commit comments