ActiveMQ: Difference between revisions

From CLONWiki
Jump to navigation Jump to search
Boiarino (talk | contribs)
No edit summary
Boiarino (talk | contribs)
No edit summary
 
(23 intermediate revisions by the same user not shown)
Line 1: Line 1:
'''Install Apache ActiveMQ'''
'''Install Apache ActiveMQ'''


*    Download ActiveMQ from http://activemq.apache.org, both the tar file and the key file.
Download ActiveMQ tar file (for example apache-activemq-5.15.5-bin.tar.gz) from http://activemq.apache.org to /usr/downloads
*    Copied both files to /usr/local/activemq.
*    Verifying the checksum with PGP did not work on "halld-sc" computer. Ignored it for now.
*    Untared the tar-file in the /usr/local/activemq directory.
*    Go to /usr/local/activemq/apache-activemq-5.5.1 directory and start by issuing


  sudo bin/activemq start
  cd /usr/local/src
cp /usr/downloads/apache-activemq-5.15.5-bin.tar.gz .
gunzip apache-activemq-5.15.5-bin.tar.gz
tar xvf apache-activemq-5.15.5-bin.tar
rm apache-activemq-5.15.5-bin.tar
ln -s apache-activemq-5.15.5 apache-activemq
cd /usr/local/src/apache-activemq-5.15.5/bin


*  When checking the port with netstat I get
'''become superuser''' and start by issuing


  halld-sc:apache-activemq-5.5.1> netstat -an | fgrep 61616  
  ./activemq console (interactive mode)
tcp        0      0 :::61616                    :::*                        LISTEN       
./activemq start (batch mode)
 
When checking the port with netstat, getting
 
netstat -an | fgrep 61616  
    tcp        0      0 :::61616                    :::*                        LISTEN       


indicating that ActiveMQ is running.
indicating that ActiveMQ is running.
Configuration files are /usr/local/src/apache-activemq-5.15.5/bin/env and /usr/local/src/apache-activemq-5.15.5/conf/activemq.xml. In ''env'' file there is setting
ACTIVEMQ_OPTS_MEMORY="-Xms64M -Xmx4G"
where ''-Xmx'' defines maximum heap size, default is 1G, it should be increased  if memory allows.






'''Install C++ API'''
'''Install C++ API'''
Download activemq-cpp tar file (for example activemq-cpp-library-3.9.5-src.tar.gz) from http://activemq.apache.org/cms/download.html to /usr/downloads.


  cd /usr/local/src
  cd /usr/local/src
  cp /usr/downloads/activemq-cpp-library-3.8.2-src.tar .
  cp /usr/downloads/activemq-cpp-library-3.9.5-src.tar.gz .
  tar xvf activemq-cpp-library-3.8.2-src.tar
gunzip activemq-cpp-library-3.9.5-src.tar.gz
  rm activemq-cpp-library-3.8.2-src.tar
  tar xvf activemq-cpp-library-3.9.5-src.tar
  cd activemq-cpp-library-3.8.2-src
  rm activemq-cpp-library-3.9.5-src.tar
  ./configure
  cd activemq-cpp-library-3.9.5
./configure --prefix=/usr/local/activemq
  ###./configure --prefix=/usr/local  (or ./configure CC=/apps/gcc/8.3.0/bin/gcc CXX=/apps/gcc/8.3.0/bin/g++ --prefix=/usr/local)
  make
  make
make install
'''Running C++ example'''
Go to /usr/local/src/activemq-cpp-library-3.9.5-src. Modify src/examples/main.cpp file setting hostname where ActiveMQ broker is running, line
"failover:(tcp://localhost:61616".
Type 'make', the run it:
./src/examples/example
It will print messages like 'Message #1993 Received: Hello world! from thread 140724062602600' and in the end 'Time to completion = 0.178 seconds.'.
'''NOTE1:''' on RHEL5/CentOS5 apr-1.4.8.tar.gz was installed by commands './configure --prefix=/usr/local', 'make', 'make install'
'''NOTE2:''' on RHEL5/CentOS5 openssl-1.0.1e.tar.gz was installed by commands './config --prefix=/usr/local', 'make', 'make install'
'''Running Java example'''
Make sure [[maven]] installed.
Become root, assume bash. Go to example directory:
cd /usr/local/src/apache-activemq/examples/amqp/java
Add 'true' line into following section of ''pom.xml'' file.
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-compiler-plugin</artifactId>
  <version>2.1</version>
  <configuration>
    <fork>true</fork>     
    <source>1.6</source>
    <target>1.6</target>
  </configuration>
</plugin>
Run command
/apps/maven/bin/mvn install
Set following environment (in last line specify server where activemq server is running):
export ACTIVEMQ_USER=admin
export ACTIVEMQ_PASSWORD=PASSWORD
export ACTIVEMQ_HOST=clondb1
In separate xterm, run Listener:
java -cp target/amqp-example-0.1-SNAPSHOT.jar example.Listener
In separate xterm, run Publisher:
java -cp target/amqp-example-0.1-SNAPSHOT.jar example.Publisher
You should see following in Publisher xterm:
Sent 1000 messages
Sent 2000 messages
Sent 3000 messages
Sent 4000 messages
Sent 5000 messages
Sent 6000 messages
Sent 7000 messages
Sent 8000 messages
Sent 9000 messages
Sent 10000 messages


