Sie sind auf Seite 1von 73

2003 BEA Systems, Inc.

955
Theory and Fundamentals
At the end of this module you will be able to:
9 EJ B fundamentals
9 Transaction fundamentals
9 J DBC fundamentals
9 J MS and MOM fundamentals
Module 26
Theory and Fundamentals-1
2003 BEA Systems, Inc. 956
Road Map
1. EJ B Fundamentals
Maj or EJB T ypes and T hei r Purpose
EJB Pool and Cache Management
2. Transaction fundamentals
3. J DBC fundamentals
4. J MS and MOM fundamentals
Theory and Fundamentals-2
2003 BEA Systems, Inc. 957
Enterprise JavaBeans
fEnterpri se J avaBeans (EJ B) standardizes the
development and deployment of server
components built in J ava.
fThe EJ B specification defines relationships
between:
the EJ B and its container
the container and the application server
the container and the client
Theory and Fundamentals-3
2003 BEA Systems, Inc. 958
Types of EJBs
fThe EJ B specification discusses four types of
objects:
stateless session beans
stateful session beans
entity beans
message driven beans
Theory and Fundamentals-4
2003 BEA Systems, Inc. 959
What Is a Stateless Session EJB?
fStateless session EJ Bs:
provide independent services
do not maintain state on behalf of client
are synchronous
do not survive EJ B server crashes
are maintained in memory
calls can be handled by any instance with the same
results
Stateless Session EJB
Theory and Fundamentals-5
2003 BEA Systems, Inc. 960
What Is a Stateful Session EJB?
fStateful session EJ Bs:
provide conversational interaction
store state on behalf of the client
are synchronous
do not survive EJ B server crashes
are maintained in memory
each instance is associated to a single client
Stateful Session EJB
Theory and Fundamentals-6
2003 BEA Systems, Inc. 961
Session EJB Examples
f Stateless session EJ Bs:
an EJ B that checks to see if
a stock symbol is valid
an EJ B that determines the
local billing price for a
phone call
an EJ B that calculates an
insurance quote based on a
provided customer profile
an EJ B that assembles a
standard report from several
departments
f Stateful session EJ Bs:
an EJ B that books a flight
and car rental at a travel
agents Web site
an EJ B that orders spare
parts for a car as part of an
application
an EJ B that manages the
shopping cart in a Web site
Theory and Fundamentals-7
2003 BEA Systems, Inc. 962
What Is an Entity EJB?
fEntity EJ Bs have the following behavior:
they are representati ons of persistent data
they can survive a crash
multiple clients can be using EJ Bs that represent the
same data
the EJ B manages an in-memory copy of the data in the
persistent store
Entity EJB
Theory and Fundamentals-8
2003 BEA Systems, Inc. 963
Entity EJB Examples
fSome entity EJ B examples include:
an EJ B that represents a football players career
statistics
an EJ B that represents a stocks historical prices
an EJ B that represents a genome sequence
an EJ B that represents the outline for a course
an EJ B that contains your personal profile for accessing
your favorite Web site
Theory and Fundamentals-9
2003 BEA Systems, Inc. 964
Message-Driven Beans
fMessage-driven beans (MDB):
are asynchronous stateless components
behave similarly to stateless session beans
are J MS message consumers
fClients do not interact directly with MDBs
Container
Client
Sends
JMS Destination
Message
Theory and Fundamentals-10
2003 BEA Systems, Inc. 965
Message-Driven EJB Examples
fMessage-driven EJ Bs:
an EJ B that stores logging messages
an EJ B that processes a Web sites feedback messages
sent from a Servlet
an EJ B that processes news article postings
Theory and Fundamentals-11
2003 BEA Systems, Inc. 966
JAR File Structure
fEJ B components come
packaged in a J AR file.
fThe format of the J AR
file is shown here:
fEJ Bs are configured
by modifying the XML
files.
Theory and Fundamentals-12
2003 BEA Systems, Inc. 967
EJB Pooling & Caching in WLS
fEJ B objects can be pooled:
creating many instances at deployment time
servicing many concurrent clients faster
fEJ B objects can also be cached:
the number of objects is limited to a certain ceiling,
so memory cannot be filled up
only the recently used objects stay in memory
other objects are either
saved to persistent storage, or
destroyed (if they are timed out)
f Pooling and Caching are set up by editing the file
META-INF\weblogic-ejb-jar.xml.
Theory and Fundamentals-13
2003 BEA Systems, Inc. 968
EJB Administrator Tasks with WLS
f You can set up Stateless session EJ Bs for:
pool size
f You can configure Stateful session EJ Bs:
cache size
idle timeout - if memory is short, not used objects can be disposed
of after a certain period of time
cache type - if memory is short, objects can be stored to persistent
storage (if they are not timed out); this is called passi vati on
f Entity EJ Bs are both pooled and cached, so you can set
their:
pool size
cache size and idle timeout
Theory and Fundamentals-14
2003 BEA Systems, Inc. 969
Stateless Session EJB Pool Settings
fYou can manage the stateless session EJ B pool by:
capping the number of instances
setting an initial pool size
META-INF\weblogic-ejb-jar.xml Snippet:
<!- Other Tags As Appropriate Here -->
<weblogic-enterprise-bean>
<ejb-name>HelloEJB</ejb-name>
<stateless-session-descriptor>
<pool>
<max-beans-in-free-pool>15</max-beans-in-free-pool>
<initial-beans-in-free-pool>5</initial-beans-in-free-pool>
</pool>
</stateless-session-descriptor>
<jndi-name>HelloWorld</jndi-name>
</weblogic-enterprise-bean>
10
0101
1110
Theory and Fundamentals-15
2003 BEA Systems, Inc. 970
Stateful Session EJB Cache Settings
fYou can manage the stateless session EJ B cache by:
capping the number of instances
setting a timeout period
setting the passivation strategy for the cached EJ Bs
META-INF\weblogic-ejb-jar.xml Snippet:
<!- Other Tags As Appropriate Here -->
<weblogic-enterprise-bean>
<ejb-name>HelloEJB</ejb-name>
<stateful-session-descriptor>
<stateful-session-cache>
<max-beans-in-cache>1000</max-beans-in-cache>
<idle-timeout-seconds>60</idle-timeout-seconds>
<cache-type>NRU</cache-type>
</stateful-session-cache>
</stateful-session-descriptor>
<jndi-name>HelloEJB</jndi-name>
</weblogic-enterprise-bean>
10
0101
1110
Theory and Fundamentals-16
2003 BEA Systems, Inc. 971
Entity EJB Pool & Cache Settings
f You can manage the entity EJ B:
pool by capping the number of instances and setting an
initial pool size
cache by capping the number of instances and setting a
timeout period
META-INF\weblogic-ejb-jar.xml Snippet:
<weblogic-enterprise-bean>
<ejb-name>DogEBean</ejb-name>
<entity-descriptor>
<pool>
<max-beans-in-free-pool>15</max-beans-in-free-pool>
<initial-beans-in-free-pool>5</initial-beans-in-free-pool>
</pool>
<entity-cache>
<max-beans-in-cache>100</max-beans-in-cache>
<idle-timeout-seconds>30</idle-timeout-seconds>
</entity-cache>
</entity-descriptor> example
10
0101
1110
Theory and Fundamentals-17
2003 BEA Systems, Inc. 972
Pool Size Determination
fHow many EJ Bs should be in the pool?
fFactors to consider:
number of threads set in WLS
number of concurrent clients
number of dependent backend resources (for
example, database connections)
fPool size will equally affect all servers of a
cluster.
Theory and Fundamentals-18
2003 BEA Systems, Inc. 973
Cache Size Determination
fSome criteria that affect the size of your
cache include:
the total amount of J ava heap space available in
the VM
the number of different stateful session and
entity beans deployed
the amount of memory a single EJ B consumes
while active
the number of concurrent clients
clustering requires more memory because of
replication of EJ Bs
Theory and Fundamentals-19
2003 BEA Systems, Inc. 974
Section Review
9 Major EJ B types and their purpose
9 EJ B pool and cache management
In this section we discussed:
Theory and Fundamentals-20
2003 BEA Systems, Inc. 975
Road Map
1. EJ B Fundamentals
2. Transaction fundamentals
T ransacti ons
T he ACI D Properti es of T ransacti ons
Commi t and Rollback
T he T wo-phase Commi t Protocol
3. J DBC fundamentals
4. J MS and MOM fundamentals
Theory and Fundamentals-21
2003 BEA Systems, Inc. 976
What Is a Transaction?
fA transacti on is a mechanism to handle groups of
operations as though they were one.
fEither all operations in a transaction occur or
none at all.
fOperations involved in a transaction may rely on
many different servers and databases.
Theory and Fundamentals-22
2003 BEA Systems, Inc. 977
ACID Properties of a Transaction
fA transaction is formally defined by the set of
properties known by the acronym ACID.
fThe acronym ACID stands for:
Atomic
Consistent
Isolated
Durable
Theory and Fundamentals-23
2003 BEA Systems, Inc. 978
Transfering Without Transactions
fSuccessful transfer:
fUnsuccessful transfer (accounts are left in an
inconsistent state):
$1000
+$100
$1100
$500
-$100
$400
2) Deposit: $100
1) Withdraw: $100
Transfer: $100
From: Acct 1
To: Acct 2
ATM Bank
Account 1
Account 2
$1000
$500
-$100
$400
1) Withdraw: $100
Transfer: $100
From: Acct 1
To: Acct 2
ATM Bank
Account 1
Account 2
Failed
Deposit
Theory and Fundamentals-24
2003 BEA Systems, Inc. 979
Successful Transfer with Transactions
Transaction Started by Bank
fChanges within a transaction are buffered.
fIf a transfer is successful, changes are commi tted
(made permanent).
Transfer: $100
From: Acct 1
To: Acct 2
ATM Bank
$1100
$400
Commit
Transfer
Successful
ATM Bank
Account 1
Account 2
Transaction Started by Bank $500
-$100
$400
1) Withdraw: $100
Account 1
Account 2
$1000
+$100
$1100
2) Deposit: $100
Commit
Theory and Fundamentals-25
2003 BEA Systems, Inc. 980
Transaction Started by Bank
fChanges within a transaction are buffered.
fIf a problem occurs, the transaction is rolled back
to the previous consistent state.
Transfer: $100
From: Acct 1
To: Acct 2
ATM Bank
Transaction Started by Bank
$1000
$500
-$100
$400
1) Withdraw: $100
Account 1
Account 2
Failed
Deposit
$1000
$500
Rollback
Error
message
ATM Bank
Account 1
Account 2
Rollback
Unsuccessful Transfer with Transactions
Theory and Fundamentals-26
2003 BEA Systems, Inc. 981
What Are Distributed Transactions?
fA resource, like a database, is controlled through
software called a resource manager (RM).
fA local transacti on is a transaction that deals with
a single resource manager.
fA di stri buted transacti on is a transaction that
coordinates or spans multiple resource managers.
fCoordination of multiple resource managers is
done by a transacti on manager (TM).
fA transaction is often referred to as a transacti on
context.
Theory and Fundamentals-27
2003 BEA Systems, Inc. 982
The Two-Phase Commit Protocol
fThe 2PC protocol uses two steps to commit
changes within a distributed transaction.
fPhase 1 asks all RMs to prepareto make the
changes and if any of them cannot, the transaction
is aborted.
fPhase 2 asks all RMs to actually commit and make
the changes permanent.
fA global transacti on I D(XID) is used to track all
changes associated with a distributed a
transaction.
Theory and Fundamentals-28
2003 BEA Systems, Inc. 983
XA (Extended Architecture)
fXA:
is the interface used between WLS and Resource
Managers
implements the 2PC protocol
allows programs to control RMs that are involved in
distributed transactions
Client
Transaction
Manager
RM1
RM2
XA
XA
Theory and Fundamentals-29
2003 BEA Systems, Inc. 984
fA Transacti on Manager coordinates several
resource managers.
fThe two-phase commi t (2PC) protocol is used to
coordinate the transaction.
fThe XA protocol implements 2PC.
Transaction and Resource Managers
Transaction Context started by Transaction Manager
Transaction
Manager
Resource
Manager
Resource
Manager
Resource
Manager
Database
Printer
Another
App
Application
XA
XA
XA
Theory and Fundamentals-30
2003 BEA Systems, Inc. 985
A Successful Two-Phase Commit
Application
TLOG
Transaction
Manager
Resource
Manager
Resource
Manager
Resource
Manager
Database
Printer
Another
App
Application
pre-commit
ready
Transaction
Manager
Resource
Manager
Resource
Manager
Resource
Manager
Database
Printer
Another
App
commit
committed
Phase 1
Phase 2
TLOG
Theory and Fundamentals-31
2003 BEA Systems, Inc. 986
An Unsuccessful Two-Phase Commit
Application
TLOG
Transaction
Manager
Resource
Manager
Resource
Manager
Resource
Manager
Database
Printer
Another
App
Application
pre-commit
Transaction
Manager
Resource
Manager
Resource
Manager
Resource
Manager
Database
Printer
Another
App
abort
Phase 1
Phase 2
TLOG
not
ready
ready
prepare/
abort
ready/
committed
not
ready
rolled
back
Theory and Fundamentals-32
2003 BEA Systems, Inc. 987
Java Transaction API (JTA)
fWLS uses J TA 1.0.1 to implement and manage
transactions.
fWLS J TA provides the following support:
creates unique transaction identifier (XID)
supports optional transaction name
tracks objects involved in transaction
notifies databases of transaction
orchestrates 2PC using XA
executes rollbacks
executes automatic recovery procedures when failure
manages time-outs
Theory and Fundamentals-33
2003 BEA Systems, Inc. 988
Section Review
9 What distributed transactions are
9 The XA protocol
9 Transaction and resource managers
9 The two-phase commit
protocol
9 The J ava Transaction API
In this section we discussed:
Theory and Fundamentals-34
2003 BEA Systems, Inc. 989
Road Map
1. EJ B Fundamentals
2. Transaction fundamentals
3. J DBC fundamentals
JDBC Archi tecture
Datasources and Connecti on Pools
T he T wo-phase Commi t Protocol
4. J MS and MOM fundamentals
Theory and Fundamentals-35
2003 BEA Systems, Inc. 990
What Is JDBC?
fJ DBC is an API for accessing databases in a
uniform way.
fJ DBC provides:
platform independent access to databases
location transparency
transparency to proprietary database issues
support for both two-tier and multi-tier models for
database access
Theory and Fundamentals-36
2003 BEA Systems, Inc. 991
fJ DBC Dri vers are implementation classes for
database operations.
fDrivers fall into two categories:
2-tier, where clients talk directly to a database
3-tier, where clients talk to a middle-tier (WLS) which
delegates to a database
JDBC & JDBC Drivers
Java
Application
JDBC
Driver
WLS
JDBC
Driver
Database
Database
Theory and Fundamentals-37
2003 BEA Systems, Inc. 992
JDBC Architecture
Network
Server
(WLS)
Native API
(C, C++)
ODBC
Driver
All Java
JDBC Driver
(Type 4)
JDBC-Net
Bridge
(Type 3)
JDBC-Native
Bridge
(Type 2)
JDBC-ODBC
Bridge
(Type 1)
JDBC API
Java Application
RDBMS
Theory and Fundamentals-38
2003 BEA Systems, Inc. 993
Type 1 Driver
fThe Type 1 driver:
is a J DBC-ODBC bridge & usually runs on Windows
requires ODBC driver to be installed on client machine
ODBC Driver
Client
DBMS
JDBC-ODBC Bridge
JDBC API
Java App
ODBC-supported
Native Driver
Native program
Java program
Theory and Fundamentals-39
2003 BEA Systems, Inc. 994
Type 2 Drivers
fThe Type 2 driver:
requires a native driver to be already installed on the
client machine
the driver converts J DBC calls to native API calls of the
database
JDBC-Native Bridge
Native Driver
Client
DBMS
JDBC API
Java App
Native program
Java program
Theory and Fundamentals-40
2003 BEA Systems, Inc. 995
Type 3 Drivers
Java App
JDBC API
JDBC-Net Driver
Client[b]
DBMS[b]
Network
Server
Network
Protocol
Database
Protocol[b]
DBMS[c]
Database
Protocol[c]
Client[c]
Client[a]
DBMS[a]
Database
Protocol[a]

