Trường Đại học Khoa Học Tự Nhiên
Khoa Công Nghệ Thông Tin
Bộ môn Công Nghệ Phần Mềm
CTT526 - Kiến trúc phần mềm
Middleware
PGS.TS. Trần Minh Triết
Version 1.0
CuuDuongThanCong.com
/>
Nội dung của bài giảng sử dụng:
Session 4:
A Guide to Middleware Architectures and Technologies
trong bộ slide Software Architecture Essential
của GS. Ian Gorton
Software Engineering Institute
Carnegie Mellon University
2
CuuDuongThanCong.com
/>
Introduction
Middleware is the plumbing or wiring of IT
applications
Provides applications with fundamental services for
distributed computing
Insulates applications from underlying platform
(OS, DBMS, etc) APIs
Lots of middleware exists
Different purposes
Different vendors
Different standards and proprietary technologies
3
CuuDuongThanCong.com
/>
Middleware Classification
Business Process Orchestrators
BizTalk, TIBCO StaffWare, ActiveBPEL
Message Brokers
BizTalk, WebSphere Message Broker, SonicMQ
Application Servers
Transport
J2EE, CCM, .NET
Message-Oriented Middleware, Distributed Objects Systems
4
CuuDuongThanCong.com
/>
Outline
CORBA
Message-oriented middleware
J2EE
Message brokers
Business process orchestrators
5
CuuDuongThanCong.com
/>
CORBA
Venerable distributed object technology
Still widely used in telecomms, defense
Many different implementations
Client
Server
Object Reference
request
Servant
reply
client ORB
server ORB
Network
6
CuuDuongThanCong.com
/>
CORBA Code Example
module ServerExample
{
interface MyObject {
};
Server
string isAlive();
};
CORBA IDL
class MyServant extends _MyObjectImplBase
{ public String isAlive() { return "\nLooks like it…\n";
}
ORB orb = ORB.init(args, null);
MyServant objRef = new MyServant();
orb.connect(objRef);
ORB orb = ORB.init(args, null);
// Lookup is a wrapper that actually access the CORBA Naming
// Service directory – details omitted for simplicity
MyServant servantRef = lookup(“Myservant”)String
reply = servantRef.isAlive();
}
Client
7
CuuDuongThanCong.com
/>
CORBA – Some Thoughts
Many associated services, eg
Naming
Notification
Transactions
Synchronous technology, client-server relatively tightly
coupled
Remote calls can/will fail
State management in server objects creates
„interesting‟ recovery issues
8
CuuDuongThanCong.com
/>
Messaging - MOM
Basic Message Oriented Middleware (MOM) provides
features like:
Asynchronous communications between processes,
applications and systems
Send-and-forget
Delivering messages despite failures
Transactional Messaging
Deliver all messages in a transaction, or none
Persistence
Messages can be logged at the server and hence
survive server failure
9
CuuDuongThanCong.com
/>
Basic Messaging
Send (queue, message)
Receive (queue, message)
Put message onto queue
Get message from queue
No dependency on state of receiving
application on message send
send
receive
queue
CuuDuongThanCong.com
/>
10
Persistence
queue
send
receive
Receipt of message at queue implies
message is written to disk log
Removal of message from queue
deletes message from disk log
Trade-off performance versus reliability
CuuDuongThanCong.com
/>
11
MOM Server
Receivers
Sending
Applications
Senders
Sending
Applications
Message
Handler Thread Pool
MOM Server
Peer-to-peer MOM technologies are the alternative design
12
CuuDuongThanCong.com
/>
MOM Transactions
Begin
transaction
...
transaction
...
update
put
Begin
database
message
on
record
queue
...
get
message
update
from
database
queue
record
...
commit
transaction
CuuDuongThanCong.com
commit
transaction
/>
13
MOM Transactions
Sender and receiver do *not* share a transaction
Rollback on receiver does not affect the sender (already
committed)
„Synchronous‟ operations are not atomic
Request/response is 3 transactions not 1
Put to request queue
Get from request queue, put to response queue
Get from response queue
Request queue
send
receive
send
receive
Response queue
14
CuuDuongThanCong.com
/>
Scaling MOM
MOM Server
ApplicationQ
Senders
Receivers
MOM Server
ApplicationQ
15
CuuDuongThanCong.com
/>
Messaging – Some thoughts
Highly attractive asynchronous technology
Supports loosely-coupled, dynamic applications
Scales well, high throughput possible
Many implementations, various qualities of service
caveat emptor
16
CuuDuongThanCong.com
/>
Publish-Subscribe Messaging
Extension of MOM to provide 1-to-N, N-to-1, and N-toN communications
Messages are „published‟ to logical subjects or topics
Subscribers receive all messages from subjects they
subscribe to
Sub
Pub
Create/
Publish
Subject
Register/
Subscribe
Sub
Sub
17
CuuDuongThanCong.com
/>
Publish-Subscribe with Multicast
S u b s c r ib e r
S u b s c r ib e r
rvd
rvd
rvrd
Based on
TIBCO
Rendezvous
P u b lis h e r
rvd
rvd
S u b s c r ib e r
rvrd
rvd
S u b s c r ib e r
rvd
S u b s c r ib e r
18
CuuDuongThanCong.com
/>
Performance
M i l l i se c o n d s
700
600
500
M C1
400
M C2
300
QB
200
100
0
10
20
30
40
50
N o . O f S u b sc r i b e r s
19
CuuDuongThanCong.com
/>
Subject/Topic Naming
Sydney
work
DevGroup
SupportGroup
Information
Information
gossip
Sydney
Sydney/DevGroup
Sydney/DevGroup/Information
Sydney/DevGroup/Information/work
Sydney/DevGroup/Information/gossip
Sydney/SupportGroup
Sydney/SupportGroup/Information
Sydney/SupportGroup/Information/work
Sydney/SupportGroup/Information/gossip
work
gossip
Sydney/*/Information
Sydney/DevGroup/*/*
Sydney/DevGroup/**
20
CuuDuongThanCong.com
/>
Publish-Subscribe – Some
Thoughts
Highly decoupled messaging style
Publishers don‟t know about subscribers
Subscribers don‟t know who is publishing
Publishers and Subscribers can dynamically appear
and disappear
Issues –
Reliability
Transactions
Security
Performance
21
CuuDuongThanCong.com
/>
J2EE Overview
C lie n t t ie r
B u s in e s s C o m p o n e n t tie r
W e b T ie r
W eb
HTTP
s e rv e r
E I S T ie r
RMI
S e r v le t s ,
A p p lic a t io n c o m p o n e n t s
JSPs
E JB s
B r o w s e r - b a s e d c lie n t
JC A
a p p lic a tio n s
( H T M L , a p p le t s ,
D H T M L / s c r ip t in g )
ER Ps, C R M s,
Java R M I
M a in f r a m e T P s y s t e m s
C o n t a in e r S e r v ic e s
J a v a c lie n t a p p lic a tio n s
C o m p o n e n ts
eg. JTS , JM S
JD BC
RDBMS
C A S C O M B r id g e , R M I o v e r I I O P
W in d o w s / C O M c lie n t
a p p lic a tio n s
CuuDuongThanCong.com
/>
22
J2EE Application Server
In J2EE, the application server container provides the
execution environment for the J2EE-specific
components
EJBs
Message-driven beans
Connectors
Container provides additional services for hosted
components
Transactions
Security
Directory
Threading
Connection pooling
23
CuuDuongThanCong.com
/>
EJB Container
Application Server
EJB Container
EJB Pool
Lifecycle Management
Transaction
Service
Directory
Service
Persistence
Connection Pool
Security
Service
Thread Pool
24
CuuDuongThanCong.com
/>
Beans and State
state
EJB Container
Stateless bean pool
state
state
state
state
EJB
Clients
state
Stateful beans
state
25
CuuDuongThanCong.com
/>