SCEA之路--8. Messaging

原创 2004年08月23日 23:44:00

Synchronous communication.
Synchronous communication represents a tight coupling between a sender and receiver :
• the sender and receiver must both be available – i.e. real-time communication
• the sender will block until the response is available
• communication is one-to-one
• sender / receiver have some knowledge of each other – e.g. location, protocol, methods, etc.
• the sender is responsible for dealing with failures - e.g. retries, etc. “request/response” is an example of a synchronous communication paradigm.
Example : a browser sends a request to a web server and “waits” for the response. The “wait” can be indefinite or until a timeout occurs.
Asynchronous communication.
Asynchronous communication represents a loose coupling between senders / receivers :
• sender and receiver communicate via a midde-man / broker / mediator
• no requirement for sender or receiver to both be available – i.e. deferred communication
• sender doesn’t wait for a response (if any)
• communication can be one-to-one or one-to-many
• sender and receiver have no direct knowledge of each other so promotes reuse / extension – e.g. new senders / receivers can be added without impact; senders / receivers can be replaced as required
• the broker is responsible for dealing with failures – e.g. retries, etc.
• messages may be delayed and/or arrive out of sequence

JMS (Java Message Service) is an API from Sun which allows generic access to MOM services – in a similar way that JDBC allows generic access to databases.
• Provider – vendor implementation of the JMS API
• Messaging domains – two types of domain, Point To Point (PTP) or publisher/subscriber
• Message consumption – two types of consumption, synchronous and asynchronous (see below).
• Administered objects – JMS bootstrap objects (e.g. connection factories, destinations) bound in the JNDI namespace by an administrator
• ConnectionFactory – Queue/TopicConnectionFactory, used to create a connection to the Provider
• Destination – Queue/Topic, target of message production/consumption
• Connection – Queue/TopicConnection, encapsulates connection to the Provider; start () indicates that message delivery should begin
• Session – Queue/TopicSession, used to create producers, consumers and message; also provides a context for transactions
• MessageProducer – QueueSender/TopicPublisher
• MessageConsumer – QueueReceiver/TopicSubscriber; consume messages synchronously using the receive () methods or asynchronously by passing a MessageListener to setMessageListener ()
• Message – object produced or consumed; composed of header, properties and body. Body types are : text, name/value pairs, bytes, stream of primitives, serialized object or none.

PTP messaging.
• based on Queues, Senders and Receivers
• Senders and Receivers address the Queue by name
• one or more Senders but only one Receiver
• messages stay in the Queue until consumed or past expiry time
• receiver acknowledges successful processing of a message

Publisher / subscriber.
• based on Topics, Publishers and Subscribers
• Publishers and Subscribers address the Topic by name
• one or more Publishers publish to the Topic subscribed to by one or more Subscribers
• messages only stay in the Topic for as long as it takes to send them to the active Subscribers
• a subscriber can only consume “active” messages – i.e. those published since the subscriber became active (unless durable subscriptions are in use)

List Benefits of Synchronous and Asynchronous Messaging
The benefits of synchronous messaging follow:
• Because both parties must be active to participate in synchronous messaging, if either party is not active, the message transaction cannot be completed.
• A message must be acknowledged before proceeding to the next message. If it is not acknowledged, the message cannot be considered processed.

The benefits of asynchronous messaging are as follows:
• As the volume of traffic increases, asynchronous messaging is better able to handle the spike in demand by keeping a backlog of requests in its queue and then operating at maximum capacity over a period of time instead of needing to service the requests instantaneously.
• Asynchronous messaging is less affected by failures at the hardware, software, and network levels.
• When capacities are exceeded, information is not lost; instead, it is delayed.

Identify Scenarios That Are Appropriate to Implementation Using Messaging
• Scenarios appropriate to implementation using message include asynchronous communication, one-to-many communication, guaranteed messaging, and transactional messaging.

Identify Scenarios That Are More Appropriate to Implementation Using Asynchronous Messaging, Rather Than Synchronous
• You need to implement a messaging system in which a response is not required or not immediately required.
• You need a high-volume transaction processing capability for sending messages.
• You want a messaging system that uses your system hardware in an efficient manner.

Identify Scenarios that Are More Appropriate to Implementation Using Synchronous Messaging, Rather Than Asynchronous
• One scenario more appropriate to synchronous messaging includes that in which a response to the message is required before continuing, for example, for transactions requiring credit card or user login authentication.
• A second scenario includes a transaction where both parties must be active participants.

Identify Scenarios That Are Appropriate to Implementation Using Messaging, Enterprise JavaBeans Technology, or Both
• The scenarios appropriate for messaging technology include broadcasting stock prices to traders, instant messages, and in situations when integration of incompatible systems is necessary.
• The scenarios appropriate for EJB technology include those that perform business logic and those that maintain persistent data.
• The scenarios appropriate for messaging and EJB technology including those that require maintenance of distributed transactions and those that send an order to another system.


  • bakiya
  • bakiya
  • 2006年07月07日 17:20
  • 3410


  • taomoon719
  • taomoon719
  • 2009年06月12日 17:09
  • 5336

SCEA认证资料 SUN在这方面的认证软件开发专业证书分为六类,分别为JAVA程序员(SCJP)、JAVA开发员(SCJD)、...
  • haimianjie2012
  • haimianjie2012
  • 2014年04月11日 17:41
  • 925


在八月份里看完了一遍”Sun Certified Enterprise Architect for J2EE Study Guide”,并作了一些相应的笔记,在这些笔记中并没有包含Design Pat...
  • wangjiong
  • wangjiong
  • 2004年09月05日 11:36
  • 768


General.Internationalisation.An application with support for Internationalisation• a.k.a. I18N• can ...
  • wangjiong
  • wangjiong
  • 2004年08月28日 16:29
  • 684

SCEA之路--3. UML

Elements Used in UMLClassAs mentioned, a class is any uniquely identified abstraction that models a ...
  • wangjiong
  • wangjiong
  • 2004年08月10日 22:48
  • 816


自从2004年4月份完成了SCJD考试之后,很是闲散了一段时间。每天除了工作之外,就是看看书、打打球,好像没有了什么具体的目标。这样悠闲的过了几个月,终于收拾起心情,开始准备最后的SCEA考试。 其实...
  • wangjiong
  • wangjiong
  • 2004年08月03日 16:54
  • 767

SCEA之路--10. Security

General.• nothing is 100% secure• only as strong as the weakest link (e2e security requires many lay...
  • wangjiong
  • wangjiong
  • 2004年08月29日 11:22
  • 584

SCEA之路--11. Protocols

Scenarios.HTTP/HTTPS – internet sitesRMI-IIOP – intranet environment; interoperability requirements ...
  • wangjiong
  • wangjiong
  • 2004年09月06日 22:33
  • 739


从事 Java 的教学也有好几年了,学生问我的问题除了程序语言之外的,最多的应该非认证相关的问题莫属了。像是认证怎么考啊?题型会像长的怎样?做考古题有没有用?其中里面最被大家所关心的就是,考认证对于找...
  • LP2001lp
  • LP2001lp
  • 2006年02月25日 17:57
  • 2561
您举报文章:SCEA之路--8. Messaging