Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Understanding Apache ActiveMQ

I am confused about the function of Apache ActiveMQ.

I downloaded ActiveMQ from this link. So I use it this way (environment: Windows 7): I start the bin/activemq.bat, then it works.

My question is: Does this mean I start a server on my machine? When I initialize the ActiveMQConnectionFactory, the broker URL is tcp://localhost:61616. But what if I want my machine to serve as a server and another machine to connect to my server?

like image 551
Cacheing Avatar asked Dec 03 '25 15:12

Cacheing


1 Answers

Yes, you can use the primary box as a server and have consumers/subscribers running on other boxes (which will need to connect to the server - you will need to specify the server hostname & port for the connection to be established) - once in place, the messages on the server (topic or queue) can be consumed by the clients.

If you one have one producer and one consumer, you can look into using queues - if you have more than one consumer/subscriber, you can look into setting up a topic to which the consumers will subscribe to. Messages need to be inserted to the topic/queue as needed.

You can specify the server information in your code or preferably in the config file.

For reference to topologies: http://activemq.apache.org/topologies.html

Also, you can choose to persist your messages or not based on your use case. Kaha DB is the preferred route (specially if performance is of concern).

Useful examples:

http://sujitpal.blogspot.com/2007/12/jms-patterns-with-activemq.html

http://vvratha.blogspot.com/2012/05/java-client-to-sendreceive-messages-for.html

Hope it helps.

like image 72
ali haider Avatar answered Dec 07 '25 21:12

ali haider



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!