Amazon MQ starter kit described in AWS blog Implementing FIFO message ordering with Amazon MQ for Apache ActiveMQ
Template | Purpose |
---|---|
CF_Template_AmazonMQBroker.yaml | Sample template to provision Amazon MQ broker |
custom-broker-configuration.xml | Sample Broker Configuration File |
-
Clone or download this source code
-
Import the source code to Eclipse or IntelliJ IDEA as a Maven project
-
Build the project using Maven commands
-
This will generate a jar file with name amazon-mq-fifo-starter-kit-1.0.jar
-
Provision Amazon MQ Broker using CF_Template_AmazonMQBroker.yaml
Note: To make the set up easy, you can provision the broker in a public subnet with a security group that has inbound access from your Laptop / EC2 instance. For production deployments, check the following resources:
-
Optionally, you can use AWS Management Console to provision broker by following this AWS Blog
-
From AWS Management Console, go to Amazon MQ, select the broker, and make a note of the below values. You will need them to access Broker console and run the PoC.
- ActiveMQ Web Console URL
- OpenWire Endpoint URL
-
Configure Security Group from Broker details section on AWS Console as shown in the below screenshot.
- Find out the Public IP address of your system and follow step # 8 of Setup Instructions
- Run the program AmazonMQFIFOStarterKit with the following program arguments separated by a space
- Amazon MQ OpenWire Endpoint URL
- Amazon MQ username
- Amazon MQ password
- Number of messages to be inserted per producer
-
Go to the folder /amazon-mq-fifo-starter-kit/target and run the jar file.
java -jar amazon-mq-fifo-starter-kit-1.0.jar \ Replace_this_with_OpenWire_Endpoint_URL \ Replace_this_with_AmazonMQ_UserName \ Replace_this_with_AmazonMQ_Password \ 5000
-
Launch an EC2 instance with an IAM role that has read and write permission on DynamoDB.
-
Take the Private IP address of your EC2 instance and follow step # 8 of Setup Instructions
-
Log on to EC2 instance and do the following:
sudo yum -y install java-1.8.0-openjdk.x86_64 mkdir amazon-mq-starter-kit cd amazon-mq-starter-kit/
-
Copy the Jar file amazon-mq-fifo-starter-kit-1.0.jar from your Laptop to EC2 instance using secure copy (SCP) or PuTTY:
-
An example SCP command is below:
scp -i ec2_keypair.pem amazon-mq-fifo-starter-kit-1.0.jar ec2-user@IP_Address_of_EC2:/home/ec2-user/amazon-mq-starter-kit
-
To use PuTTY, refer Connecting to Your Linux Instance from Windows Using PuTTY
-
-
Run the Java Application
java -jar amazon-mq-fifo-starter-kit-1.0.jar \ Replace_this_with_OpenWire_Endpoint_URL \ Replace_this_with_AmazonMQ_UserName \ Replace_this_with_AmazonMQ_Password \ 5000
-
The above step generates message metrics in CSV files. Use the following command to import them back to your Laptop for analysis.
scp -i /The_Path_To/ec2_keypair.pem ec2-user@IP_Address_of_EC2:/home/ec2-user/amazon-mq-starter-kit/*.csv .
Test Case Description | Java Class |
---|---|
The driver program to execute all test cases | AmazonMQFIFOStarterKit |
Queue with 3 producers, 3 message groups, 1 consumer | FIFO_Testcase_1 |
Queue with 3 producers, 3 message groups, 2 consumers | FIFO_Testcase_2 |
Queue with 3 producers, 3 message groups, 3 consumers | FIFO_Testcase_3 |
Queue with 3 producers, 3 message groups, 4 consumers | FIFO_Testcase_4 |
Queue with 4 producers, 4 message groups, 3 consumers | FIFO_Testcase_5 |
Test Case Description | Java Class |
---|---|
Queue with 3 producers, 3 message groups, 3 consumers | FIFO_Testcase_6 |
Scenario 2b: All consumers not started at same time – mitigate consumer message distribution by closing message groups
Test Case Description | Java Class |
---|---|
Queue with 3 producers, 3 message groups, 3 consumers | FIFO_Testcase_7 |
Amazon MQ, Enterprise Messaging, Queues, FIFO, Message Ordering
This sample code is made available under the MIT-0 license. See the LICENSE file.