1. Introduction to ActiveMQ First analyze such a scenario: when we shop on the website, we must go through, place an order, create an invoice, process payment, fulfill an order, shipping, etc. However, when a user places an order, they are immediately redirected to the "Thank You for Your Order" page. Not only that, but if there is no delay, the user will also receive an email. If we use the traditional way to implement, it is generally to operate the database, and then call various interfaces, various services to wait for various responses, so that it takes a long time to see the result of the next order, if there is a problem in a certain link, then the order result will not be visible for a while, for modern e-commerce, this is intolerable. Then ActiveMQ can solve this problem very well: when the user places an order, there is a call to ActiveMQ to submit the order, and then the system can return to the result page, and the entire order process will not be called synchronously, and the background JOB can be chatted and running. If the front desk order volume is large, each order only needs to be called once, and the background office can't handle it all at once? Take your time, no one is forcing you, orders are waiting in line in ActiveMQ, they won't be irritated. This scenario is ideal for a kind of cache queue, called a message queue, which many products can implement, and by the way, answers the next potential question: it is much faster than a database. This article starts from the basics and learns together, the system operating environment of this article: Window7 32-bit 2. Download the ActiveMQ official website download address: http://activemq.apache.org/ 3.运行ActiveMQ解压缩apache-activemq-5.10.0-bin.zip,然后双击apache-activemq-5.10.0inwin32activemq.bat运行ActiveMQ程序。 See the last line of the console output: "access to all MBeans is allowed" to prove that the startup was successful. After starting ActiveMQ, you can log in using the browser to log in: http://localhost:8161/admin/ authentication, the default username is admin, and the password is admin (Premise is that the Java environment is installed) Download the .NET version of the Dll:Apache.NMS-1.6.0-bin.zip and Apache.NMS.ActiveMQ-1.6.4-bin.zip at the same time Download all from here:http://archive.apache.org/dist/activemq/apache-nms/1.6.0/ 3. The first ActiveMQ example uses C# to write a source of information, i.e. the producer: The interface is very simple, a Lable, a TextBox, a Button, then add Apache.NMS.dll and Apache.NMS.ActiveMQ.dll references, find them in the other 2 download packages above, pay attention to the version number.
You can click the button to send some messages, and these messages will be temporarily stored in ActiveMQ, and you can log in to the webpage where you just asked for a password to view it.
Then write the receiver, that is, the consumer: Also add references to those 2 DLLs, the interface is very simple with only one Lable:
As soon as you start it, you will find that these messages have been received here, and the server-side ones have been deleted.
4. Summary The above implements a P2P message queue, which is temporarily stored in and waited for processing, and the message is gone after processing, ensuring delivery, not lost, and not dropped. This mode can only be used in limited occasions, and the customer can only have one, which belongs to the form of express delivery, and cannot meet the order processing requirements, the reason is very simple: the blacklist inspection link obtains this order information, and the review link cannot be obtained, and the next section we learn "message group sending" together, that is, shout, the order is coming, everyone starts to get busy...
Note: The article is reprinted, and the article message. Properties.SetString("filter","demo"); This does not need to be set up!!!
|