JCEA Part 1: Messaging

 

Contents

  1. General
  2. References
  3. Syllabus
    1. Concepts
    2. Common architectures
    3. Legacy connectivity
    4. EJB
    5. EJB Container model
    6. Protocols
    7. Applicability of J2EE
    8. Patterns
    9. Messaging
    10. Internationalisation
    11. Security
  4. Reference
    1. UML
  5. Resources
  6. Further Tips
 
 

Syllabus

  • Identify scenarios that are appropriate to implementation using messaging, Enterprise JavaBeans technology, or both
  • List benefits of synchronous and asynchronous messaging
  • Identify scenarios that are appropriate to implementation using messaging
  • Identify scenarios that are more appropriate to implementation using asynchronous messaging, rather than synchronous
  • Identify scenarios that are more appropriate to implementation using synchronous messaging, rather than asynchronous
 

Information

Overview

Message-Oriented-Middleware provide a common reliable way for programs to create, send, receive and read messages in any distributed Enterprise System. MOM ensures fast, reliable asynchronous electronic communication, guaranteed message delivery, receipt notification and transaction control.

The Java Message Service (JMS) provides a standard Java-based interface to the message services of a MOM of some other provider.

Messaging systems can either be:

  1. Asynchronous
  2. Synchronous

and can be classified into different models that determine which client receives a message. The most common messaging models are:

  1. Publish-Subscribe Messaging
  2. Point-To-Point Messaging
  3. Request-Reply Messaging

Not all MOM providers support all these models.

1. Asynchronous messaging

Advantages:

  • Loose coupling between sender and receiver
  • Does not block sender
  • Network does not need to be available, messages can be queued
  • Least demanding on communication mechanisms

Disadvantages:

  • Reliability is an issue

Good for publish-subscribe

2. Synchronous messaging

Advantages:

  • Good for transaction processing
  • Fail-safe communication
  • Coping with error situations

Disadvantages:

  • Tight coupling between sender and receiver
  • Blocks sender until receiver is finished processing
  • Network must be available
  • More demanding on communication mechanisms

a. Publish-Subscribe Messaging

Publish-Subscribe Messaging is used when there may be multiple Senders and multiple Receivers.

The central concept in a Publish-Subscribe messaging system is the Topic. Multiple Publishers may send messages to a Topic, and all Subscribers to that Topic receive all the messages sent to that Topic.

b. Point-To-Point Messaging

Point-To-Point Messaging is used when one or more senders need to send messages to a single receiver.

The client to a Messaging system may only send messages, only receive messages, or send and receive messages. At the same time, another client can also send and/or receive messages.

There are two basic types of Point-to-Point Messaging systems. The first one involves a client that directly sends a message to another client. The second and more common implementation is based on the concept of a Message Queue. In this situation each message is addressed to a specific queue; clients get messages from the queue(s) created to hold their messages

c. Request-Reply Messaging

When an application sends a message and expects to receive a message in return, Request-Reply Messaging can be used. This is the standard synchronous object-messaging format. This messaging model is often defined as a subset of one of the other two models.

JMS does not explicitly support Request-Reply Messaging, though it allows it in the context of the other methods.

Java Messaging Service (JMS)

JMS provides a common way for Java programs to create, send, receive and read an enterprise messaging system’s messages.

The primary features of JMS are as follows:

  • Connection Factories are used in JMS to create connections to a specific JMS provider.
  • In JMS, both Publish-Subscribe Messaging and Point-To-Point are implemented and defined by separate interfaces so that a Provider does not have to support both.
  • JMS defines the concept of a Topic or a Queue as the target for a Message. Topics are used for Publish-Subscribe Messaging. Queues are used for Point-to-Point Messaging.
  • The Providers’ code is defined by interfaces in JMS, freeing the implementation from the limitations of subclassing.
  • JMS provides support for distributed transactions.

JMS Service Providers implement the JMS interface on top of their messaging services. JMS defines Queues and Topics, but it does not require the provider to implement both. JMS thus tries to maximize portability of the solution with as many features as possible.

Nothing prevents a JMS application from combining PTP and publish-subscribe but JMS focuses on applications that use one approach or the other.

JMS does NOT include the following:

  • Load balancing/fault tolerance
  • Error/advisory notification
  • Administration
  • Security
  • Wire protocol
  • Message Type Repository
 

Links

  1. Java Messaging Tutorial: Another one from Suresh Gopalan. This covers Publisher / Subscriber and Point to Point communication. This is a very good site for getting started with JMS. (this page is largely copied from this tutorial)
  2. Sun's Messaging tutorial
  3. MQSeries (MOM)
  4. Microsoft Message Queue Server (MSMQ) by Gopalan Suresh Raj
 

Observations

  • Advantages of messaging, and one question expected you to know that MQSeries is a MOM (Message Oriented Middleware)
  • The current EJB spec (1.1) defines beans that are invoked synchronously via method calls from EJB clients.
  • JMS provides client interfaces that can interface with point-to-point and publish-subscribe systems.
  • EJB 2.0 adds a messaging bean that is invoked when a JMS client sends it a message.
  • Advantages of messaging, and one question expected you to know that MQSeries is a MOM (Message Oriented Middleware)
  • One question required you to know that MSMQ is a messaging technology.

Page created by Leo Crawford
last updated in January 2003