Chapter 2 Introduction to Message Queue As shown in the figure, a Message Queue client uses the Java or C API to send or receive a message" /> Chapter 2 Introduction to Message Queue As shown in the figure, a Message Queue client uses the Java or C API to send or receive a message" />
HomeĐời SốngMessage queue là gì

Message queue là gì

13:32, 05/04/2021
l version="1.0" encoding="ISO-8859-1"?> Chapter 2 Introduction to lớn Message Queue


As shown in the figure, a Message Queue client uses the Java or C API lớn send or receive sầu a message. These APIs are implemented in a Java or C-client runtime library, which does the actual work of creating connections to the broker và packaging the bits appropriately for the connection service requested. If the application uses administered objects, the client runtime locates these objects in an object store và uses them to lớn configure the connection và to locate physical destinations. The broker routes & delivers the message. An administrator uses Message Queue administrative sầu tools to manage the broker & lớn add administered objects khổng lồ the object store.

Bạn đang xem: Message queue là gì

Each of these elements is described briefly in the following sections.

Message Server

The message hệ thống is composed of one or more brokers và performs message routing and delivery. It is the heart of the Message Queue service.

The message server consists of a single broker or a set of brokers working together (as a broker cluster) to perform message routing and delivery services. The broker is a process that performs the following tasks:

For a detailed mô tả tìm kiếm of the message VPS, its internal components, và the functions they perkhung, see Chapter 4, "Message Server".

Message Queue Enterprise Edition supports the use of broker clusters, consisting of multiple interconnected broker instances, allowing a message VPS to lớn scale with the volume of message traffic. For a description of architecture và cluster configuration issues, see Chapter 5, "Broker Clusters."

Client Runtime

The Message Queue client runtime provides client applications with an interface khổng lồ the Message Queue service. The client runtime supports all operations needed for Message Queue clients to produce messages (sover them khổng lồ destinations) và khổng lồ consume messages (retrieve them from destinations).

There are two language implementations of the Message Queue client runtime, as shown in Figure 2-1:

Java client runtime. Supplies Java client applications and components with all the objects needed khổng lồ implement the JMS API và lớn interact with the Message Queue message VPS. These interface objects include connections, sessions, messages, message producers, & message consumers.
C client runtime. Supplies C client applications & components with the C programming interfaces needed lớn interact with the Message Queue hệ thống. (The C client runtime supports a procedural version of the JMS API messaging Mã Sản Phẩm.)

Figure 2-2 illustrates the central role played by the client runtime between Message Queue clients and the message server. Message production & consumption involve sầu an interaction between clients & the client runtime, while message delivery is an interaction between the client runtime and the message server.

Figure 2-2  Client Runtime and Messaging Operations


The client runtime performs the following functions:

Manages message delivery to lớn the message VPS.

The following subsections briefly describe client runtime functions. Some aspects of the behavior of the client runtime can be customized by configuring the properties of the connection factory object.

Connection Handling

To configure connection handling behavior you must specify the host name & port of the broker to lớn which the client wants lớn connect & the type of connection service desired. If the connection is made khổng lồ a broker that is part of a cluster, you must specify a list of addresses to lớn which to make a connection. If one broker is not online, the client runtime can connect you khổng lồ another broker in the cluster.

In the Enterprise Edition, the client runtime can automatically reconnect lớn a broker if a connection fails. The reconnection can be khổng lồ the same broker, or lớn a broker different from the original connection if the client is connected khổng lồ a broker that is part of a cluster.

If broker instances vị not use a shared, highly available persistent store (as could be achieved through integration of Message Queue with Sun Cluster), persistent messages và other state information held by the failed (or disconnected) broker can be lost if a reconnect is lớn a different broker instance. That is khổng lồ say, reconnection provides connection failover but not data availability.

Client Identification

A client ID can be phối on any connection if an application finds it useful; it must be mix to lớn identify durable subscribers.

To keep trachồng of durable subscriptions, the broker uses a quality client identification. The client ID is used to identify a durable subscriber that is inactive at the time that messages are delivered lớn a topic destination. The broker retains messages addressed to such subscribers & makes them available when the subscriber becomes active sầu.

