Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your profile (name, country/region, and company) is displayed to the public and will accompany any content you post. You may update your IBM account at any time.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

Java certification success, Part 4: SCEA

Sivasundaram Umapathy (authors@whizlabs.com), Programmer, Sella Synergy India Limited
Sivasundaram Umapathy holds a bachelor of engineering degree in computer science from the University of Madras and a master of science degree in software systems from BITS, Pilani. He is presently associated with Sella Synergy India Limited, India, the software division of Banca Sella, S.p.A, where he designs and develops mission-critical banking applications using the BEA WebLogic application server. He is also crazy about certifications, with SCJP, SCBCD, SCWCD 1.4, SCMAD, SCEA, OCA, BEA WL7, IBM, and PMP certifications to his credit. He has authored the Whizlabs SCWCD 1.4 and co-authored the Whizlabs SCMAD exam simulators. He actively participates in the open source movement in his free time and is in an expert group member of JSR 244 (J2EE 5.0) and JSR 245 (JSP 2.1).

Acknowledgements

I wish to thank my friend and colleague Mrs. Rajeswari for her support and suggestions in completing this tutorial.

Summary:  This tutorial aims to help SCEA certification aspirants clear the first part of the SCEA certification exam, a knowledge-based, multiple-choice exam. The tutorial introduces the reader to the concepts and then builds upon them to cover other topics such as common architectures, legacy connectivity, Enterprise JavaBeans technology, the Enterprise JavaBeans container model, protocols, applicability of J2EE technology, design patterns, messaging, internationalization, and security. Readers' understanding is then reinforced through examples and practice questions and guides them to various useful resources for SCEA certification exam preparation.

Date:  16 Aug 2005
Level:  Intermediate PDF:  A4 and Letter (1372 KB | 89 pages)Get Adobe® Reader®

Activity:  44967 views
Comments:  

Messaging

Messaging introduction

A message is a unit of serializable data exchanged between two or more distributed components running in the same machine or different machine. By using a message-oriented middleware (MOM) infrastructure, an application can create, send, and receive messages. This lets you combine separate business components into a reliable, yet flexible system. Several vendors provide MOM, and in J2EE, Java Messaging Service (JMS) offers a generic way to access these systems. In this section, let's explore the different messaging modes and models and learn how to choose the correct one for a given scenario.


Communication modes

There are two modes of communication depending on the level of coupling between the sender and receiver:

  • Synchronous
  • Asynchronous

Synchronous

A distributed component sends a message to another active component and waits for the reply (also known as blocking call) to proceed further. The synchronous communication is tightly coupled because both the sender and receiver have knowledge about each other. The sender is responsible for retries in case of failures.

The benefits of synchronous communication are:

  • This mode is fail-safe and is used for transaction processing.

  • Sender can receive the response immediately in realtime.

  • When multiple messages are sent, they reach the destination in the same order in which they are sent.

  • It is a reliable communication mode.

You can use this mode when the sender:

  • Wants to have more control over the message.

  • Needs real-time response.

  • Wants to maintain the order of message processing.

  • Wants to retry in case of message failure.

Asynchronous

A distributed component can send messages to any other component via MOM and continue its processes without waiting for the response. This communication mechanism is loosely coupled, where sender and receiver need not have knowledge about each other because a central intermediary, the MOM, exists. Messages can arrive at the destination in any sequence and not necessarily in same order in which they are sent. MOM is responsible for retry in case of failure in the communication.

The benefits of asynchronous communication are:

  • Sender need not wait till the message gets processed. The responsibility is delegated to the MOM.

  • Messages can be queued. Sender and receiver need not be always available to receive the messages.

  • It is loosely coupled because the sender and receiver do not directly communicate; they communicate through MOM.

You can use this mode when the sender:

  • Wants to broadcast the message.

  • Needs no response, or the response is not needed immediately.

  • Wants to use the system hardware efficiently.

  • Wants to do transaction processing in high volume.

Messaging models

There are two types of messaging models depending on whether you require one-to-one message delivery or a one-to-many broadcast delivery. The models are:

  • Point-to-point messaging. In this model, the sender sends the messages to a destination known as queue, and the receiver consumes the message from the queue. A queue is designated to only one receiver. More than one sender can send the messages to a queue, but only one consumer receives that message from the queue. The messages in the queue are processed on a first-in-first-out (FIFO) basis. The messages stay in the queue until they are consumed by the consumer or until the messages' expiry time. A sender can also send the message directly to the consumer instead of placing it in the queue. A consumer can acknowledge the successful processing of the message.
  • Publish-subscribe messaging. In this model, publishers publish the messages to a topic. The subscribers who subscribe to that topic then receive the message. The message stays in the topic until it is sent to the active subscribers. If some subscribers are not active, the messages are not delivered to them. There is a special type of subscription known as a durable subscription in which the messages will not be lost if the subscriber is not active. Rather, the messages are delivered once the subscriber becomes active.

Technology and scenarios

The following table summarizes the technologies you can use for different scenarios.

Technologies and scenarios
TechnologyScenarios
Messaging
  • Need to broadcast messages
  • To interface between two incompatible systems that do not communicate directly
  • To simulate threads
  • Asynchronous communication
EJB
  • For doing transactional and secure operations
  • Need an immediate response
  • To perform business logic
  • To maintain persistence data
Messaging and EJB
  • To retrieve data and send to another system, which does not communicate directly
  • To perform distributed transactions across multiple application and systems

Messaging summary

In this section, we discussed the different types of communication modes and messaging models used in enterprise systems for messaging. We also discussed their benefits and when to use these different communication modes. In the exam, given a scenario, you should be able to identify which technologies you can use for the particular scenario. Remember that if the scenario calls for one-to-one messaging then it is a candidate for the point-to-point messaging model. On the other hand, if there are numerous receivers, the best method for implementation is the publish-subscribe model.


Test yourself on messaging

Question 1:

Which of the following choices describe asynchronous messaging?

Choices:

  • A. Loose coupling between sender and receiver
  • B. Blocks until message is processed
  • C. Suitable for transaction processing
  • D. The network is not required to be available

Correct choice:

A and D

Explanation:

Choices A and D are the correct answers.

Asynchronous messaging is loosely coupled because the sender and receiver do not directly communicate; they use MOM for communication. Hence, choice A is correct.

Because MOM takes care of delivering the messages if the receiver is not available, the network is not required to be constantly running. Thus, choice D is correct.

Only synchronous messaging blocks the sender until the receiver processes the message. Therefore, choice B is incorrect.

Because transaction processing requires immediate response, only synchronous messaging is suitable for implementing it. Hence, choice C is incorrect.

10 of 16 | Previous | Next

Comments



static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Java technology
ArticleID=132106
TutorialTitle=Java certification success, Part 4: SCEA
publish-date=08162005
author1-email=authors@whizlabs.com
author1-email-cc=