Title: P1246990956DrYmR
1Using Message-Driven Beans in a Service-Oriented
Architecture
Dave Chappell VP Chief Technology Evangelist,
Sonic Software
2(No Transcript)
3(No Transcript)
4(No Transcript)
5Tell Them About the Book Raffle
6Sonic Software
Driving Industry Standards
- 1st J2EE 1.3 Certified MOM!
- HTTP(S), XML, SOAP, WSDL, JMS, JCA
- Java Message Service (JMS)
- Apache Axis
- Web services, JAXM, J2EE CA
- XML Schema
- ebXML
- WS-I
7SonicMQ AppServer Integration
- Borland Appserver
- HP/Bluestone Total-e-server
- BEA Weblogic
- CMT,Clustering, Failover/Reconnect, Design
Patterns - IBM WebSphere
- Oracle Appserver
- MacroMedia
- JBoss (soon)
8Sonic Software
- Recognized Enterprise messaging Integration
middleware - Established Over 500 of Global 2000 rely on
Sonic Software - Strong Independent operating company of Progress
Backing Software Corp. (NASDAQ PRGS) 170M
cash, no debt Distribution in 65 countries,
24x7 world-wide support - History SonicMQ released 12/1999, 1 JMS
product Today SonicMQ 4.0, SonicXQ 1.0
Enterprise Service Bus
9Agenda
- J2EE Message Driven Topology
- JMS Overview
- Using JMS With EJBs
- JMS and XA Integration
- J2EE Connector Architecture
- Service Oriented Architectures and Web Services
10J2EE Topology
EJB Containers
Web Containers
JSP
html
Database
EJB
EJB
servlet
xml
EJB
EJB
xml
JSP
EJB
EJB
EIS
servlet
servlet
EJB
EJB
gifs
jpegs
EJB
Presentation Logic
Business Logic
11J2EE Topology Message Driven
Web Containers
Database
JMS
html
JSP
servlet
servlet
EIS
gifs
jpegs
Presentation Logic
Business Logic
12J2EE Topology Message Driven
EJB Server
EJB Server
EJB Server
Broker
EJB Server
Broker
EJB Server
Trading Partner
Regional Office
EJB Server
Broker
Broker
EJB Server
EJB Server
Business Partner
13Agenda
- J2EE Message Driven Topology
- JMS Overview
- Using JMS With EJBs
- JMS and XA Integration
- J2EE Connector Architecture
- Service Oriented Architectures and Web Services
14Java Message Service (JMS)
- Sun standard
- Common APIs
- Loosely-coupled asynchronous processing
- Senders and receivers abstractly decoupled from
each other - Destinations administratively configurable at
runtime - Point to Point and Pub/Sub messaging models
- Supports synchronous or asynchronous communication
15Java Message Service (JMS)
- Message delivery semantics
- Guaranteed Once-and-only-once
- At-most-once
- Deployment architecture not addressed by
specification - Vendor differentiators
16Java Message Service
Messaging Components
BusinessApplication A
BusinessApplication A
JMSProvider
JMS Messaging API
JMS Messaging API
JMS Messaging Client
JMS Messaging Client
standards based API
17Broad Range of Message Types
MultiPartMessage
Message
BytesMessage
MapMessage
ObjectMessage
StreamMessage
TextMessage
XMLMessage
Included in JMS Specification
Extensions in SonicMQ
18JMS Messages
19JMS Reliability
Persistent messages and durable subscriptions
JMSProvider
Publisher
Subscriber
7. publish() method returns
2. Disconnect
Persistent Store
5. Message retained in persistent store
20JMS Reliability
Transactional Message Send and Receive
JMSProvider
Consumer
Producer
21JMS Reliability
XA Compliant Transaction Manager
commit()
JMSProvider
Producer
rollback()
External Resource (DB/EJB)
22Filtering with message selectors
Publisher
Departments.Sales
JMSPriority 2 Pipeline 20000
not delivered
Subscriber
delivered
Subscriber
Message Server
Departments.Sales Pipeline 20000
Departments.Sales Pipeline 15000
not delivered
delivered
Subscriber
Subscriber
Departments.Sales JMSPriority 5
Departments.Sales JMSPriority 2 AND Pipeline
10000
23JMS as a J2EE Resource
- 2 Requirements to access a Message Provider
- ConnectionFactory
- Creates connection to JMS providers
- Destination Object
- The Specific Topic or Queue
24Obtaining the ConnectionFactory
- Resource Manager Connection Factories as
Administered Objects - Specify standard mechanism for getting
connections to resources outside the J2EE
component - Enables the container to do pooling
- JNDI is used for maximum portability
-
QueueConnectionFactory qcf (QueueConnectionFacto
ry) ctx.lookup("javacomp/env/jms/TrafficConFactor
y")
25Accessing the Destination
- The Specific Queue or Topic
- Retrieved via JNDI
- Specified in the Deployment Descriptor
- Binding to a real Destination done at deploy time
Topic traffic (Topic) ctx.lookup("javacomp/env/
jms/TrafficTopic")
26What the Java/API looks like
// Create a connection factory TopicConnectionFact
ory factory factory (TopicConnectionFactory)jnd
i.lookup("TopicConnectionFactory") // Create a
connection connect factory.createTopicConnection
(username, password) // Create a
session session connect.createTopicSession(true,
Session.AUTO_ACKNOWLEDGE) // Create a
topics. Topic topic (Topic)jndi.lookup("chat")
27What the Java/API looks like
// Create Subscriber to application
topics. TopicSubscriber subscriber
session.createSubscriber(topic) // Initialize
the onMessage() message handler. subscriber.setMes
sageListener(this) // Create a
publisher publsher session.createPublisher(null)
// Topic will be set for each reply // Now
setup is complete, start the Connection connect.st
art()
28What the Java/API looks like
public void onMessage( javax.jms.Message
message) TextMessage textMessage
(TextMessage) message System.out.println(text
Message.getText()) -- OR ... while( true
) textMessage (javax.jms.TextMessage
)qReceiver.receive(1000) ...
29Break
30Do the Book Raffle
31Agenda
- J2EE Message Driven Topology
- JMS Overview
- Using JMS With EJBs
- JMS and XA Integration
- J2EE Connector Architecture
- Service Oriented Architectures and Web Services
32EJB Design Pattern Reminder
Server provides resource mgmt
create lookup remove
home
context
create lookup remove
client
bean
object
methods
methods
Container
Deployment Descriptor
Automatically invokes services based
on requirements defined in deployment descriptor
Remote interface stubs
33MessageDrivenBean
EJB Container
EJB Container
PublisherBean
SubscriberMsg-drivenInstance
Delivers
Publishes
Acknowledges
Stores
Database
DurableSubscription
ClientApp
34MessageDrivenBean
- Defined in EJB 2.x Specification
- Benefits
- Simple to write
- Allow for asynchronous execution
Container
JMS Provider
Msg-driven Bean Class
Msg-drivenBean instances
Destination
Consumer
35MessageDrivenBean
- Executes on receipt of a JMS message
- javax.jms.MessageListener interface
- Shares the following characteristics of stateless
session bean - Is stateless and relatively short- lived
- Security
- Transactions
- Concurrency
- Management
- All the other services that EJBs enjoy!
- Notable difference No home or remote interface
36MessageDrivenBean Interface
- javax.ejb.MessageDrivenBean
- ejbCreate(), ejbRemove()
- setMessageDrivenContext()
- Just like a usual javax.jms.MessageListner
- onMessage(javax.jms.Message)
37MessageDrivenContext
- get/setRollbackOnly()
- getUserTransaction()
- For BMT only
- Others inherited from EJBContext Interface, but
not allowed - getCallerPrincipal()
- isCallerInRole()
- getEJBHome(), getEJBLocalHome()
38Serialization and Concurrency
- Container Must Serialize all calls to an MDB
- ejbCreate(), ejbRemove(), etc
- No need to be coded as re-entrant
- Concurrency
- Container May Launch Multiple Instances of an MDB
- No guarantee of order
- Cancellation Message May Arrive Before
Reservation Message
39MDB Example
- public class SubscriberMsgBean implements
MessageDrivenBean - setMessageDrivenContext( MessageDrivenContext
mdc) .. - MessageDrivenContext mdc null
- public void onMessage( Message inMessage)
- TextMessage msg (TextMessage) inMessage
- try
-
-
- catch( Exception e)
- mdc. setRollbackOnly()
-
-
40MDB Example Deployment Descriptors
-
- ...
- SubscriberMsgBean
- Container
-
- NewsType'Metro/Region
-
-
-
- javax.jms.Topic
-
-
- durable
-
-
- ...
41MDB Example Deployment Descriptors
-
- QueueMessageDriven
-
-
- 20ool
- 1-free-pool
-
- sonicQueuendi-name
-
- com.sun.jndi.fscontext.RefFSContextFactory
-
-
- file//localhost/C/temp/jndi/fileStore/
-
-
- myJMSxaqcf
-
42Agenda
- J2EE Message Driven Topology
- JMS Overview
- Using JMS With EJBs
- JMS and XA Integration
- J2EE Connector Architecture
- Service Oriented Architectures and Web Services
43Distributed Transaction Processing (DTP)
44A local instance of a DTP system
RM
RM
45Local DTP zoom in
EJB
Application Server
JMS Provider
TransactionManager
JMS XA API
XA Resource
SonicMQ Client
JMS Client
46XA interfaces
- JMS XA SPI
- XAConnectionFactory
- XAConnection
- XASession
- XAQueueConnectionFactory
- XAQueueConnection
- XAQueueSession
- XATopicConnectionFactory
- XATopicConnection
- XATopicSession
47Agenda
- J2EE Message Driven Topology
- JMS Overview
- Using JMS With EJBs
- JMS and XA Integration
- J2EE Connector Architecture
- Service Oriented Architectures and Web Services
48J2EE Directions
- J2EE 1.3
- Web Applications
- Asynchronous
- JMS
- MDB
- EJB 2.0
- J2EE 1.4
- SOA Platform
- Web Services
- JAX-RPC
- JSR-109
- J2EE Connector Architecture
- EJB 2.1
- WSEI
49J2EE Connector Architecture Overview
- Defines standard for connecting J2EE to
enterprise information systems (EIS) - System contracts define interface specification
with EIS - Connection, Transaction, Security
50J2EE Connector Architecture Overview
- Resource adapters
- Implements the EIS side of the system contracts
- System-level software drivers for connecting to
an EIS - Enables vendors to create standardized connectors
to EIS - Common client interface
- Standard API for applications to interact with
heterogeneous EIS
51Inbound Communication Model
ResourceAdapter
JMS Destination
WorkMgmt
JMSDisp
EnterpriseJavaBeans
EJBDisp
52Agenda
- J2EE Message Driven Topology
- JMS Overview
- Using JMS With EJBs
- JMS and XA Integration
- J2EE Connector Architecture
- Service Oriented Architectures and Web Services
53Service-Oriented Architecture
Global Enterprise
Internet
Web Service
54Service-Oriented Architectures (SOA)
Architecture for a Distributed World
- System design methodology using existing
application components - Applications expose functionality through service
interfaces - Loosely-coupled, asynchronous, coarse-grained
- Distributed across internal networks or the
Internet - Web services
- Software services built on standards SOAP, WSDL,
UDDI, XML, HTTP
55Web Services Technology Stack
56Web Services Technology Stack
XML-RPC(SOAP-RPC, JAX-RPC)
XML Messaging(SOAP, ebXML,JAXM)
57Connecting (Web) Services Together
What Else Do You Need?
- (Web) Services arent Islands of Themselves
- Network of Cooperative Services
- Interfaces, Discovery, and Data Formats are only
part of the big picture - Data transformation
- Intelligent Routing based on content
- End-to-end guaranteed delivery
- Management, configuration, and auditing
- Performance and scalability
- Asynchronous and synchronous messaging
- Security
- Deployment tools
58Standards Working Together...
Web Client
JAXM/RPC Client
.NET SOAP Client
Apache Client
SOAP/HTTP
SOAP/HTTP
SOAP/HTTP
SOAP/HTTP
Internet
Servlet Container
SOAP/HTTP SOAP/JMS
SOAP/HTTP SOAP/JMS
SOAP/HTTP SOAP/JMS
JMS Messaging Backbone
JCA/EIS
JCA/EIS
EJBContainer
JMS Client
C Client
59Contact Information
- Chappell_at_sonicsoftware.com
- http//www.sonicsoftware.com
Integrate with Ease. Extend at WillTM.