Transcript Java Messaging Service (JMS) and Enterprise Messaging Strategy
M
Java Messaging Service (JMS) and Enterprise Messaging Strategy Author
: Dan McCreary
Date: 7/20/2004 Version:
0.1
1 D
Copyright 2004-2008 Dan McCreary & Associates
Objectives
M
• 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
D
Copyright 2004-2008 Dan McCreary & Associates
2
Messaging Strategy Overview
M
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
D
Copyright 2004-2008 Dan McCreary & Associates
3
M D
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 Copyright 2004-2008 Dan McCreary & Associates
4
Application Portability
M D Application Vendor Neutral Service Interface Service Vendor Specific Service Interface
• 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 Copyright 2004-2008 Dan McCreary & Associates
5
M D
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?
6
Copyright 2004-2008 Dan McCreary & Associates
M D
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 Copyright 2004-2008 Dan McCreary & Associates
7
M D
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 Application Interface Interface
Copyright 2004-2008 Dan McCreary & Associates
8
M D
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 Application Interface Client Interface Client
Copyright 2004-2008 Dan McCreary & Associates
9
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)
Unreliable Network Application Interface Client M D Message Server Store & Forward Message Server Store & Forward
Copyright 2004-2008 Dan McCreary & Associates
Application Interface Client 10
Java Transaction API
M D
• 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 Copyright 2004-2008 Dan McCreary & Associates
11
M D
ACID Test
• • • •
A
tomicity – all or nothing – a transaction either completely succeeds or it completely fails – nothing in between
C
onsistency – meet constraints of endpoints such as non-duplicate ID numbers
I
solation
–
each transaction has a consistent view of the world
D
urability – once committed the transaction will endure regardless of single component failure Copyright 2004-2008 Dan McCreary & Associates
12
M D
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
Copyright 2004-2008 Dan McCreary & Associates
13
M D System 1 System 1
System Coupling
Tight Coupling System 2 System 2
•
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 Coupling
•
LOOSE:
Where programmers just send a message and can be assure the infrastructure will do whatever it needs to do send the message Copyright 2004-2008 Dan McCreary & Associates
14
Tightly Coupled Communications
System 1 System 2 Unreliable Network M D
• • • • • 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) Copyright 2004-2008 Dan McCreary & Associates
15
Loosely Coupled Communications
System 1 Message Queue Unreliable Network Message Queue System 2 M
• • • • • • 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
D
Copyright 2004-2008 Dan McCreary & Associates
16
M D
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
J2EE Application (JMS Client) JMS API JMS Provider Messaging System J2EE Application (JMS Client) JMS API JMS Provider
Copyright 2004-2008 Dan McCreary & Associates
17
APIs Promote Portability
M D Sun Certified J2EE 1.3+ Application Server Application JMS Interface Vendor Interface Transport Mechanism
• Applications DO NOT call an vendor interface directly • Applications call the industry standard and let the transport mechanism move the data Copyright 2004-2008 Dan McCreary & Associates
18
JMS is part of J2EE
M D Sun Certified J2EE 1.3+ Application Server Application JMS Interface
• 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
Transport Mechanism
• JMS is
THE
default application server messaging interface Copyright 2004-2008 Dan McCreary & Associates
19
M D
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/ Copyright 2004-2008 Dan McCreary & Associates
20
M D
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 Copyright 2004-2008 Dan McCreary & Associates
21
Benefits of JMS
M D
• 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 Copyright 2004-2008 Dan McCreary & Associates
22
M
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.
23 D
Copyright 2004-2008 Dan McCreary & Associates
JMS is NOT a Wire Protocol
M D
• 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 Copyright 2004-2008 Dan McCreary & Associates
24
JBoss and JBossMQ
M D JBoss Application JMS Interface 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 Copyright 2004-2008 Dan McCreary & Associates
25
M D
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 Copyright 2004-2008 Dan McCreary & Associates
26
M D
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 Copyright 2004-2008 Dan McCreary & Associates
27
When to Use a JMS Interface?
M
• 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
D
Copyright 2004-2008 Dan McCreary & Associates
28
ISO Seven Layer Reference Model
M D Application Presentation Session Transport Network Data Link Physical
• Seven layers of "Abstraction" that allows applications to communicate with each other • Lowest level is the physical wire • Internet Protocol is in the middle Copyright 2004-2008 Dan McCreary & Associates
29
M D
Communication Occurs at the Lowest Level
Application Presentation Session Transport Network Data Link Physical Application Presentation Session Transport Network Data Link Physical
Copyright 2004-2008 Dan McCreary & Associates
30
M D
What is a "Common Language"?
Problem Solving Conversation Sentences Words Phonemes Sound
Copyright 2004-2008 Dan McCreary & Associates
31
M D
Computer to Computer
Service Level Agreements Interface Definitions XML Schemas XML Tags XML Internet WSDL
Copyright 2004-2008 Dan McCreary & Associates
32
Publish/Subscribe Securely
M D Publisher 1 Publisher 2 Publisher 3 Criminal Justice Information Bus Subscriber 1 Subscriber 2 Subscriber 3 Authentication
Copyright 2004-2008 Dan McCreary & Associates
33
3 EAI Architectures
Presentation Presentation Presentation Method Method Method M D Database Data Database
Copyright 2004-2008 Dan McCreary & Associates
34
M D
Evolution of EAI
Share process Share read-write data Share read-only data
Copyright 2004-2008 Dan McCreary & Associates
35
M D
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.
Copyright 2004-2008 Dan McCreary & Associates
36
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
37
Initial License Costs
EAI is Expensive
• Up to 30% of costs of installing enterprise applications are related to integration.
–
Gartner Group
M D Integration Costs
Copyright 2004-2008 Dan McCreary & Associates
38
M D
Asynchronous Messaging
• Ways that objects communicate • A service of the underlying operating system • Allows programmers to “fire and forget”
39
Copyright 2004-2008 Dan McCreary & Associates
M D
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
Copyright 2004-2008 Dan McCreary & Associates
40
M D
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 Copyright 2004-2008 Dan McCreary & Associates
41
M D
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 Copyright 2004-2008 Dan McCreary & Associates
42
M D Outgoing Mail Server
Similar to E-mail
Header: To: From: Subject: Priority: Urgent Body Recipients e-Mail Server
Copyright 2004-2008 Dan McCreary & Associates
43
When we send e-mail…
M D
• 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 Copyright 2004-2008 Dan McCreary & Associates
44
M D
Message Structure
Header Properties Body
Copyright 2004-2008 Dan McCreary & Associates
45
M D
Object to Object Messaging
Header Properties Body Message Queue
Copyright 2004-2008 Dan McCreary & Associates
46
M D Header Properties Body
Header
• Identify message • Destination • Routing Information • Priority • Timestamp • Reply to • Message type Copyright 2004-2008 Dan McCreary & Associates
47
M D Header Properties Body
Properties
• Added by the application developer • Application specific properties • Key-value pairs – KEYWORD=VALUE • Extensions for messaging systems
48
Copyright 2004-2008 Dan McCreary & Associates
M D Header Properties Body
Body
• Message body • Can contain arbitrary data types – Text messages – Map (key-value pairs) –
XML
– Serialized objects (Java) – Binary data – Empty
49
Copyright 2004-2008 Dan McCreary & Associates
M D
Message Example
To: My Enterprise Service Bus TransactionNumber=12345
Copyright 2004-2008 Dan McCreary & Associates
50
JMS Modes
• One-to-one (aka Point-to-point) – Send a message to a JMS Queue – One message reader
Sender Message Queue Receiver M D Sender
• One-to-Many (aka Publish-subscribe) – Send (publish) message to a JMS Topic – Enables many readers (subscribers) – Also enables many-to-many subscription
Message Subscriber Topic Subscriber
Copyright 2004-2008 Dan McCreary & Associates
51
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
52
Automatic Header Information
M
• 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?
D
Copyright 2004-2008 Dan McCreary & Associates
53
M D
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 Copyright 2004-2008 Dan McCreary & Associates
54
M D
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.
Copyright 2004-2008 Dan McCreary & Associates
55
M D
Multi-Tier Architecture
Presentation Control Process Persistence Database
Customer First Name: Last Name: Phone: Save
Customer Window Controller Order Database Adapter Database
Copyright 2004-2008 Dan McCreary & Associates
56
J2EE Container Architecture
M D Bean Container Bean Bean Application Server
• J2EE allows developers to create "beans" that inherit common characteristics • Everything inside a container can have a common set of characteristics • Data, Communication, Security Copyright 2004-2008 Dan McCreary & Associates
57
J2EE Bean Types
User M DB D Session Bean Entity Bean Container Message Bean Application Server
• J2EE allows developers to create "beans" that inherit common characteristics • Everything inside a container can have a common set of characteristics
JMS Provider
• Data, Communication, Security Copyright 2004-2008 Dan McCreary & Associates
58
JCA: J2EE Connection Architecture
M D Container Connection Pool Manager Transaction Manager Security Services Manager Application Server Container-Component Contract Application Component Application Contract System Contract Resource Adapter EIS-specific Interface Enterprise Information System
Copyright 2004-2008 Dan McCreary & Associates
59
Bridges
Translation M Vendor A Vendor B
• 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
D
Copyright 2004-2008 Dan McCreary & Associates
60
JMS and Web Services
M
• Web service are similar yet different from JMS • Web services is vendor and language neutral (works with Microsoft, C#, VB etc.)
D
• 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 Copyright 2004-2008 Dan McCreary & Associates
61
SOAP is a wire protocol for exchanging messages
M D SOAP Document SOAP Header SOAP Body
• 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 Copyright 2004-2008 Dan McCreary & Associates
62
M D
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 Copyright 2004-2008 Dan McCreary & Associates
63
M D CriMNet Helper Engines
Natural Language Translator Biometrics Fax Server Directory Services Custom
CriMNet Database
Registry Logging Config Profiles Meta Data Critical Data Rules Archiving
CriMNet Tiers
CriMNet Hub Server CriMNet Services Tier
Interact with the Database Registration Registry (Unique ID’s) Association Services Search Module Query Services Rules Processing Message Processing Access Security Logging Admin
.
.
.
Interface with Legacy systems (e.g. local agencies)
CriMNet Communication Tier
CriMNet website Registration Request Locater / Query Request Web Site Servlets XML/XSLT JSP w/Custom Tags Session Manager Session Controller Request Handler JMS Server Point-to-Point Publish Messaging Adaptor
Operations Console
Monitoring, Reporting, Administration HTTPS
Client
Browser (SSL) Custom App via https Other CriMNet Hub Operational Systems
64
BizTalk Architecture
BizTalk Doc Header Body Application Adapter BizTalk Server M D BizTalk Message Transport Envelope BizTalk Doc Header Body Internet
Copyright 2004-2008 Dan McCreary & Associates
BizTalk Server 65
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
66
RosettaNet
M D Application Action Transaction Process Service Agent Message Handling Transfer Presentation Session Transport Network Data Link Physical Security
• Agree on bottom six layers of OSI model • Subdivide application layer into seven distinct layers Copyright 2004-2008 Dan McCreary & Associates
67
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.”
M D Roy Schulte
VP and Research Fellow Gartner Research
Copyright 2004-2008 Dan McCreary & Associates
68
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
69
M D
JMS Textbooks
1.
2.
Java Message Service
by Richard Monson-Haefel and David Chappell
Good explanation on how to use JMS for programmers 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 Programming
by Shaun Terry
Copyright 2004-2008 Dan McCreary & Associates
70
M D
JBossMQ
• JBoss Administration and Development
by 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)
71
Copyright 2004-2008 Dan McCreary & Associates
Thank You!
M D
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, President Dan McCreary & Associates Metadata Strategy Development [email protected]
(952) 931-9198
Copyright 2004-2008 Dan McCreary & Associates
72