Message queue compared to WebService

Source: Internet
Author: User
Tags message queue

What are the advantages of using the IBM Websphere Message Queue recently as a cross-platform communication method compared to WebService?

The Message queue belongs to a more heavyweight application,use more in standardized enterprise processes。 If the enterprise has many departments and departments have their own systems, then the integrated communication between different systems, the Message queue is a good choice.MQ is generally used as a middleware for enterprise-class IT applications, and many enterprises exist as standard IT infrastructures. Common MQ middleware on the market has IBM WebSphere Message Queue service,oracle advanced Queuing,microsoft Message Queue (MSMQ), Apache ACTIVEMQ, etc.

If using webservice, it is necessary to write a lot of webservice code, to build these webservcie, and then expose these interfaces, call each other, very troublesome. But if you use the message queue, just set up the server for this middleware, just add a different queue manager when you need it, and then you can access it as a bridge between different systems.

Long time-consuming reports, which are often encountered in the program, processing a large amount of data, may generate a report needs 5 minutes or more time, the customer can not wait online real-time, report processing is more resource-intensive, can not handle many requests at the same time, or even only allow processing of one, then use MQ. The client puts the report request and some necessary report conditions into the queue, and the report is processed by one of the other services, and then the user is sent a message (MSN message, or mail, etc.) to the user to view the report in the browser or other report browser.

Online store, after the customer orders the process, the system only need to do inventory reduction, record the consignee information and necessary logs, other must be distributed processing, transaction statistics and other processing can not be completed at the same time, then you can put the subsequent processing messages into the queue, let another (group) server to deal with, This can speed up the process of placing orders, improve the customer experience;

WebService is usually a high-real-time requirement, after the client sends a request to the server side, this is a short connection, an HTTP request, after the request is issued, the client side waits until the result is obtained. With MQ, however, because there is an area in the middle, when the request is sent, the client can continue to do something else. Wait for a period of time to go to the storage area of the middleware to see if there is a result, the result is taken out, no words will wait to see again.

MessageQueue is a great advantage in fault-tolerant processing to maintain data consistency . The example below is a good illustration of this.


Introduction

In this article, I'll introduce a new and independent Open Source Message Queue system that is entirely built I N C # and. NET Framework 3.5. DOTNETMQ is a message broker this has several features including guaranteed delivering, routing, load Balancing, Server graphs ... so on. I'll start by explaining messaging concepts and the need for message brokers. Then I'll examine what dotnetmq are and how to use it.

What is Messaging?

messaging  is A-Of asynchronous  communication of applications running on same or different machines with Reliable delivery. Programs communicate by sending packets of the data called messages to all other [1].

a message may be a string, a Byte array, an object ... etc. Typically, A sender (producer)  program creates A message and pushes it to a message queue and A receiver (consume R)  program gets the message from the queue and processes it. The sender and receiver programs dona€?t have a to being running at the same time, since messaging are an asynchronous process. This is Called loosely coupled  communication.

On the other hand, a Web Service method call (Remote method invocation) is a type of tightly coupled andsynch Ronous Communication (both applications has to be running and available during the whole communication; if the Web S Ervice is offline or a error occurs during the method call, the client application gets an exception).

Figure-1: Simplest messaging of the applications.

The figure above, and the applications communicate over a message queue in a loosely coupled manner. If the receiver consumes messages slower than the sender produces it, the message count on the queue would increase. Also, the receiver may be offline and the sender is sending messages. In this situation, the receiver gets the messages from the queue when it becomes online (when it starts and joins the Queu e).

Message Queuesis typically provided by Message Brokers. AMessage Brokeris a standalone application (service), that other applications connect to and send/receive messages. A Message Broker is responsible to store messages until a receiver receives them. A message Broker can route messages across machines to deliver a message to the destination application and can try Delive Ring the message until the receiver correctly handles it. A Message Broker is sometimes called aMessage oriented middleware(MOM) or simplyMessage Queue(MQ).

What is DOTNETMQ?

DOTNETMQ is an open source Message Broker This has several features:

  • persistent or non-persistent messaging.
  • Guaranteed Delivery of persistent messages even in a system crash.
  • Automatic and Manual routing of messages in a custom machine graph.
  • Supports Multiple Databases (MS sql Server, MySQL, SQLite, and memory-based storage for now).
  • Supports dona€?t Store, direct send style messaging.
  • Supports request/reply style messaging.
  • Easy-to-use-client library to communicate with the DOTNETMQ Message Broker.
  • Built-in framework to easily construct RMI services upon message queues.
  • Supports delivering messages to ASP. NET Web Services.
  • gui-based Management and monitoring tool.
  • Easy-to-install, manage, and use.
  • Written entirely in C # (using. NET Framework 3.5).

I preferred to the name Dotnetmq as MDS (Message Delivery System) when first creating it. Because It is designed isn't just to being a message queue, but also as a system that delivers messages directly to application S and an environment The provides a framework to build application services. I called it DOTNETMQ since it is entirely developed using. NET and the DOTNETMQ name are more memorable. So, Ita€?s original name (and internal project name) is MDS and the applications has many classes with the prefix MDS .

Why a New Message Broker?

The need for a Message Broker

First, I'll demonstrate a simple situation where a message broker is needed.

In my experiences in business life, I ' ve observed really bad and uncommon asynchronous enterprise application integration Solutions. Usually there is an application that runs in a server and performs some tasks and produces data, and then sends the result Data to another application on another server. The second application performs other tasks on the data or evaluates the result (the servers is on the same network or CO nnected over the Internet). Also, the message data must be persistent. Even if the remote application is isn't working or the network is not available, themessage must being delivered on the FIR St Chance.

Leta€?s look at the design of the figure below.

Figure-2: A bad solution to integrate applications.

application-1  and application-2  are executable Applications (or Windows services) And sender service  is a Windows service. Application-1 performs some task, produces data, and calls A   method onserver-b  to Transmit data. This Web Service inserts the data into A database table . Application-2 periodically checks the table for new incoming data rows and processes them (and deletes them from the tab Le or marks them as processed to not process the same data again).

If an error occurs during the Web service call or while processing data in the Web service, data must not being lost and must be sent later. However, Application-1 has the other tasks to does, so it can not be try to send data again and again. It simply inserts data into a database table. Another Windows service (or a thread in Application-1, if the application is runs) checks this table period Ically and tries to send data to the WEB Service until data is successfully sent.

This scenario is really reliable (messages was guaranteed to being delivered) but isn't an efficient of the Tween, applications. This solution has some very critical problems:

  • It takes a long time to develop (to code).
  • Individual coding for all message types (or remote method calls). For a new Web Service method call, you must change all the services, applications, and database tables.
  • Almost same software and structures must is developed (or copied and modified) for every similar service.
  • Testing and maintenance of too many services/applications/databases after coding.
  • Some applications and services periodically check the database even if there is no new message (if the database was not wel l Indexed and optimized, this may consume serious system resources).

Message Brokers do all this job and takes all the responsibility to deliver messages to the remote application Efficient. The same application integration using DOTNETMQ is shown in the figure below.

Figure-3: Simple messaging by using DOTNETMQ.

DOTNETMQ is a standalone Windows service this runs on both server-a and server-b. Thus, you just need-to-write code to communicate with DOTNETMQ. Using the DOTNETMQ Client Library, it is very easy and fast to connect and send/receive messages To/from the DOTNETMQ serv Ice. Application-1 Prepares the message, sets the destination, and passes the message to the DOTNETMQ Broker. DOTNETMQ brokers would deliver the message toApplication-2 in the most efficient and fastest the.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.