'''NOTE:''' on RHEL5/CentOS5 do ./configure --with-openssl=/usr/local/ssl --with-apr=/usr/local/apr
And following will be in Listener xterm:


'''NOTE:''' on RHEL5/CentOS5 apr-1.4.8.tar.gz was installed by commands './configure --prefix=/usr/local', 'make', 'make install'
Waiting for messages...
Received 1000 messages.
Received 2000 messages.
Received 3000 messages.
Received 4000 messages.
Received 5000 messages.
Received 6000 messages.
Received 7000 messages.
Received 8000 messages.
Received 9000 messages.
Received 10000 messages.
Received 10001 in 0.85 seconds

Latest revision as of 15:11, 15 September 2021

Install Apache ActiveMQ

Download ActiveMQ tar file (for example apache-activemq-5.15.5-bin.tar.gz) from http://activemq.apache.org to /usr/downloads

cd /usr/local/src
cp /usr/downloads/apache-activemq-5.15.5-bin.tar.gz .
gunzip apache-activemq-5.15.5-bin.tar.gz
tar xvf apache-activemq-5.15.5-bin.tar
rm apache-activemq-5.15.5-bin.tar
ln -s apache-activemq-5.15.5 apache-activemq
cd /usr/local/src/apache-activemq-5.15.5/bin

become superuser and start by issuing

./activemq console (interactive mode)
./activemq start (batch mode)

When checking the port with netstat, getting

netstat -an | fgrep 61616 
   tcp        0      0 :::61616                    :::*                        LISTEN      

indicating that ActiveMQ is running.

Configuration files are /usr/local/src/apache-activemq-5.15.5/bin/env and /usr/local/src/apache-activemq-5.15.5/conf/activemq.xml. In env file there is setting

ACTIVEMQ_OPTS_MEMORY="-Xms64M -Xmx4G"

where -Xmx defines maximum heap size, default is 1G, it should be increased if memory allows.


Install C++ API

Download activemq-cpp tar file (for example activemq-cpp-library-3.9.5-src.tar.gz) from http://activemq.apache.org/cms/download.html to /usr/downloads.

cd /usr/local/src
cp /usr/downloads/activemq-cpp-library-3.9.5-src.tar.gz .
gunzip activemq-cpp-library-3.9.5-src.tar.gz
tar xvf activemq-cpp-library-3.9.5-src.tar
rm activemq-cpp-library-3.9.5-src.tar
cd activemq-cpp-library-3.9.5
./configure --prefix=/usr/local/activemq
###./configure --prefix=/usr/local  (or ./configure CC=/apps/gcc/8.3.0/bin/gcc CXX=/apps/gcc/8.3.0/bin/g++ --prefix=/usr/local)
make
make install


Running C++ example

Go to /usr/local/src/activemq-cpp-library-3.9.5-src. Modify src/examples/main.cpp file setting hostname where ActiveMQ broker is running, line

"failover:(tcp://localhost:61616".

Type 'make', the run it:

./src/examples/example

It will print messages like 'Message #1993 Received: Hello world! from thread 140724062602600' and in the end 'Time to completion = 0.178 seconds.'.


NOTE1: on RHEL5/CentOS5 apr-1.4.8.tar.gz was installed by commands './configure --prefix=/usr/local', 'make', 'make install'

NOTE2: on RHEL5/CentOS5 openssl-1.0.1e.tar.gz was installed by commands './config --prefix=/usr/local', 'make', 'make install'


Running Java example

Make sure maven installed.

Become root, assume bash. Go to example directory:

cd /usr/local/src/apache-activemq/examples/amqp/java

Add 'true' line into following section of pom.xml file.

<plugin>

 <groupId>org.apache.maven.plugins</groupId>
 <artifactId>maven-compiler-plugin</artifactId>
 <version>2.1</version>
 <configuration>
   <fork>true</fork>       
   <source>1.6</source>
   <target>1.6</target>
 </configuration>

</plugin>

Run command

/apps/maven/bin/mvn install

Set following environment (in last line specify server where activemq server is running):

export ACTIVEMQ_USER=admin
export ACTIVEMQ_PASSWORD=PASSWORD
export ACTIVEMQ_HOST=clondb1

In separate xterm, run Listener:

java -cp target/amqp-example-0.1-SNAPSHOT.jar example.Listener

In separate xterm, run Publisher:

java -cp target/amqp-example-0.1-SNAPSHOT.jar example.Publisher

You should see following in Publisher xterm:

Sent 1000 messages
Sent 2000 messages
Sent 3000 messages
Sent 4000 messages
Sent 5000 messages
Sent 6000 messages
Sent 7000 messages
Sent 8000 messages
Sent 9000 messages
Sent 10000 messages

And following will be in Listener xterm:

Waiting for messages...
Received 1000 messages.
Received 2000 messages.
Received 3000 messages.
Received 4000 messages.
Received 5000 messages.
Received 6000 messages.
Received 7000 messages.
Received 8000 messages.
Received 9000 messages.
Received 10000 messages.
Received 10001 in 0.85 seconds