Therefore, a client identifier must be phối whenever using durable subscriptions in deployed applications. A Message Queue feature allows you khổng lồ use a special variable name syntax when you specify the Client ID. This makes it possible to obtain a different client ID for each connection obtained from a connection factory object, whether that object is created by an administrator or programmatically. For more information, see the Message Queue Administration Guide.

Message Distribution lớn Consumers

Messages delivered by a broker over a connection are received by the client runtime & distributed to lớn the appropriate Message Queue sessions, where they are queued up khổng lồ be consumed by their respective message consumers, as shown in Figure 2-3.

Figure 2-3  Message Delivery to lớn Message Queue Client Runtime


Messages are fetched off each session queue one at a time & consumed either synchronously (by a client thread invoking the receive() method) or asynchronously (by the session thread invoking the onMessage() method of a message listener object). (A session is single threaded.)

The flow of messages delivered khổng lồ the client runtime is metered at a per consumer màn chơi. By appropriately adjusting connection factory properties, you can balance the flow of messages so that messages delivered lớn one session vì not adversely affect the delivery of messages lớn other sessions on the same connection.

Ensuring Reliable Message Delivery

The client runtime has an important role in ensuring reliable delivery of messages. It supports the client acknowledgement và transaction modes of the JMS specification & controls the various broker acknowledgement behaviors used to guarantee reliable delivery.

The JMS specification describes a number of client acknowledgement modes that provide for different levels of reliability. These acknowledgement modes, and additional modes implemented by Message Queue, are described in the context of message consumption (see Client Acknowledgements).

In the case of persistent messages và reliable delivery, the broker normally acknowledges lớn the client runtime when it has completed operations used lớn ensure once và only once consumption of messages. You can use connection factory properties lớn suppress such broker acknowledgements, thereby saving on network bandwidth & processing. Of course, such suppression of broker acknowledgements, eliminates guarantees of reliable delivery.

Message Flow Control

The client runtime is the gatekeeper for the flow of messages across a connection. In addition lớn the regular JMS payload messages that flow across a connection, Message Queue also sends a variety of control messages that are used lớn guarantee reliable delivery, manage the flow of messages across a connection, và perkhung other control functions.

Since payload messages and control messages compete for the same connection, they can collide, causing logjams lớn occur. The client runtime enforces various configurable flow limits & metering schemes to lớn minimize the collision of payload & control messages, & thereby maximize message throughput.

Overriding Message Header Values

The client runtime can override JMS message header fields that specify the persistence, lifetime, và priority of messages.

Message Queue allows message header overrides at the level of a connection: overrides apply khổng lồ all messages produced in the context of a given connection.

The ability of the client runtime to lớn override message header values gives a Message Queue administrator more control over the resources of a message VPS. Overriding these fields, however, has the risk of interfering with application-specific requirements (for example, message persistence). So this capability should be used only in consultation with the appropriate application users or designers.

Other Functions

The client runtime performs a few other assorted functions:

Queue browsing characteristics. The client runtime can be configured for the number of messages it will retrieve at one time, and the time that it will wait for messages, when browsing the contents of a queue destination.
Message compression. The Java client runtime can compress messages during message production và decompress messages during message consumption. Whether or not such compression or decompression occurs depends on a Message Queue-specific message property phối in the message header when the message is created by the client.

Administered Objects

Administered objects encapsulate provider-specific implementation and configuration information about connections and destinations. Administered objects can be created programmatically, or they can be are created & configured using administrator tools, stored in an object store, & accessed by client applications through standard JNDI lookup code.

Message Queue provides the administered object types shown in the following table.

Table 2-1  Message Queue Administered Object Types 




Represents a physical destination in a broker. Contains the provider-specific name of the physical destination in the broker. Message consumer and/or message producer objects use a destination administered object lớn access the corresponding physical destination.

Connection Factory

Establishes physical connections between a client application & a Message Queue message hệ thống. Also configures the Message Queue client runtime, which controls the behavior of physical connections. When setting the attribute values of a connection factory administered object, you specify properties that apply to lớn all connections that it establishes.

XA Connection Factory

Used lớn establish physical connections that tư vấn distributed transactions (see Distributed Transactions). XA connection factory objects nội dung the same phối of attributes as regular connection factory objects, but enable the additional mechanisms needed lớn tư vấn distributed transactions.

