0% found this document useful (0 votes)
14 views24 pages

L04 Jndi Jms

The document discusses the Java Naming and Directory Interface (JNDI) and Java Messaging Service (JMS), highlighting their functions and interrelation. JNDI provides a naming service that allows clients to bind and lookup objects, while JMS facilitates message queuing for program-to-queue communication. The integration of JNDI with JMS helps abstract administrative details and enhance compatibility across different naming services.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views24 pages

L04 Jndi Jms

The document discusses the Java Naming and Directory Interface (JNDI) and Java Messaging Service (JMS), highlighting their functions and interrelation. JNDI provides a naming service that allows clients to bind and lookup objects, while JMS facilitates message queuing for program-to-queue communication. The integration of JNDI with JMS helps abstract administrative details and enhance compatibility across different naming services.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 24

JNDI and JMS

Dr. Heming Cui


University of Hong Kong

1
Java Naming and Directory Interface
(JNDI)

2
Functions of Naming Service
• bind: bind a name to an object or object reference (information about
how to access an object)
• lookup: looks up an object or object reference by its name

Object 1
Binding
(csis web svr)
Namespace Addresses
Name 1 Reference 1
(www.csis.hku.hk) (IP addr of csis) Object 2
Name 2 Reference 2 (eee web svr)
(www.eee.hku.hk) (IP addr of eee)
Client
. .
. .
. .
3
Naming Service: Binding names to
objects

4
Message Queuing (A Preview)
• Program-to-queue communication
• Message queue: like a very fast mail box, i.e. put a message in a box
without the recipient being active
• Actions:
• Put: puts a message into the queue
• Get: takes a message out of the queue
• Message queue software:
• Transfer of messages from queue to queue
• Ensures message arrives eventually and only one copy of the message is
placed in the destination queue
Get
Put

Put Get
Queue Queue
5
JMS And JNDI (Preview of the Two’s
Relation)
• JMS does not not define a standard address syntax by which
clients communicate with each other. Instead JMS utilizes
Java Naming & Directory Interface(JNDI).
• JNDI provides a mechanism by which clients can perform a
“lookup” to find the correct information to connect to each other.
• Using JNDI provides the following advantages:
• It hides provider-specific details from JMS clients.
• It abstracts JMS administrative information into Java objects that are
easily organized and administrated from a common management
console.
• Since there will be JNDI providers for all popular naming services, this
means JMS providers can deliver one implementation of administered
objects that will run everywhere. Thereby eliminating deployment and
configuration issues.

6
Naming Service
• Associates names with objects, which can then be located by names,
e.g. catalog in a library to locate books
• In a large enterprise, an application may need to access services
provided by other applications  need a naming service to locate
these services
• Naming service can be centralized or distributed
• Namespace: set of names in a naming service
• Naming context: a set of name-to-object bindings sharing the same
naming convention
• Context object: an object with methods to bind names, unbind names, rename
objects and list existing bindings
• Subcontext: a name in a context is also bound to another context with the
same naming conventions

7
Hierarchical Naming Context
• Name contexts that organized in a hierarchy
• Root is called the initial naming context, serves as a starting point to
resolve names, e.g. root of Unix file system is /

Hierarchical File System Hierarchical Naming Context

Root of Directory Initial Naming Context

Subdirectory Subcontext

file information: name binding:


file name object name
file location object reference
8
Directory Service
• Directory service: stores, distributes, searches and retrieves objects
• Directory object: object in the directory, also called directory entry
• An extension of a naming service: not only bind objects with names, but also
contains attributes for each directory object
• Attribute: provides the description about the object
• Object can be search based on its attributes
• E.g. a book in a library can be modeled as a directory object that has
the following attributes:
• Name of the book, names of authors, category, abstract, publisher, date of
publication, ISBN, call numbers of copies, locations of copies, …
• An attribute has an attribute identifier and a set of attribute values, e.g.
Book “Java Enterprise in a Nutshell”
• Attribute identifier: authors
• Values: David Flanagan, Jim Fareley, William Crawford and Kris Magnusson
• Directory service can be centralized or distributed

9
Directory Search
• A directory service supports search of directory objects by names
and by queries based on a logical expression of the object’s
attributes (search filter), e.g.
• Search a book by name “Java How to Program”
• Search for books written by “David Flanagan” and “Jim Fareley”

