DOI: 10.18419/darus-4193
title: Multi-protocol Messaging and Streaming Broker for Grasshopper (RabbitMQ_GH)

description: &lt;p&gt;RabbitMQ GH is a Grasshopper plugin for implementing RabbitMQ messaging capabilities to exchange data between external applications and Grasshopper scripts in real time, with a high degree of flexibility and scalability.&lt;/p&gt;

&lt;h3&gt;INSTALLATION&lt;/h3&gt;
&lt;b&gt;Erlang installation&lt;/b&gt;
&lt;p&gt;Download the current &lt;a href="https://erlang.org/download/otp_versions_tree.html"&gt;Erlang&lt;/a&gt; version installer and follow the default setup in the installation wizard.&lt;/p&gt;
 &lt;p&gt;Add Erlang to the Environment variables. To do it, go to &lt;em&gt;Control Panel&gt;System and Security&gt;System&lt;/em&gt;. A new window will open. Click on &lt;em&gt;Advanced system settings&lt;/em&gt; under the &lt;em&gt;Device specifications&lt;/em&gt; collapsable panel. When the &lt;em&gt;System Properties&lt;/em&gt; window appears, click on the &lt;em&gt;Environment Variables&lt;/em&gt; button at the bottom of the &lt;em&gt;Advanced&lt;/em&gt; tab.&lt;/p&gt;
 &lt;p&gt;On the &lt;em&gt;User variables&lt;/em&gt; section use the &lt;em&gt;New...&lt;/em&gt; button to add a new variable with &lt;strong&gt;ERLANG_HOME&lt;/strong&gt; as the &lt;em&gt;Variable name&lt;/em&gt; and the installation path as the &lt;em&gt;variable value&lt;/em&gt; (By default the installation path should be &lt;em&gt;C:\Program Files\Erlang OTP&lt;/em&gt;).&lt;/p&gt;
 &lt;p&gt;To verify that the variable was correctly added, open a command prompt and enter the &lt;code&gt;ECHO %ERLANG_HOME%&lt;/code&gt; command. If the installation path is printed on the screen, the variable is correctly added.&lt;/p&gt;

 &lt;b&gt;RabbitMQ installation&lt;/b&gt;
 &lt;p&gt;On RabbitMQ´s &lt;a href="https://github.com/rabbitmq/rabbitmq-server/"&gt;GitHub page&lt;/a&gt; go to the &lt;em&gt;Releases&lt;/em&gt; section on the right-hand side of the window. Click on the latest release and navigate to the &lt;em&gt;assets&lt;/em&gt; section and download the &lt;em&gt;rabbitmq-server-windows-&lt;version&gt;.zip&lt;/em&gt; file, where&lt;version&gt; corresponds to the latest release version number. Extract the compressed files to the directory where you want RabbitMQ to be stored.&lt;/p&gt;
 &lt;p&gt;To run RabbitMQ, open a terminal window and go to the installation directory. Once there, run the &lt;code&gt;rabbitmq-server.bat&lt;/code&gt; command. The current Erlang version and the plugins being used should be printed on the screen.&lt;/p&gt;
 &lt;p&gt;In Windows, RabbitMQ does not run on startup by default. To change that, the Startup type of the RabbitMQ Server must be set to &lt;em&gt;Automatic&lt;/em&gt;&lt;/p&gt;
 &lt;p&gt;If the plugins are not working properly, follow the same procedure described in the following section to activate them.&lt;/p&gt;

 &lt;b&gt;Management plugin activation&lt;/b&gt;
 &lt;p&gt;To activate the management plugin, open a terminal window and go to the installation directory. After that, run the &lt;code&gt;rabbitmq-plugins enable rabbitmq_management&lt;/code&gt; command. This should enable the plugin and it should be working the next time RabbitMQ is launched. The same command works for activating other plugins by replacing &lt;em&gt;rabbitmq_management&lt;/em&gt; with the plugin's name after it has been downloaded into the plugin's directory located on RabbitMQ's installation directory.&lt;/p&gt;
 &lt;p&gt;For further information, follow this &lt;a href="https://youtube.com/playlist?list=PLalrWAGybpB-UHbRDhFsBgXJM1g6T4IvO&si=324s3u0WqtVukrIl"&gt;link&lt;/a&gt;.&lt;/p&gt;

 &lt;b&gt;Grasshopper plugin installation&lt;/b&gt;
 &lt;p&gt;Copy the folder &lt;i&gt;Installation_Files/Rabbit_MQ_GH&lt;/i&gt; into your Grasshopper component folder. If you don´t know the location of this folder on your computer, you can find it using Grasshopper's interface. Go to &lt;em&gt;File&gt;Special Folders&gt;Components Folder&lt;/em&gt; and a file explorer window will open in the correct directory.&lt;/p&gt;
 &lt;p&gt;In general, downloaded &lt;em&gt;.gha&lt;/em&gt; files can be blocked by Windows OS, so verify that all the downloaded files are unblocked. To do so, find each file in the file explorer and right-click on it. In the context menu select &lt;em&gt;Properties&lt;/em&gt;. This will open a new window. Go to the lower part of the &lt;em&gt;general&lt;/em&gt; tab and check the checkbox labeled &lt;em&gt;Unblock&lt;/em&gt;.&lt;/p&gt;
 &lt;p&gt;For the use of the plugin, even after closing the &lt;em&gt;.gh&lt;/em&gt; files, the connections created in the session will remain open if the &lt;em&gt;Run&lt;/em&gt; toggle is set to &lt;code&gt;True&lt;/code&gt;. To prevent this, make sure to set the toggle to &lt;code&gt;False&lt;/code&gt; before closing the file.&lt;/p&gt;

 &lt;b&gt;Additional resources&lt;/b&gt;
 &lt;ul&gt;
 &lt;li&gt;&lt;a href="https://gcore.com/learning/how-to-install-rabbitmq-ubuntu/"&gt;Linux machine deployment&lt;/a&gt;&lt;/li&gt;
 &lt;li&gt;&lt;a href="https://docs.aws.amazon.com/amazon-mq/latest/developer-guide/working-with-rabbitmq.html"&gt;AWS deployment&lt;/a&gt;&lt;/li&gt;
 &lt;/ul&gt;

 &lt;h3&gt;MANAGEMENT PLUGIN&lt;/h3&gt;
 &lt;p&gt;To open the management plugin, in your web browser navigate to &lt;code&gt;localhost:15672&lt;/code&gt; If no credentials have been established, use &lt;code&gt;guest&lt;/code&gt; as the default &lt;em&gt;username&lt;/em&gt; and &lt;em&gt;password&lt;/em&gt; to log in.&lt;/p&gt;

 &lt;h3&gt;USE PATTERNS&lt;/h3&gt;
 &lt;p&gt;Example files covering several use patterns for Grasshopper, Python, and C# are located in the folder &lt;i&gt;Tutorial/Examples/&lt;/i&gt;.&lt;/p&gt;
 &lt;p&gt;Most of them build on top of the consumer-producer pattern. It has two main components: A producer that sends messages to a RabbitMQ queue and a consumer that receives the messages from the queue and processes them.&lt;/p&gt;
 &lt;p&gt;These are all the patterns covered in the example files with a detailed explanation in &lt;i&gt;Tutorial/Examples/readme.md&lt;/i&gt;:&lt;/p&gt;
 &lt;ul&gt;
 &lt;li&gt;&lt;a href="https://github.com/LiorSkoury-git/RabbitMQ_Grasshopper/tree/Documentation/Tutorial/Examples/Basic_consumer"&gt;Basic consumer&lt;/a&gt;&lt;/li&gt;
 &lt;li&gt;&lt;a href="https://github.com/LiorSkoury-git/RabbitMQ_Grasshopper/tree/Documentation/Tutorial/Examples/Competing_consumers"&gt;Competing consumers&lt;/a&gt;&lt;/li&gt;
 &lt;li&gt;&lt;a href="https://github.com/LiorSkoury-git/RabbitMQ_Grasshopper/tree/Documentation/Tutorial/Examples/Publisher_subscriber"&gt;Publisher-subscriber&lt;/a&gt;&lt;/li&gt;
 &lt;li&gt;&lt;a href="https://github.com/LiorSkoury-git/RabbitMQ_Grasshopper/tree/Documentation/Tutorial/Examples/Request_reply"&gt;Request-reply&lt;/a&gt;&lt;/li&gt;
 &lt;li&gt;&lt;a href="https://github.com/LiorSkoury-git/RabbitMQ_Grasshopper/tree/Documentation/Tutorial/Examples/Basic_routing"&gt;Basic routing&lt;/a&gt;&lt;/li&gt;
 &lt;li&gt;&lt;a href="https://github.com/LiorSkoury-git/RabbitMQ_Grasshopper/tree/Documentation/Tutorial/Examples/Topic_routing"&gt;Topic routing&lt;/a&gt;&lt;/li&gt;
 &lt;/ul&gt;