Theory and Fundamentals-41


2003 BEA Systems, Inc. 996
Type 3 Drivers
fA network server can apply several techniques to
boost performance:
load management
caching
pooling
getConnection()
Free Connection
Connection in Use
DBMS
Theory and Fundamentals-42
2003 BEA Systems, Inc. 997
Type 4 Drivers
fType 4 drivers are all-J ava driver implementations
that do not require client side configuration.
JDBC Driver
Client
DBMS
JDBC API
Java App
Theory and Fundamentals-43
2003 BEA Systems, Inc. 998
Two-Tier Architecture
fIn the two-tier model a J ava application
communicates directly with the DBMS.
fA J DBC driver is needed that can communicate
directly with the DBMS.
fThis is a client/server configuration.
JDBC
Java Application
Client
DBMS - proprietary
protocol
DBMS
Theory and Fundamentals-44
2003 BEA Systems, Inc. 999
Multi-Tier Architecture
fIn the multi-tier model,
commands are sent to a "middle
tier" of services, which then
sends the commands to the
DBMS.
fThe DBMS processes the
commands and sends the results
back to the middle tier, which
then sends them to the client.
DBMS
JDBC
Java applet or
HTML browser
Client
DBMS - proprietary protocol
Server
Application Server,
Business Logic
Theory and Fundamentals-45
2003 BEA Systems, Inc. 1000
WebLogic Server Two-Tier Drivers
fThe following table shows the two-tier drivers for
vendor specific platforms that WebLogic Server
provides.
4 Weblogic jDriver for Oracle
4 Oracle Thin
4 Sybase jConnect
4 Pointbase (evaluation license)
4
Weblogic jDriver for Microsoft SQL
Server
4 Weblogic jDriver for Informix
Type Driver
Theory and Fundamentals-46
2003 BEA Systems, Inc. 1001
WebLogic Server Multi-Tier Drivers
fWebLogic Server provides three multi-tier drivers
for vendor-neutral database access.
A server-side driver used in distributed
transactions across multiple resource
managers.
Weblogic JTS Driver
A type 3 driver that can be sued with any
two-tier JDBC driver.
Weblogic RMI Driver
Enables usage of connection pools from
server-side applications such as HTTP
Servlets or EJBS.
Weblogic Pool jDriver
Description Driver
Theory and Fundamentals-47
2003 BEA Systems, Inc. 1002
Choosing the Correct Driver
fChoosing the correct driver can have significant
impact on performance.
fFor two-tier applications use the type 1, 2 or 4
driver specific to the DBMS you are using.
fFor multi-tier applications use:
the RMI driver (DataSources) in a client class
a type 1, 2 or 4 driver on the server, specific to the
DBMS you are using
the J TS or Oracle XA driver in EJ B or where transaction
support is required
Theory and Fundamentals-48
2003 BEA Systems, Inc. 1003
Accessing DB Directly with JDBC
fAccessing databases directly consists of:
loading the J DBC driver class
getting and using a connection from the driver
10
0101
1110
Example of connecting to a database directly:
import java.sql.*;...
Try{
Statement stmt = con.createStatement();
String sql = "SELECT * FROM MYTABLE";
ResultSet res = stmt.executeQuery(sql);
while(res.next()){
String col1 = res.getString("MYCOLUMN1");
int col2 = res.getInt("MYCOLUMN2");
}
}catch(Exception e){...}}
Class.forName("COM.cloudscape.core.JDBCDriver");
Connection con = DriverManager.getConnection(
"jdbc:cloudscape:c:\data\MyDatabase");
Theory and Fundamentals-49
2003 BEA Systems, Inc. 1004
Connection Pools
fConnecti on pools:
are administered objects that manage database
connections
are configured with the Administration Console
provide connection sharing, security etc.
Application Server
Connection Pool
Java
Application
&RQQHFWLRQ
$YDLODEOH
&RQQHFWLRQ
$YDLODEOH
Connection
Available
Connection
In Use
Database
Theory and Fundamentals-50
2003 BEA Systems, Inc. 1005
Data Sources
fData Sources are:
administered factory objects that provide connections
from connection pools
bound into J NDI and configured using the
Administration Console
Application Server
Connection Pool
Java
Application
JNDI
Data Source Connection
Database
3 3
2 2
1 1 lookup
getConnection
Use like regular JDBC connection
Theory and Fundamentals-51
2003 BEA Systems, Inc. 1006
Create Connection Pools
9 9
3 3
2 2
1 1
5 5
6 6
7 7
8 8
4 4
Theory and Fundamentals-52
2003 BEA Systems, Inc. 1007
Target Connection Pool
4 4
3 3
2 2
1 1
Theory and Fundamentals-53
2003 BEA Systems, Inc. 1008
Create & Configure Data Sources
6 6
5 5
4 4
3 3
2 2
1 1
8 8
7 7
Theory and Fundamentals-54
2003 BEA Systems, Inc. 1009
Using Data Sources to Access DB
fTo use Data Sources:
look it up in J NDI
get a connection from Data Source
use connection as a regular connection
fHere is a J SP that prints the content of a table:
Theory and Fundamentals-55
2003 BEA Systems, Inc. 1010
A JSP That Prints Content of Table
Example of using a Data Source to connect to a database:
<TABLE>
<% try {
InitialContext ic = new InitialContext();
DataSource ds = (DataSource)ic.lookup("jdbc/BugDs");
Connection c = ds.getConnection();
Statement s = c.createStatement();
ResultSet rs = s.executeQuery("select * from BUGS");
ResultSetMetaData md = rs.getMetaData();
int colCount = md.getColumnCount();%>
<TR BGCOLOR=DDDDDD ALIGN=CENTER>
<% for(int j=1; j<colCount; j++){%>
<TD><FONT FACE=Verdana SIZE=-1><B>
<%=md.getColumnName(j)%></TD>
<% }%>
</TR>
<% while(rs.next()){%> <TR BGCOLOR=EEEEEE ALIGN=CENTER>
<% for(int j=1; j<colCount; j++){%>
<TD><FONT FACE=Verdana SIZE=-1>
<%=rs.getString(j)%></TD>
<% }%>
</TR>
<% }}catch(Exception e){System.out.println(e);
}%>
</TABLE>
10
0101
1110
Theory and Fundamentals-56
2003 BEA Systems, Inc. 1011
Section Review
9 Creating & configuring J DBC connection pools
9 Creating & configuring J DBC DataSources
9 Using DataSources in a database client code
In this section we discussed:
Theory and Fundamentals-57
2003 BEA Systems, Inc. 1012
Road Map
1. EJ B Fundamentals
2. Transaction fundamentals
3. J DBC fundamentals
4. J MS and MOM fundamentals
I ntroducti on to Message-Ori ented Mi ddleware
I ntroducti on to JMS
Theory and Fundamentals-58
2003 BEA Systems, Inc. 1013
What Is Messaging?
fMessaging is a mechanism that allows programs to
communicate with one another.
fThere are many messaging technologies:
TCP/IP sockets
pipes
files
shared memory
Message
Program Program
Theory and Fundamentals-59
2003 BEA Systems, Inc. 1014
Message-Oriented Middleware
fMessage-oriented middleware is used to refer to
an infrastructure that supports messaging.
fTypical message-oriented middleware
architectures define:
message structure
how to send/receive messages
scaling guidelines
Theory and Fundamentals-60
2003 BEA Systems, Inc. 1015
Benefits of Msg-Oriented Middleware
fMessage-oriented middleware architectures
provide many benefits:
multi-protocol, multi-platform support
user-defined message types
guaranteed message delivery (GMD)
load-balancing of messages
fault tolerance of messaging servers
cross-platform support
GUI-based configuration and management
reduced risk
Theory and Fundamentals-61
2003 BEA Systems, Inc. 1016
Types of Msg-Oriented Middleware
fMessage-oriented middleware software falls into
categories that define whi chclient receives a
message.
fWLS-supported categories:
Point-to-Point (PTP)
Publish-Subscribe (Pub/Sub)
Msg-Oriented
Middleware
Consumer 1
Consumer 2
Consumer 3
Message
Sender
Theory and Fundamentals-62
2003 BEA Systems, Inc. 1017
The Point-to-Point Domain
fThe PTP domain allows one client (called a
producer) to send messages to another client
(called a recei ver).
One-Way
Relationship
Two-Way
Relationship
Message
Message
Program Program
Program Program
Theory and Fundamentals-63
2003 BEA Systems, Inc. 1018
Queue Manager
(Msg-Oriented Middleware
Server)
PTP Queues
fMany producers can seri ali zemessages to
multiple receivers in a queue.
Distribution
Queue
4 5 6 7 8 9
Consumer 1
Consumer 2
Consumer 3
Message
Message
Message 2
Message 1
Message 3
Messages are delivered
to a single client
Producer
Producer
Theory and Fundamentals-64
2003 BEA Systems, Inc. 1019
The Publish/Subscribe Domain
fMessage producers (called publi shers),
disseminate data to multi pleconsumers (called
subscri bers).
Message
Message
Subscriber 1
Message
Subscriber 2
Subscriber 3
Publisher
Theory and Fundamentals-65
2003 BEA Systems, Inc. 1020
Topic Manager
(Msg-Oriented Middleware
Server)
Pub/Sub Topics
fPublishing and subscribing to atopi c decouples
producers from consumers.
Topic
1
1
1
2
2
2
3
3
3
Subscriber 1
Subscriber 1
Subscriber 1
Message
Message
Publisher
Publisher
4 5 6 7 8 9
Theory and Fundamentals-66
2003 BEA Systems, Inc. 1021
Durable Subscribers and Subscriptions
fSubscribers can be made durableby having the
messaging service persist messages to guarantee
delivery.
fDurable subscri bers register a durable
subscri pti on with J MS service using an ID.
fThis ID can then be used to retrieve missed
messages.
JMS
Client
JMS
Provider
Publishes
to a topic
JMS
Client
Backing Store
If client subscriber not
active: message is persisted
for later redelivery
If client subscriber
is active: Message
is delivered
Theory and Fundamentals-67
2003 BEA Systems, Inc. 1022
What Is Java Messaging Service (JMS)?
fJ MS consists of a set of interfaces that determine
how clients access a messaging service.
fA messaging service allows its clients to exchange
messages efficiently and reliably.
fA message is a structured asynchronous
communication between two programs.
Theory and Fundamentals-68
2003 BEA Systems, Inc. 1023
What Does JMS Provide?
fJ MS is a set of i nterfaces and associated semantics
that define how a J MS client accesses the facilities
of an enterprise messaging product.
fJ MS supports:
the PTP domain
the Pub/Sub domain
http://java.sun.com/products/jms/index.html
http://java.sun.com/products/jms/index.html
Theory and Fundamentals-69
2003 BEA Systems, Inc. 1024
What Is a JMS Application?
fA J MS Application consists of:
J MS clients
messages
J MS provider
administered objects
JMS Client Destination and
ConnectionFactory
Objects
Msg-Oriented
Middleware
Administered
Objects
JMS Implementation
Theory and Fundamentals-70
2003 BEA Systems, Inc. 1025
Administrative Tasks
fAdministrative tasks consist of:
creating connection factories
creating and monitoring J MS servers
creating and monitoring J MS destinations
creating various J MS stores
configuring thresholds and quotas
configuring durable subscriptions
Theory and Fundamentals-71
2003 BEA Systems, Inc. 1026
Section Review
9 The purpose of messaging
9 The role and benefits of message-oriented
middleware
9 Different message-oriented
middleware domains
(PTP, pub/sub, RR)
In this section we discussed:
Theory and Fundamentals-72
2003 BEA Systems, Inc. 1027
Module Review
9 EJ B fundamentals
9 Transaction fundamentals
9 J DBC fundamentals
9 J MS and MOM fundamentals
In this module we discussed:
Theory and Fundamentals-73

Das könnte Ihnen auch gefallen