Directory Service

Name 1 Attributes 1

Name 2 Attributes 2

Name 3 Attributes 3
Client

...
10
Java Naming and Directory Interface
(JNDI)
• A naming and directory service in the Java environment
• Does not replace existing naming/directory services, only provides a
common interface (JNDI API):
• Common Object Services (COS) naming: is used to store and access
references to CORBA objects
• Domain Name System (DNS): Internet naming service to map host names
(e.g. www.csis.hku.hk) into IP addresses (147.8.179.15)
• Lightweight Directory Access Protocol (LDAP): simpler version of X.500
network directory protocol
• Novell Directory Service (NDS): directory service for Novell Netware
networks
• Network Information System (NIS): a naming system from Sun
Microsystems used to access files from a number of hosts with a single ID
and password

11
JNDI Architecture
Java Application

JNDI API

JNDI Naming Manager

JNDI Service Provider Interface (SPI)

NIS LDAP DNS COS JNDI


… Implementation

Objects

12
Java Messaging Service (JMS)

13
Message Queuing
• Program-to-queue communication
• Message queue: like a very fast mail box, i.e. put a message in a box
without the recipient being active
• Actions:
• Put: puts a message into the queue
• Get: takes a message out of the queue
• Message queue software:
• Transfer of messages from queue to queue
• Ensures message arrives eventually and only one copy of the message is
placed in the destination queue
Get
Put

Put Get
Queue Queue
14
Message Queue Software
• Queue have names
• The queues are independent of program, i.e. many programs can
perform Puts and Gets on the same queue, and a program can access
many queues
• If the network goes down, messages will wait in the queue until the
network comes up
• The queues can be put onto a disk so that the queue is not lost even
the system goes down
• The queue can be a resource manager and co-operate with a
transaction manager, i.e. if the message is put in a queue during a
transaction and the transaction later aborted, then the DB will be
rolled back and the message is removed from the queue
• Some message queue systems can cross networks of different types,
e.g. message goes through SNA leg, TCP/IP leg and then a Novell IPX
leg
• Efficient: used in applications require sub-second response time

15
Message Queue Software
• Products: IBM MQSeries, Microsoft MSMQ, BEA Systems Tuxedo/Q,
JMS in J2EE

16
Message Oriented Middleware
(MOM)

17
Messaging
Architecture
• Client-based messaging
Client
• Server-based messaging

Client Client
Server

Client Client Client

18
MOM Middleware
• What happens to a message if the intended receiver is not available?
• Store for later delivery vs. ignore the message
• What happens when the server goes down? How does the client find
out?
• Do all clients receive all messages?
• Clients want to receive messages by specifying the corresponding message
destination
• Can any client send messages to any other client?
• Message provider limits the message destinations
• What can a message include?
• Binary messages, text messages, messages that have key-value pairs, objects

19
Messaging Domains
• The models for the programs that are communicating
• Point-to-point messaging: one client to send messages to another
client and vice versa, 2 models:
• Direct messaging: a client directly send a message to another client, similar
to RMI
• Message queue: senders put messages into a queue (supported by JMS)
• Publish-subscribe messaging: multiple programs to receive the same
message
• JMS defines publish-subscribe around the concept of a topic
• Publishers send messages to a topic, subscribers receive all messages sent
to that topic
• Used if a group of programs want to notify each other of a particular event
• Request-reply messaging: a program sends a message and expects
to receive message in return
• JMS supports the use of a “reply to” field in the above 2 domains

20
JMS Overview

21
JMS Overview (cont)

22
JMS Overview (cont)

23
JMS And JNDI (Final)

• JMS does not not define a standard address syntax by which


clients communicate with each other. Instead JMS utilizes
Java Naming & Directory Interface(JNDI).
• JNDI provides a mechanism by which clients can perform a
“lookup” to find the correct information to connect to each other.
• Using JNDI provides the following advantages:
• It hides provider-specific details from JMS clients.
• It abstracts JMS administrative information into Java objects that are
easily organized and administrated from a common management
console.
• Since there will be JNDI providers for all popular naming services, this
means JMS providers can deliver one implementation of administered
objects that will run everywhere. Thereby eliminating deployment and
configuration issues.

24

You might also like