java messaging service
TRANSCRIPT
M
D Copyright 2004-2008 Dan McCreary & Associates 1
Java Messaging Service (JMS)and Enterprise Messaging Strategy
Author: Dan McCreary
Date: 7/20/2004
Version: 0.1
M
D Copyright 2004-2008 Dan McCreary & Associates 2
Objectives
• Understand strategies for computer-to-computer messaging
• Understand how vendors attempt to lock-in customers using proprietary communication APIs
• Understand why the Java Messaging Service (JMS) is becoming the de-facto vendor-neutral messaging interface between J2EE systems and how JMS helps avoid vendor lock-in
• Understand the differences between messaging systems
• Understand how messaging systems interoperate
• Understand how JMS fits in with other EAI architectures such as Web Services, SOA, ESB, Multi-tier architectures, J2EE Architecture, JCA, Microsoft BizTalk, RosettaNet
• Understand how future systems will interoperate
• Review references
M
D Copyright 2004-2008 Dan McCreary & Associates 3
Messaging Strategy Overview
1. Support cost effective reliable messaging between state law enforcement agencies
2. Allow messages to have guaranteed delivery and be fully encrypted
3. Avoid vendor-specific APIs
4. Integrate with search and workflow
5. Be flexible for future standards
6. Make it easy for developers to use
M
D Copyright 2004-2008 Dan McCreary & Associates 4
Vendor Lock-In
• Definition: When you spend a lot of time and money building your products around a specific vendor's solution.
• Vendor lock-in prevents you from moving your application to another vendor or an open-source solution
– Vendor lock-in is Bad
– Portability between vendors is Good• Successful Enterprise Architecture Strategies attempt
to minimize dependencies on any product due to:– Excessive licensing fees
– Excessive support fees
– Vendor support for a specific product
– Vendor stability
M
D Copyright 2004-2008 Dan McCreary & Associates 5
Application Portability
• To promote portability and prevent vendor lock-in, whenever there is a choice between a vendor-neutral-industry-standard service interface and a vendor specific interface, always use the vendor-neutral standard unless you have a BUSINESS REASON to use the vendor specific interface
Application
Service
VendorNeutralService
Interface
VendorSpecificService
Interface
M
D Copyright 2004-2008 Dan McCreary & Associates 6
What is A Message?• A communication between two things
(people, computers)
• Typical questions:– Who was the message from?
– What is the destination?
– Was the message actually received by the recipient?
– Was it understood? (what restaurant?, 8am or 8pm?)
– Should it be acknowledged?
– Could it have been tampered with in transit?
– Who really sent it?
Joe,
Lets meet for lunch atthe restaurant at 8.
- John
M
D Copyright 2004-2008 Dan McCreary & Associates 7
Definition
Messaging: a method of communication between software components or applications– E-mail is also messaging but it is person to
person– In this tutorial, messaging is computer to
computer
M
D Copyright 2004-2008 Dan McCreary & Associates 8
Messaging System
• A Messaging System is a peer-to-peer facility to allow any number computer applications to communicate with each other
• A messaging application can send messages to, and receive messages from, any other application
• Each client connects to a messaging interface that provides facilities for creating, sending, receiving, and reading messages.
Application
Interface
Application
Interface
M
D Copyright 2004-2008 Dan McCreary & Associates 9
Messaging Clients
• A Messaging Client is a system that handles the communication between the application interface and the physical network
• A client can be either an open-source product or a commercial product
• Clients deal with issues such as how to send a message over an unreliable network
Application
Interface
Application
Interface
Client Client
M
D Copyright 2004-2008 Dan McCreary & Associates 10
Store and Forward
• Messaging clients deal with issues such as how to send a message over an unreliable network with guaranteed security once-and only-once-delivery so that messages can be part of reliable distributed transactions (ACID)
Application
Interface
Application
Interface
Client Client
MessageServer
Store &Forward
MessageServer
Store &Forward
Unreliable Network
Unreliable Network
M
D Copyright 2004-2008 Dan McCreary & Associates 11
Java Transaction API
• Java Transactions are handled by the Java Transaction API (JTA)
• The JTA makes it easy for Java programmers to do complex transactions involving data on multiple J2EE systems located over a wide area network (WAN)
• JTA depends on Messages Beans (MBean) and therefore JMS
• JTA makes ACID transactions possible
M
D Copyright 2004-2008 Dan McCreary & Associates 12
ACID Test
• Atomicity – all or nothing – a transaction either completely succeeds or it completely fails – nothing in between
• Consistency – meet constraints of endpoints such as non-duplicate ID numbers
• Isolation – each transaction has a consistent view of the world
• Durability – once committed the transaction will endure regardless of single component failure
M
D Copyright 2004-2008 Dan McCreary & Associates 13
A Wire Protocol
• A wire protocol is an agreed upon standard between two systems (potentially built with different technologies) that defines how they will communicate with each other
Format of messages "on the wire"
Examples: HTTP (web), SMTP (mail), SNMP (monitoring) and SOAP
M
D Copyright 2004-2008 Dan McCreary & Associates 14
System Coupling
• TIGHT: Systems that are very rigid in their requirements
• System 2 MUST respond to a message before System 1 can proceed to the next activity
• LOOSE: Where programmers just send a message and can be assure the infrastructure will do whatever it needs to do send the message
System 1 System 2
System 1 System 2
Tight Coupling
Loose Coupling
M
D Copyright 2004-2008 Dan McCreary & Associates 15
Tightly Coupled Communications
• Sender needs a remote service and calls a remote procedure call• The sending process “Stops” and waits for a reply• Synchronous messaging – don’t proceed till we are synchronized up• The sender will “freeze” if the network is down or the sender will have to
manually keep trying till the remote system is up and it gets a response• Remote procedure call (RPC), Java Remote Method Invocation (RMI)
System 1
Unreliable Network
Unreliable Network
System 2
M
D Copyright 2004-2008 Dan McCreary & Associates 16
Loosely Coupled Communications
• Programmers just “fire and forget”• There is no “blocking” of sender’s process• System 1 just gets a reply message when the data request has been received• System can transmit messages to remote systems even when the remote system is down or
the network has failed. Messages wait patiently in the queue till the network is back up.• System administrators can monitor the message queues and be notified of congestions• High priority messages can take precedence over large, batch transfers
System 1
Unreliable Network
Unreliable Network
System 2
MessageQueue
MessageQueue
M
D Copyright 2004-2008 Dan McCreary & Associates 17
Application Program Interface (API)• A formal set of interfaces definitions used by programmers
• Usually a specified in SPECIFIC language such as Java or C
• Java Messaging Service (JMS) is an API
• JMS was designed to be a wrapper API around existing messaging systems
J2EEApplication(JMS Client)
JMS Provider
JMS API
J2EEApplication(JMS Client)
JMS Provider
JMS API
Messaging System
M
D Copyright 2004-2008 Dan McCreary & Associates 18
APIs Promote Portability
• Applications DO NOT call an vendor interface directly
• Applications call the industry standard and let the transport mechanism move the data
Sun Certified J2EE 1.3+Application Server
JMS Interface
Application
Transport Mechanism
Vendor Interface
M
D Copyright 2004-2008 Dan McCreary & Associates 19
JMS is part of J2EE
• In order to be a Sun-certified J2EE 1.3+ compliant, the application server MUST support the JMS interface (1.2 was only recommended)
• Any object can use the JMS API
• JMS is THE default application server messaging interface
Sun Certified J2EE 1.3+Application Server
JMS Interface
Transport Mechanism
Application
M
D Copyright 2004-2008 Dan McCreary & Associates 20
JMS Details
• JMS is a Messaging API Specification
• Published and maintained by Sun Microsystems
• First published in August 1998.
• Latest version is Version 1.0.2b
• See http://java.sun.com/products/jms/
M
D Copyright 2004-2008 Dan McCreary & Associates 21
Goals of JMS
• Minimizes the set of concepts a programmer must learn to use messaging products (programmer friendly)
• Provides enough features to support sophisticated messaging applications
• Maximize the portability of JMS applications across JMS providers in the same messaging domain
M
D Copyright 2004-2008 Dan McCreary & Associates 22
Benefits of JMS
• Simplifies enterprise development
• Allows loosely coupled systems (systems that don't block each other)
• Provides reliable messaging over an unreliable network
• Promotes secure messaging between systems
• Messages between JMS systems can be encrypted
M
D Copyright 2004-2008 Dan McCreary & Associates 23
Vendors Passing JMS Compatibility Tests
Part of the J2EE SDK version 1.3. J2EE
Must licensees Sun technology to be certified
• BEA Systems, Inc.
• Hewlett-Packard
• IBM
• JBoss
• Sun
• Macromedia
• Oracle Corporation
• Pramati
• SeeBeyond
• SilverStream Software, Inc. (Novell)
• Sonic Software
• SpiritSoft, Inc.
• Talarian Corp.
• TIBCO Software, Inc.
M
D Copyright 2004-2008 Dan McCreary & Associates 24
JMS is NOT a Wire Protocol
• The JMS API is promoted as a technology for providing high-quality reliable communication between components within an enterprise, but not for business-to-business (B2B) communication between enterprises over the Internet
• JMS is an insulator for proprietary messaging APIs
• JMS is not a router to router specification
M
D Copyright 2004-2008 Dan McCreary & Associates 25
JBoss and JBossMQ
• JBoss has an implementation of the JMS interface
• JBoss has an implementation of the JMS transport service
• JMS isolates the application from dependencies of specific transport systems
JBoss
JMS Interface
JBossMQ
Application
M
D Copyright 2004-2008 Dan McCreary & Associates 26
JBossMQ
• Initially released as spyderMQ
• "clean room" implementation– programmers given an interface specification
but have never seen similar systems – very low risk of copyright infringement
• First release April 2000
• Active users migrated from standalone spyderMQ to JBossMQ
M
D Copyright 2004-2008 Dan McCreary & Associates 27
JBossMQ
• Full implementation of JMS specification including:– Point-to-point– Publish-subscribe– Durable subscribers– JMS Application Server Facilities– Global work units can be coordinated by
transaction manager
M
D Copyright 2004-2008 Dan McCreary & Associates 28
When to Use a JMS Interface?
• The provider wants the components not to depend on information about other components' interfaces, so that components can be easily replaced
• The provider wants the application to run whether or not all components are up and running simultaneously
• The application business model allows a component to send information to another and to continue to operate without receiving an immediate response
M
D Copyright 2004-2008 Dan McCreary & Associates 29
ISO Seven Layer Reference Model
• Seven layers of "Abstraction" that allows applications to communicate with each other
• Lowest level is the physical wire
• Internet Protocol is in the middle
Physical
Data Link
Network
Transport
Session
Presentation
Application
M
D Copyright 2004-2008 Dan McCreary & Associates 30
Communication Occurs at the Lowest Level
Physical
Data Link
Network
Transport
Session
Presentation
Application
Physical
Data Link
Network
Transport
Session
Presentation
Application
M
D Copyright 2004-2008 Dan McCreary & Associates 31
What is a "Common Language"?
Sound
Phonemes
Words
Sentences
Conversation
Problem Solving
M
D Copyright 2004-2008 Dan McCreary & Associates 32
Computer to Computer
Internet
XML
XML Tags
XML Schemas
Interface Definitions
Service Level Agreements
WSDL
M
D Copyright 2004-2008 Dan McCreary & Associates 33
Publish/Subscribe Securely
Subscriber 1
Publisher 1
Criminal Justice Information Bus
Publisher 2 Publisher 3
Subscriber 2 Subscriber 3
Authentication
M
D Copyright 2004-2008 Dan McCreary & Associates 34
3 EAI Architectures
Presentation
Database
MethodMethod
Presentation
Database
Presentation
Method
Data
M
D Copyright 2004-2008 Dan McCreary & Associates 35
Evolution of EAI
Share process
Share read-write data
Share read-onlydata
M
D Copyright 2004-2008 Dan McCreary & Associates 36
Why Share Process?
• Sharing data requires you to know who has the right data: the synchronization problem and the metadata problem.
• Sharing process allows you to avoid rewriting code.
• Quality of data is dependant on the process that validate it.
M
D Copyright 2004-2008 Dan McCreary & Associates 37
Challenges: Share Process and Data
• Allow any application developer to easily allow both user and programmatic access to application services.
• Often requires developers to re-conceptualize their applications as a series of published services: e.g. Web Service
M
D Copyright 2004-2008 Dan McCreary & Associates 38
EAI is Expensive
• Up to 30% of costs of installing enterprise applications are related to integration.– Gartner Group
Initial LicenseCosts
Integration Costs
M
D Copyright 2004-2008 Dan McCreary & Associates 39
Asynchronous Messaging
• Ways that objects communicate
• A service of the underlying operating system
• Allows programmers to “fire and forget”
M
D Copyright 2004-2008 Dan McCreary & Associates 40
Message Brokers
Use of a broker will reduce these integration costs by one-third. During maintenance, when a single change to an application can have a rippling effect on several to several dozen interfaces, use of a broker can reduce costs by two-thirds.“
- Gartner Group
M
D Copyright 2004-2008 Dan McCreary & Associates 41
Message Queuing
• Message Oriented Middleware – Product Classification
• IBM MQSeries - Product
• Microsoft MSMQ - Product
• Java 2 Enterprise Edition (J2EE 1.4)- J2EE – Application Server Standard
• Java Messaging Service - JMS
M
D Copyright 2004-2008 Dan McCreary & Associates 42
Messaging Benefits
• Messaging infrastructure guarantees reliable delivery of a message
• Once and only once delivery
• Messages can have different priority
• Transactional control
• Transactions can be grouped together
• Support of “undo” – reversible operations
M
D Copyright 2004-2008 Dan McCreary & Associates 43
Similar to E-mail
Header:Header:To: From: Subject:
Priority: Urgent
To: From: Subject:Priority: Urgent
BodyBody
Recipientse-MailServer
OutgoingMail
Server
M
D Copyright 2004-2008 Dan McCreary & Associates 44
When we send e-mail…
• Sender sends a message to the outgoing e-mail server using a standard format ( e.g. Simple Mail Transfer Protocol)
• Message is routed to receiver’s e-mail server
• Message stored in e-mail server till the receiver picks up the message
• Example of asynchronous processing
M
D Copyright 2004-2008 Dan McCreary & Associates 45
Message Structure
HeaderHeader
PropertiesProperties
BodyBody
M
D Copyright 2004-2008 Dan McCreary & Associates 46
Object to Object Messaging
HeaderHeader
PropertiesProperties
BodyBody
MessageQueue
M
D Copyright 2004-2008 Dan McCreary & Associates 47
Header
• Identify message• Destination• Routing Information• Priority• Timestamp• Reply to• Message type
HeaderHeader
PropertiesProperties
BodyBody
M
D Copyright 2004-2008 Dan McCreary & Associates 48
Properties
• Added by the application developer
• Application specific properties
• Key-value pairs– KEYWORD=VALUE
• Extensions for messaging systems
HeaderHeader
PropertiesProperties
BodyBody
M
D Copyright 2004-2008 Dan McCreary & Associates 49
Body
• Message body• Can contain arbitrary data
types– Text messages
– Map (key-value pairs)
– XML
– Serialized objects (Java)
– Binary data
– Empty
HeaderHeader
PropertiesProperties
BodyBody
M
D Copyright 2004-2008 Dan McCreary & Associates 50
Message Example
To: My Enterprise Service BusTo: My Enterprise Service Bus
TransactionNumber=12345TransactionNumber=12345
<?xml version="1.0"?><RequestedAction>Person Search</RequestedAction><Person> <PersonSurName>Jones</PersonSurName> <PersonGivenName>Sam</PersonGivenName> <PersonBirthDate>1980-12-31</PersonBirthDate></Person>
<?xml version="1.0"?><RequestedAction>Person Search</RequestedAction><Person> <PersonSurName>Jones</PersonSurName> <PersonGivenName>Sam</PersonGivenName> <PersonBirthDate>1980-12-31</PersonBirthDate></Person>
M
D Copyright 2004-2008 Dan McCreary & Associates 51
JMS Modes
• One-to-one (aka Point-to-point)– Send a message to a JMS Queue
– One message reader
• One-to-Many (aka Publish-subscribe)– Send (publish) message to a JMS Topic
– Enables many readers (subscribers)
– Also enables many-to-many subscription
Queue
Message
Receiver
Sender
Topic
Message
Subscriber
Sender
Subscriber
M
D Copyright 2004-2008 Dan McCreary & Associates 52
Required Header Types
• Automatic – automatically put in EVERY message by the system
• Developer-Assigned – required headers that must be set before a send()
M
D Copyright 2004-2008 Dan McCreary & Associates 53
Automatic Header Information
• Destination – where to send the message (either a queue or a topic)
• DeliveryMode – reliable or not• MessageID – number that identifies the message• Timestamp – date and time that send() was called• Expiration – time to live in milliseconds – by
default is does not expire• Redelivered – not the first try• Priority – Should this message be expedited?
M
D Copyright 2004-2008 Dan McCreary & Associates 54
Priority Messages
• The JMS API defines ten levels of priority value
• 0 as the lowest priority
• 9 as the highest
• 0-4 are gradations of normal priority and priorities
• 5-9 are gradations of expedited priority
M
D Copyright 2004-2008 Dan McCreary & Associates 55
Developer Assigned
• ReplyTo – who should the receiver send a reply to
• CorrlationID – how this message is related to previous messages
• Type – The type of the payload – binary, text, XML etc.
M
D Copyright 2004-2008 Dan McCreary & Associates 56
Multi-Tier Architecture
Presentation
Control
Process
Persistence
Database
Window Controller
Customer Order
Database Adapter
Customer
First Name:
Last Name:
Phone:
Save
Database
M
D Copyright 2004-2008 Dan McCreary & Associates 57
J2EE Container Architecture
• J2EE allows developers to create "beans" that inherit common characteristics
• Everything inside a container can have a common set of characteristics
• Data, Communication, Security
Application Server
Container
Bean
Bean Bean
M
D Copyright 2004-2008 Dan McCreary & Associates 58
J2EE Bean Types
• J2EE allows developers to create "beans" that inherit common characteristics
• Everything inside a container can have a common set of characteristics
• Data, Communication, Security
Application Server
Container
MessageBeanEntity
Bean
SessionBean
DBJMS Provider
User
M
D Copyright 2004-2008 Dan McCreary & Associates 59
JCA: J2EE Connection Architecture
Application Server
Container
Connection PoolManager
TransactionManager
SecurityServicesManager
Application ComponentApplication Component
Container-ComponentContract
SystemContract Resource Adapter
Application Contract
EIS-specific Interface
Enterprise InformationSystem
M
D Copyright 2004-2008 Dan McCreary & Associates 60
Bridges
• Bridges translate from one vendor system into another
• Example IBM-MQ to/from MSMQ
• Some loss of information when headers do not have precise mappings
• Allows interoperability
Vendor A Vendor B
Translation
M
D Copyright 2004-2008 Dan McCreary & Associates 61
JMS and Web Services
• Web service are similar yet different from JMS
• Web services is vendor and language neutral (works with Microsoft, C#, VB etc.)
• Web service can have semantically clear published interfaces
• Web service are not inherently reliable and do not offer standards for retransmission
• Built on SOAP which is extensible
M
D Copyright 2004-2008 Dan McCreary & Associates 62
SOAP is a wire protocol for exchanging messages
• Any XML tags can be added to SOAP header to tell the receiving system how to transmit the message
• Security can also be added
• Must agree on what tags to use
SOAP DocumentSOAP DocumentSOAP Header
SOAP Body
M
D Copyright 2004-2008 Dan McCreary & Associates 63
Future WS-Reliable, WS-Secure
• New web-service standards to provide wire-protocol reliable and secure web services
• Emerging standards from IBM, Microsoft, TIBCO etc.
• Sun, Oracle have a similar standard WS-Reliability
• Wait for standards to shake out before adopting
M
D Copyright 2004-2008 Dan McCreary & Associates 64
CriMNet Tiers
CriMNetServices
Servlets
XML/XSLT
MessageProcessing
RequestHandler
RulesProcessing
SessionManager
SessionController
Interactwith the
Database
AccessSecurity
Operations ConsoleŸ Monitoring,Ÿ Reporting,Ÿ Administration
Registry(Unique ID’s)
JSP w/Custom Tags
CriMNet websiteŸ Registration
RequestŸ Locater / Query
RequestŸ Web Site
.
.
.
Locator
CriMNetHelper
NaturalLanguageTranslator
CriMNetDatabase
Interface withLegacy systems
(e.g. local agencies)
ClientŸ Browser (SSL)Ÿ Custom App via
https
Logging
QueryServices
AssociationServices
Other CriMNet Hub
Point-to-Point
Publish
OperationalSystems
JMS Server
Admin
Messaging
Engines
Biometrics
Fax Server
DirectoryServices
Custom
Adaptor
Registry
Logging
Config
Profiles
Meta Data
Critical Data
Rules
Archiving
Services
Search Module
Registration
Tier
CriMNetCommunication
Tier
CriMNet Hub Server
HTTPS
From January 2000 Macro Group Logical Architecture
M
D Copyright 2004-2008 Dan McCreary & Associates 65
BizTalk Architecture
BizTalk ServerBizTalk Server BizTalk ServerBizTalk Server
ApplicationApplication
AdapterAdapter
BizTalk DocBizTalk DocHeader
Body
BizTalk DocBizTalk DocHeader
Body
Transport EnvelopeTransport Envelope
BizTalk Message
InternetInternet
M
D Copyright 2004-2008 Dan McCreary & Associates 66
BizTalk Constraints
• Protocols are proprietary to Microsoft
• XLang is only used by Microsoft
• All endpoints are MSMQ
M
D Copyright 2004-2008 Dan McCreary & Associates 67
RosettaNet
• Agree on bottom six layers of OSI model
• Subdivide application layer into seven distinct layers
PhysicalData LinkNetwork
Presentation
Application
SessionTransport
Security
Transfer
Agent
Service
Process
Transaction
Action
Message Handling
M
D Copyright 2004-2008 Dan McCreary & Associates 68
JMS and ESB
"An ESB can be a sensible first step toward a systematic Enterprise Nervous System because it provides the basic connectivity backbone. It can interoperate with a variety of disparate application servers simultaneously, smoothing over technical differences and also providing services for communication and integration.”
Roy SchulteVP and Research FellowGartner Research
M
D Copyright 2004-2008 Dan McCreary & Associates 69
References
• Best high-level book for EAI architects using J2EE– J2EE Connector
Architecture and Enterprise Application Integration (by Sharma, Stearns and Ng)
M
D Copyright 2004-2008 Dan McCreary & Associates 70
JMS Textbooks
1. Java Message Serviceby Richard Monson-Haefel and David ChappellGood explanation on how to use JMS for programmers
2. Java Message Service API Tutorial and Reference: Messaging for the J2EE Platform by Mark Hapner, Rich Burridge, Rahul Sharma, Joseph Fialli, Kim Haase
3. Enterprise JMS Programmingby Shaun Terry
M
D Copyright 2004-2008 Dan McCreary & Associates 71
JBossMQ
• JBoss Administration and Developmentby Marc Fleury, Scott Stark
• Chapter 4 has an excellent chapter on JMS and JBossMQ
• Chapter 6 covers Transactions
• Chapter 7 covers Connector Architecture
• (book only covers JBoss up to 2.4.x)
M
D Copyright 2004-2008 Dan McCreary & Associates 72
Thank You!
Please contact me for more information:• Enterprise Service Bus• Native XML Databases• Metadata Management• Metadata Registries• Service Oriented Architectures• Business Intelligence and Data Warehouse• Semantic Web
Dan McCreary, PresidentDan McCreary & Associates
Metadata Strategy [email protected]
(952) 931-9198