SOAPhường Endpoint

Identifies the final destination of a SOAPhường message: this is the URL of a servlet that can receive the SOAPhường message. The SOAP endpoint administered object can be configured to lớn specify multiple URLs. Also specifies the lookup name associated with the object, & object store attributes.

Using Administered Objects via JNDI

Although the JMS specification does not require JMS clients to lớn look up administered objects in a JNDI namespace, there are distinct advantages khổng lồ doing so: it allows for a single source of control, it allows connections (client runtime behavior) lớn be configured và reconfigured without having to lớn recode, và it allows clients lớn be portable to lớn other JMS providers.

Administered objects make it easier to lớn control and manage a Message Queue service:

Administrators can specify the behavior of the client runtime by requiring client applications to lớn access preconfigured connection factory objects.
Administrators can control the proliferation of physical destinations by requiring client applications to access preconfigured destination administered objects that correspond to lớn existing physical destinations.

In other words, the use of administered objects allows a Message Queue administrator khổng lồ control message service configuration details, while at the same time allowing client applications khổng lồ be provider-independent.

Using administered objects means that client programmers vị not have to know about provider-specific syntax và object naming conventions or provider-specific configuration properties. In fact, by specifying that administered objects be read only, administrators can ensure that client applications cannot change administered object attribute values that were set when the administered object was first created.

While it is possible for client applications lớn instantiate both connection factory and destination administered objects on their own, this practice undermines the basic purpose of an administered object. Message Queue administrators need to control broker resources required by an application and to tune messaging performance. In addition, directly instantiating administered objects makes client applications provider-dependent.

Notwithstanding these arguments, applications often instantiate administered objects in development environments in which administrative control is not an issue.

Object Stores

Message Queue administered objects are placed in an object store (see Figure 2-1) where they can be accessed by client applications through a JNDI lookup. Message Queue supports two types of object store: a standard LDAP directory server and a file-system object store.

LDAPhường Server Object Store    An LDAPhường. hệ thống is the recommended object store for production messaging systems. LDAP.. implementations are available from a number of vendors & are designed for use in distributed systems. LDAPhường servers also provide security features that are useful in production environments.

File-system Object Store    Message Queue supports a file-system object store, which is not recommended for production systems but has the advantage of being very easy to use in development environments. Rather than setting up an LDAPhường. hệ thống, all you have lớn vày is create a directory on your local tệp tin system. A file-system object store, however, cannot be used as a centralized object store for clients deployed across multiple computer nodes unless these clients have sầu access lớn the directory where the object store resides.

Administration Tools

Message Queue administration tools consist of a mix of commvà line utilities & a graphical user interface (GUI) Administration Console.

Comm& Line Utilities    Message Queue provides a set of comm& line utilities lớn persize all Message Queue administration tasks, such as starting up and managing a broker, creating & managing physical destinations, managing administered objects, & performing other, more specialized administrative tasks. All the commvà line utilities nội dung common formats, syntax conventions, and options. For more detailed information on the use of the comm& line utilities, see the Message Queue Administration Guide.

The Administration Console    The Console provides a submix of the capabilities of the Message Queue comm& line utilities. You can use the Administration Console khổng lồ manage a broker, create and manage physical destinations, và manage administered objects. However you cannot persize the more specialized tasks of some of the command line utilities. For example, you cannot use the Administration Console to start up a broker, create broker clusters, or manage a user repository. These tasks must be performed using the Message Queue command line utilities.

The Message Queue Administration Guide provides a brief, hands-on tutorial khổng lồ familiarize you with the Administration Console and to lớn illustrate how you use it to lớn accomplish basic tasks.

The Administration Console and some of the command line utilities allow for remote management of brokers and physical destinations.

Product Features

The Message Queue service, & the architecture described in the previous section, fully implement the JMS 1.1 specification for reliable, asynchronous, flexible message delivery. For documentation of JMS compliance-related issues, see Appendix A, "Message Queue Implementation of Optional JMS Functionality."

However, Message Queue has capabilities & features that go far beyond the requirements of the JMS specification. These features enable Message Queue to lớn integrate systems consisting of large numbers of distributed components exchanging many thousands of messages in round-the-cloông chồng, mission-critical operations.

