Apache Active MQ

Omiiz Voice - Sep 12 - - Dev Community

ActiveMQ and Tomcat Setup

  1. Launch Instance with Volumes
  2. Launch an EC2 instance with two EBS volumes.
  3. Mount the secondary volume to /opt.
  4. Install ActiveMQ and mysql-connector
  5. Download the ActiveMQ package from the official website: wget https://www.apache.org/dyn/closer.cgi?filename=/activemq/6.1.3/apache-activemq-6.1.3-bin.tar.gz&action=download
    • Extract the tar file into the /opt directory: tar -xzf apache-activemq-6.1.3-bin.tar.gz -C /opt
  6. Download the mysql-connector and extract it. wget https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-j-9.0.0.tar.gz tar -xzvf mysql-connector-j-9.0.0.tar.gz
  7. Configure ActiveMQ
  8. Update the ActiveMQ configuration file: vim /opt/apache-activemq-6.1.3/conf/activemq.xml
    • Modify the following: • Change the broker name • Change the PersistenceAdapter block with jdbc to use mysql as its database. • Remove all the transportConnector expect the openwire.




• Add this lines at the end of file before








  1. Update Jetty Configuration
    • Edit the Jetty configuration file and modify the host as follows: vim /opt/apache-activemq-6.1.3/conf/jetty.xml
    • Change the line:
    • Create ActiveMQ Service
    • Create a systemd service file for ActiveMQ: vim /etc/systemd/system/activemq.service
    • Content of the service file: [Unit] Description=Apache ActiveMQ Message Broker After=network-online.target

[Service]
Type=forking
User=activemq
Group=activemq
WorkingDirectory=/opt/apache-activemq-6.1.3/bin
ExecStart=/opt/apache-activemq-6.1.3/bin/activemq start
ExecStop=/opt/apache-activemq-6.1.3/bin/activemq stop
Restart=on-abort

[Install]
WantedBy=multi-user.target

  • Enable and start the ActiveMQ service: systemctl enable activemq.service systemctl start activemq.service
    1. Install Java
    2. Install Java 22 and Java 8: yum install java java-1.8.0 -y
  • Create a symbolic link for Java 8: ln -s /usr/lib/jvm/java-1.8.0-amazon-corretto.aarch64/jre/bin/java /usr/bin/java8
    1. Install Tomcat 9
    2. Download Tomcat 9 from the official website: wget https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.93/bin/apache-tomcat-9.0.93.tar.gz
  • Extract the tar file into the /opt directory: tar -xzf apache-tomcat-9.0.93.tar.gz -C /opt
    • Rename the extracted directory: mv /opt/apache-tomcat-9.0.93 /opt/notification_tomcat
    • Configure Tomcat
    • Edit the catalina.sh file: vim /opt/notification_tomcat/bin/catalina.sh
    • Add the following configuration: JAVA_HOME="/usr/lib/jvm/java-1.8.0-amazon-corretto.aarch64/jre/" CATALINA_OPTS="-Xmx512m -Xss256m -Xms256m -XX:PermSize=256m -XX:MaxPermSize=512m -XX:NewSize=128m" JAVA_OPTS="$JVM_OPTS -Dproperties.filepath=$CATALINA_BASE/conf/learningPlatform.properties -Dexclusion.properties=$CATALINA_BASE/conf/exclusion.properties" CATALINA_OPTS="$CATALINA_OPTS -Dinstance_base=$CATALINA_BASE -Dfile.encoding=UTF-8"
  • Clean Up Tomcat
    • Delete the existing files from the webapps directory: rm -rf /opt/notification_tomcat/webapps/*
    • Migrate Application
    • Copy the notification-consumer directory from the old server to the new server's webapps directory.
    • Update Configuration Files
    • Add the learningPlatform.properties and exclusion.properties files in the conf directory: vim /opt/notification_tomcat/conf/learningPlatform.properties #Notification Consumer will connect to the below ActiveMQ notification.broker.url=failover:(tcp://test-activemq1.loudcloudsystems.com:61612,tcp://test-activemq2.loudcloudsystems.com:61612)?initialReconnectDelay=100

vim /opt/notification_tomcat/conf/exclusion.properties

to=@gail.com,@fake.com,@v.l,@qq.com

  1. Create Tomcat Service
  2. Create a systemd service file for Tomcat: vim /etc/systemd/system/tc_notification.service
    • Content of the service file: [Unit] Description=Apache Tomcat 9 Web Application Server After=network.target

[Service]
Type=forking
Environment="JAVA_HOME=/usr/bin/java8"
Environment="CATALINA_PID=/opt/notification_tomcat/temp/tomcat.pid"
Environment="CATALINA_HOME=/opt/notification_tomcat"
Environment="CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC"
ExecStart=/opt/notification_tomcat/bin/startup.sh
ExecStop=/opt/notification_tomcat/bin/shutdown.sh
User=root
Group=root
RestartSec=10
Restart=always

[Install]
WantedBy=multi-user.target

  • Enable and start the Tomcat service: systemctl enable tc_notification.service systemctl start tc_notification.service
  • Verify Setup
    • Once both services are active, verify the ActiveMQ setup by accessing the web interface: http://:8161
. . .
Terabox Video Player