Thursday, February 21, 2019

RabbitMQ - How to setup and Test from Mule 3.9

  • Install RabbitMQ
    • Step 1: Install Erlang
    • Step 2: Install RabbitMQ
  • Enable RabbitMQ Web Console
    • RabbitMQ Login Page
    • RabbitMQ Overview Page
    • Start RabbitMQ Service in Windows
  • Setting up Mule
    • Create New Mule App and Design Flow
    • Add AMQP-0-9 Connector Global Element
    • Create A Queue in RabbitMQ
    • Create A Virtual Host in RabbitMQ
  • Test RabbitMQ From Mule
    • Publish a message in RabbitMQ
    • Test the mule-3.9 app
    • RabbitMQ Test Project in Mule-3.9

Install RabbitMQ

Here is the quick installation guideline for Ubuntu 18.04
Step 1: Install Erlang
RabbitMQ needs Erlang to run. To install the latest version of Erlang, add the repository below
sudo sh -c 'echo "deb https://packages.erlang-solutions.com/ubuntu $(lsb_release -sc) contrib" >> /etc/apt/sources.list.d/erlang.list'

wget https://packages.erlang-solutions.com/ubuntu/erlang_solutions.asc
sudo apt-key add erlang_solutions.asc

sudo apt update
sudo apt install erlang
Step 2: Install RabbitMQ
Add RabbitMQ Repository, Add Repository Key, Install RabbitMQ and Enable on Startup. 
sudo sh -c 'echo "deb https://dl.bintray.com/rabbitmq/debian $(lsb_release -sc) main" >> /etc/apt/sources.list.d/rabbitmq.list'

wget -O- https://dl.bintray.com/rabbitmq/Keys/rabbitmq-release-signing-key.asc | sudo apt-key add -
wget -O- https://www.rabbitmq.com/rabbitmq-release-signing-key.asc | sudo apt-key add -

sudo apt update
sudo apt install rabbitmq-server

sudo systemctl enable rabbitmq-server
sudo systemctl start rabbitmq-server
For other Operating Systems please see the links below:

Enable RabbitMQ Web Console

RabbitMQ provides a web console to manage it easily. To enable the console, run the commands below
sudo rabbitmq-plugins enable rabbitmq_management
After that, open your browser and browse to the server name or IP address followed by port # 15672
You should see RabbitMQ web management console to logon. The default username and password is guest.
Username: guest
Password:  guest
RabbitMQ Login Page
RabbitMQ Overview Page
Start RabbitMQ Service in Windows
In windows system the RabbitMQ Service starts automatically. If not then you need to start it manually after installation
as like the image below. Then enable RabbitMQ Management console as shown in the following CLI.

Setting up Mule

Now open AnypointStudio and enter the AnyPointStudio Exchange Login Page.
Login and install AMQP connector mule component. 
Create New Mule App and Design Flow
Now create a new Mule project and add the following components to Mule flow:
Add AMQP-0-9 Connector Global Element
Add a AMQP-0-9 Connector Global Element to the mule flow with following properties
Create A Queue in RabbitMQ
Logon to RabbitMQ Web-console with guest user and create a queue with name "queue" 
Create A Virtual Host in RabbitMQ
Create a vhost with name "/test"
Set up logger log message and run the project.

Test RabbitMQ From Mule

Publish a message in RabbitMQ
Now publish a message in the queue named queue 
Test the mule-3.9 app
Check mule console log to check the output
RabbitMQ Test Project in Mule-3.9
For your convenience the sample mule-3.9 project has been attached below
RabbitMQ Test App using Mule-3.9

ActiveMQ - How to setup and run from Mule 3.9

  • Install ActiveMQ
    • Step 1: Download Apache Active MQ 5.x.x (5.15.8 Latest Version Up to Feb 2019)
    • Step 2: Install ActiveMQ
    • Run the Active MQ server(Run the command from any directory)
  • Enable ActiveMQ Web Console
    • Testing the Installation
    • Monitoring ActiveMQ
    • ActiveMQ Overview Page
  • Setting up & running Mule App with JMS Connector using Active MQ Service
    • Create New Mule App and Design Flow Active MQ with JMS
    • Adding the Maven Dependency in POM
    • Create A Queue in Active MQ
  • Test Active MQ From Mule
    • Enqueue the message in Active MQ  named bjit
    • Test the mule-3.9 app
    • Active MQ Test Project in Mule-3.9

Install ActiveMQ

Here is the quick installation guideline for Ubuntu 16.04 LTS
Step 1: Download Apache Active MQ 5.x.x (5.15.8 Latest Version Up to Feb 2019)
Step 2: Install ActiveMQ
Extract the Archive
sudo tar -zxvf apache-activemq-5.15.8-bin.tar.gz
Move to the activemq extracted folder
cd apache-activemq-5.15.8
Give permission to the executable  
chmod 755 activemq
Add the Environment Variable to the PATH
export ACTIVEMQ_HOME=/home/path-to-the-file-location/apache-activemq-5.15.8
export PATH=$PATH:$ACTIVEMQ_HOME/bin
Run the Active MQ server(Run the command from any directory)
command for start the server
activemq start
 
command for check status the server
activemq status
command for restart the server
activemq restart
For other Operating Systems please see the links below:
Installing oMac/Unix

Enable ActiveMQ Web Console

ActiveMQ provides a web console to manage it easily. To enable the console, run the commands below
activemq console
Testing the Installation
ActiveMQ's default port is 61616. From another window, run netstat and search for port 61616.
Monitoring ActiveMQ
There are various ways to monitor ActiveMQ. If you are on version 4.2 or later of ActiveMQ, you can then monitor ActiveMQ, using the Web Console by pointing your browser at:
After that, open your browser and browse to the server name or IP address followed by port # 8161(Jetty proxy)
You should see the ActiveMQ web management console to logon. The default username and password is the admin.
Username: admin
Password:  admin
ActiveMQ Overview Page

Setting up & running Mule App with JMS Connector using Active MQ Service

Create New Mule App and Design Flow Active MQ with JMS
Now create a new Mule project and add the following components to Mule flow:
Configure JMS Connector as ActiveMQ and broker url, user name , password






Adding the Maven Dependency in POM
<dependency>
  <groupId>org.apache.activemq</groupId>
  <artifactId>activemq-all</artifactId>
  <version>5.15.8</version>
</dependency>

Create A Queue in Active MQ
Login to ActiveMQ Web-console with admin user and create a queue with name "bjit" 
Sent The message 'Hello' to the JMS consumer
Now set the JMS Connector queue name as "bjit" to consume the queue messages
Set up the logger message and run the project.

Test Active MQ From Mule

Enqueue the message in Active MQ  named bjit
Test the mule-3.9 app
Check mule console log to check the output
Active MQ Test Project in Mule-3.9
For your convenience, the sample mule-3.9 project has been attached below
ActiveMQ Test App using Mule-3.9







5 Strategies for Getting More Work Done in Less Time

Summary.    You’ve got more to do than could possibly get done with your current work style. You’ve prioritized. You’ve planned. You’ve dele...