Install activemq locally
Download gzip'd tar'd file from one of the mirror siteseg.
wget http://mirror.vorboss.net/apache/activemq/5.9.1/apache-activemq-5.9.1-bin.tar.gz
tar zxvf apache-activemq-5.9.1-bin.tar.gz
cd apache-activemq-5.9.1/bin
chmod 755 activemq
Start activemq
./activemq startCheck it is running:
netstat -an|grep 61616
You can go to the admin console in a web browser:
http://localhost:8161/admin/
Default username and password is admin/admin.
Create JMS project
I created a maven project from the command line:mvn archetype:generate -DgroupId=com.ojha.play -DartifactId=activemq -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
In the pom I added a dependency on active mq:
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-all</artifactId>
<version>5.9.0</version>
</dependency>
Implement producer and consumer
Producer:
Consumer:
I ran the producer and checked the console in the web browser to see the message:
Then ran the consumer to dequeue the message.
No comments:
Post a Comment