Message Queue’s enterprise features, discussed below, are grouped inkhổng lồ the following categories:

Integration Support Features

Message Queue allows you khổng lồ integrate disparate applications and components across an enterprise by including tư vấn for several transport protocols, a C client interface lớn the Message Queue service, support for SOAP (XML) messages, & a pluggable J2EE resource adapter.

Multiple Transport Support

Message Queue supports the ability of clients to interact with the Message Queue message server over a number of different transport protocols, including TCPhường và HTTP, and using secure connections.

HTTPhường connections    HTTPhường transport allows messages lớn be delivered through firewalls. Message Queue implements HTTPhường support using an HTTPhường. tunnel servlet that runs in a website hệ thống environment. Messages produced by a client are delivered over HTTP.. through a firewall lớn the tunnel servlet. The tunnel servlet extracts the message from an HTTPhường request & delivers the message over TCP/IP.. to lớn the broker. In a similar fashion, Message Queue supports secure HTTPhường connections using an HTTPS tunnel servlet. For more information on the architecture of HTTPhường connections, see HTTP/HTTPS Support. For information on setting up and configuring HTTP/HTTPS connections, see the Message Queue Administration Guide.

Xem thêm: Tác Dụng Của Trà Sữa Là Gì? Những Lợi Ích Bất Ngờ Từ Trà Sữa

Secure connections    Message Queue provides for secure transmission of messages based on the Secure Socket Layer (SSL) standard over TCP/IPhường. & HTTPhường transports. These SSL-based connection services allow for the encryption of messages sent between clients and broker.

SSL support is based on self-signed hệ thống certificates. Message Queue provides a utility that generates a private/public key pair & embeds the public key in a self-signed certificate. This certificate is passed to lớn any client requesting a connection lớn the broker, và the client uses the certificate to phối up an encrypted connection. For information on creating self-signed certificates to lớn enable SSL-based connections services, see the Message Queue Administration Guide.

C Client Interface

In addition to lớn supporting Java language messaging clients, Message Queue also provides a C language interface lớn the Message Queue service. The C API enables legacy C applications & C++ applications khổng lồ participate in JMS-based messaging. However, clients using Message Queue’s C API are not portable lớn other JMS providers.

Message Queue’s C API is supported by a C client runtime that supports most of the standard JMS functionality, with the exception of the following: the use of administered objects; maps, stream, or object message body types; distributed transactions; và queue browsers. The C client runtime also does not support most of Message Queue’s enterprise features.

For more information on the features of the C API and how it implements the JMS programming Model with C data types & functions, see the Message Queue Developer’s Guide for C Clients.

SOAP. (XML) Messaging Support

Message Queue supports creation và delivery of messages that conform to lớn the Simple Object Access Protocol (SOAP) specification. SOAP allows for the exchange of structured XML data, or SOAP. messages, between peers in a decentralized, distributed environment. A SOAPhường message is an XML document that can also contain an attachment, which does not have sầu khổng lồ be in XML.

The fact that SOAP. messages are encoded in XML makes SOAP messages platkhung independent. They can be used to access data from legacy systems và cốt truyện data between enterprises. The data integration offered by XML also makes this technology a natural for Web-based computing, such as Web services. Firewalls can recognize SOAP. packets & can filter messages based on information exposed in the SOAP. message header.

Message Queue implements the SOAPhường with Attachments API for Java (SAAJ) specification. SAAJ is an application programming interface that can be implemented khổng lồ support a programming Model for SOAP messaging and to lớn furnish Java objects that you can use khổng lồ construct, sover, receive, và examine SOAP messages. SAAJ defines two packages:

javax.xml.soap: You use the objects in this package khổng lồ define the parts of a SOAPhường message & to lớn assemble & disassemble SOAP messages. You can also use this package lớn sover a SOAP.. message without the support of a provider.
javax.xml.messaging: You use the objects in this package to lớn send a SOAP message using a provider & to lớn receive sầu SOAPhường messages.

