ActiveMQ of message Middleware
First, brief introduction
ActiveMQ is an excellent JMS implementation framework, which has the advantages of simple, convenient and good performance in asynchronous message communication.
Second, installation
Download address: http://mirror.bit.edu.cn/apache/activemq/
Just decompress it.
Three, start
Windows start
Linux start
Fourth, java application
Dependent package: activemq-all-5.12.0.jar
Send a message:
/ / construct the ConnectionFactory instance object, here using the implementation of ActiveMq jarConnectionFactory connectionFactory = new ActiveMQConnectionFactory (ActiveMQConnection.DEFAULT_USER,ActiveMQConnection.DEFAULT_PASSWORD, "tcp://localhost:61616"); / / construct the connection object Connection connection = connectionFactory.createConnection () from the factory; / / start connection.start (); / / get the operation connection Session session = connection.createSession (Boolean.TRUE,Session.AUTO_ACKNOWLEDGE); Destination destination = session.createQueue ("FirstQueue") / / get the message generator [sender] MessageProducer producer = session.createProducer (destination); / / set non-persistence. Learn here and actually decide producer.setDeliveryMode (DeliveryMode.NON_PERSISTENT) according to the project.
To this producer object generation, the next step is to send data
/ / create message TextMessage message = session.createTextMessage ("message sent by ActiveMq"); / / send producer.send (message)
Consumers accept data
Create a connection as above
`/ / message consumer object
MessageConsumer consumer = session.createConsumer (destination)
/ / receive messages
TextMessage message = (TextMessage) consumer.receive (100000)
`
Fifth, message management
Built-in management: http://127.0.0.1:8161/admin/
Username password: default username password admin,admin
Set up
The main menus on the management page are: 1 ActiveMq home: current ActiveMq information, name, id, version, etc. 2 focus queues: queues running in the current message, as well as the number of producers, consumers, and queuing messages in the queue, etc.