Message Queue provides utilities to lớn transform SOAPhường messages inlớn JMS messages and vice versa. These utilities allow SOAP messages to be received by a servlet, transformed into a JMS message, delivered by the Message Queue service to a JMS consumer, transformed back inlớn a SOAP.. message, and delivered khổng lồ a SOAP endpoint. In other words, Message Queue supports the ability khổng lồ reliably and asynchronously exchange SOAPhường messages between SOAP endpoints or, more simply, to lớn publish SOAPhường messages to lớn Message Queue subscribers.

For additional information, see the Message Queue Developer’s Guide for Java Clients.

J2EE Resource Adapter

The Java 2 Platkhung, Enterprise Edition (J2EE platform) is a specification for a distributed component model in a Java programming environment. One of the requirements of the J2EE platsize is that distributed components be able lớn interact with one another through reliable, asynchronous message exchange. In short, the J2EE platsize requires JMS support.

This tư vấn is provided in the J2EE programming Model using the message-driven bean (MDB), a specialized type of Enterprise Java Bean (EJB) component that can consume JMS messages. A J2EE-compliant application VPS must provide an MDB container that supports JMS messaging. This can be achieved by plugging-in a JMS resource adapter into the application VPS. Message Queue provides such a resource adapter.

By plugging the Message Queue resource adapter into lớn an application VPS, J2EE components, including MDBs, deployed and running in the application VPS environment can exchange JMS messages aý muốn themselves và with external JMS components. This provides a powerful integration capability for distributed components.

For information on the Message Queue resource adapter, see Chapter 6, "Message Queue and J2EE."

Security Features

Protecting stored & in-transit message data is critical for most enterprise applications. Message Queue provides security at many levels, including authentication of users, controlled access lớn resources, và message encryption.

Authentication    Message Queue supports password-based authentication of users. Connections khổng lồ the message VPS are granted to users based on passwords stored in a flat tệp tin or LDAP user repository. Information about all connection attempts (users và host computers) is logged and can be tracked.

Authorization    Access control lists (ACLs) provide configurable, fine-grained control over access to a broker’s connections và physical destinations. Both user & group access is supported. Authorization is performed on a broker-by-broker basis; each broker can have a different access control file.

Encryption    SSL tư vấn allows all message traffic between a message hệ thống and its clients (whether over TCP/IPhường or HTTP.. connections) to lớn be encrypted using a full-strength SSL implementation.

For information on populating a user repository, managing access control lists, and setting up SSL support, see the Message Queue Administration Guide.

Scalability Features

Message Queue allows you to scale your application as users, client connections, and message loads grow.

Scalable Connection Capathành phố

The Message Queue broker can handle thousands of concurrent connections. By default, each connection is handled by a dedicated broker thread. Because this ties up the thread even when the connection is idle, you can configure the connection service so that multiple connections can cốt truyện the same thread. This shared threadpool Model can dramatically expvà the number of connections that a broker can tư vấn. For more information, see Thread Pool Manager.

Broker Clusters

As the number of connections and the number of messages being delivered through a broker increases, the extra load can be managed by adding additional broker instances lớn the Message Queue server. Broker clusters balance client connections and message delivery across a number of broker instances, making the message VPS highly scalable. The broker instances can be on the same host or distributed across a network. Clustering is an igiảm giá khuyến mãi way to improve message throughput và exp& messaging bandwidth as business needs grow. Broker clusters are introduced in Chapter 5, "Broker Clusters" & discussed more fully in Message Queue Administration Guide.

Queue Delivery khổng lồ Multiple Consumers

According khổng lồ the JMS specification, a message in a queue destination can be delivered only to lớn a single consumer. Message Queue allows multiple consumers to lớn register with a queue. The broker can then distribute messages to lớn the different registered consumers, balancing the load aý muốn them and allowing the system to lớn scale.

The implementation of queue delivery to multiple consumers uses a configurable load-balancing approach. Using this approach, you can specify the maximum number of active sầu consumers and the maximum number of backup consumers standing by to lớn take the place of active sầu consumers should any fail. In addition, the load-balancing mechanism takes into lớn tài khoản a consumer’s current capacity & message processing rate.

For more information on load-balanced queue delivery, see Queue Delivery to Multiple Consumers.

Availability Features

Message Queue provides a number of features for minimizing service downtime. These range from mechanisms for preventing failure to lớn those that allow integration with Sun Cluster to lớn provide high availability.

Message Service Stability

One of the most effective sầu ways of ensuring availability of a message service is khổng lồ provide a service that offers high performance & minimizes failure. Message Queue provides mechanisms for averting memory overloads or performance logjams. These operate on both the message hệ thống & client runtime.

Message hệ thống resource management    Because the message hệ thống is limited in memory and CPU resources, it is possible for it lớn become overloaded to lớn the point where it becomes unresponsive or unstable. This commonly happens when the rate of message production far exceeds the rate of consumption. To avert such situations, a broker can be configured on the cấp độ of individual physical destinations and on a system-wide level lớn prevent memory overruns. For more information, see Memory Resource Management.

Client runtime message flow control    In addition, Message Queue provides mechanisms for controlling the delivery of messages khổng lồ the client runtime. You can use flow control mechanisms to lớn optimize the delivery of messages to the client runtime while preventing the client from running out of memory. For more information, see Message Flow Control.

Automatic Reconnect to lớn Message Server

Message Queue provides an automatic reconnect capability: If a connection between a message VPS & client fails, Message Queue maintains the client state while attempting to reestablish the connection. In most cases, message production and consumption will transparently resume once the connection is re-established. for more information, see Message Queue Administration Guide.

High Availability Through Sun Cluster

While Message Queue’s broker clustering provides a highly scalable message VPS, it does not currently support failover from one broker instance in a cluster khổng lồ another. However, Message Queue can be integrated with Sun Cluster software lớn provide a high-availability message hệ thống. Using a Sun Cluster agent developed for Message Queue, Sun Cluster can ensure that no state data is lost if a broker fails, allowing a message server to be restored immediately and transparently with virtually no downtime.

Manageability Features

Message Queue provides a number of features that you can use to lớn monitor & administer a message service và to tune message service performance.

Robust Administration Tools

Message Queue offers both command line & GUI tools for administering a Message Queue message VPS and for managing destinations, transactions, durable subscriptions, và security (see Administration Tools).

Message Queue also supports remote monitoring & administration of message servers as well as tools for managing JMS administered objects, user repositories, plugged-in JDBC-compliant data stores, và self-signed VPS certificates. For information on using these administration tools, see the Message Queue Administration Guide.

Message-Based Monitoring API

Message Queue provides a simple JMS-based monitoring API that you can use khổng lồ create custom monitoring applications. These monitoring applications are consumers that retrieve metrics messages from special topic destinations. The metrics messages contain monitoring data provided by the Message Queue broker (see Metrics Message Producer (Enterprise Edition)).

For details of the metrics quantities reported in each type of metrics message, see the Message Queue Developer’s Guide for Java Clients, which explains how to develop a Message Queue client for consuming metrics messages. For information about how to lớn configure the production of metrics messages, see the Message Queue Administration Guide.

Tunable Performance

Message Queue offers many ways khổng lồ tune both the message VPS & the client runtime lớn achieve sầu optimal performance. You can monitor key resources and adjust memory usage, threading resources, message flow, connection services, reliability parameters, và other elements that affect message throughput and system performance. For details about how to tune message service performance, see the Message Queue Administration Guide.

Flexible Server Configuration Features

Message Queue allows you khổng lồ choose how persistent objects, user information, và administered objects are stored.

Configurable Persistence

In order lớn guarantee delivery of messages, Message Queue stores messages và other persistent objects until messages are consumed. In addition khổng lồ providing a high performance file-based persistent store, Message Queue also supports configurable persistence. This allows you lớn store persistent messages in embedded or external JDBC-compliant databases, such as 8i. For more information, see Persistence Manager.

LDAPhường Server Support

Message Queue provides file-based storage for both administered objects and user information needed for authentication & authorization. However, Message Queue also supports using LDAP servers for administered object stores & user repositories. LDAPhường. servers provide a more secure, standard way of storing and retrieving such information, và are recommended for production systems. For information on using LDAPhường servers for administered object stores and user repositories, see the Message Queue Administration Guide.

Product Editions

Message Queue is available in two editions: Enterprise & Platform. Both editions provide a full implementation of the JMS specification, but each corresponds lớn a different feature set và licensed capacity. The feature sets are compared in the following table. For a mô tả tìm kiếm of the features, see Product Features.