Presentation is loading. Please wait.

Presentation is loading. Please wait.

Using Message-Driven Beans in a Service-Oriented Architecture Dave Chappell VP & Chief Technology Evangelist, Sonic Software.

Similar presentations


Presentation on theme: "Using Message-Driven Beans in a Service-Oriented Architecture Dave Chappell VP & Chief Technology Evangelist, Sonic Software."— Presentation transcript:

1 Using Message-Driven Beans in a Service-Oriented Architecture Dave Chappell VP & Chief Technology Evangelist, Sonic Software

2 © 2002, Sonic Software Corporation 2

3 3 O’REILLY

4 © 2002, Sonic Software Corporation 4

5 5 Tell Them About the Book Raffle

6 © 2002, Sonic Software Corporation 6 Sonic Software n 1st J2EE 1.3 Certified MOM! n HTTP(S), XML, SOAP, WSDL, JMS, JCA n Java Message Service (JMS) n Apache Axis n Web services, JAXM, J2EE CA n XML Schema n ebXML n WS-I Driving Industry Standards

7 © 2002, Sonic Software Corporation 7 SonicMQ AppServer Integration n Borland Appserver n HP/Bluestone Total-e-server n BEA Weblogic –CMT,Clustering, Failover/Reconnect, Design Patterns n IBM WebSphere n Oracle Appserver n MacroMedia n JBoss (soon)

8 © 2002, Sonic Software Corporation 8 Sonic Software Recognized:Enterprise messaging Integration middleware Established:Over 500 of Global 2000 rely on Sonic Software StrongIndependent 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

9 © 2002, Sonic Software Corporation 9 Agenda n J2EE Message Driven Topology n JMS Overview n Using JMS With EJBs n JMS and XA Integration n J2EE Connector Architecture n Service Oriented Architectures and Web Services

10 © 2002, Sonic Software Corporation 10 EJB Containers J2EE Topology Web Containers JSP servlet JSP servlet EJB html gifs jpegs xml Presentation LogicBusiness Logic xml EIS Database EJB Internet

11 © 2002, Sonic Software Corporation 11 J2EE Topology – Message Driven Web Containers servlet JSP gifs jpegs html Presentation LogicBusiness Logic EIS Database Internet EJB Containers EJB MDB EJB Containers EJB MDB JMS

12 © 2002, Sonic Software Corporation 12 J2EE Topology – Message Driven Business Partner EJB Server Broker Head Office EJB Server Broker Business Partner Trading Partner Broker EJB Server Broker Regional Office

13 © 2002, Sonic Software Corporation 13 Agenda n J2EE Message Driven Topology n JMS Overview n Using JMS With EJBs n JMS and XA Integration n J2EE Connector Architecture n Service Oriented Architectures and Web Services

14 © 2002, Sonic Software Corporation 14 Java Message Service (JMS) n Sun standard n Common APIs n Loosely-coupled asynchronous processing –Senders and receivers abstractly decoupled from each other –Destinations administratively configurable at runtime n Point to Point and Pub/Sub messaging models n Supports synchronous or asynchronous communication

15 © 2002, Sonic Software Corporation 15 Java Message Service (JMS) n Message delivery semantics –Guaranteed Once-and-only-once –At-most-once n Deployment architecture not addressed by specification –Vendor differentiators

16 © 2002, Sonic Software Corporation 16 Java Message Service Business Application A JMS Messaging API JMS Messaging Client …standards based API… Messaging Components Business Application A JMS Messaging API JMS Messaging Client JMS Provider

17 © 2002, Sonic Software Corporation 17 Broad Range of Message Types BytesMessage Message MapMessage ObjectMessage StreamMessage TextMessage Included in JMS Specification XMLMessage Extensions in SonicMQ MultiPartMessage

18 © 2002, Sonic Software Corporation 18 JMS Messages Message Header Properties Body Used to identify and route the message The actual “payload” of the message (five different types, plus XML and Multipart for SonicMQ) Support application-specific values passed with the message

19 © 2002, Sonic Software Corporation 19 JMS Provider PublisherSubscriber PersistentStore 7. publish() method returns 2. Disconnect 2. Disconnect 5. Message retained in persistent store 1. Subscribe 6. Ack 8. Connect 10. Receive 4. Persist 3. Send 9. Retrieve Persistent messages and durable subscriptions JMS Reliability

20 © 2002, Sonic Software Corporation 20 JMS Reliability JMS Provider 1. Send 3. commit() 2. Send 4. Receive 6. commit() 5. ReceiveConsumerProducer Transactional Message Send and Receive

21 © 2002, Sonic Software Corporation 21 JMS Reliability JMS Provider 1. SendProducer XA Compliant Transaction Manager External Resource (DB/EJB) 2. Update commit() rollback()

22 © 2002, Sonic Software Corporation 22 Filtering with message selectors Message Server Publisher Departments.Sales Subscriber Departments.Sales Pipeline > 15000 JMSPriority = 2 Pipeline = 20000 delivered Subscriber Departments.Sales JMSPriority > 5 not delivered Subscriber Departments.Sales JMSPriority >= 2 AND Pipeline > 10000 delivered Subscriber Departments.Sales Pipeline > 20000 not delivered

23 © 2002, Sonic Software Corporation 23 JMS as a J2EE Resource n 2 Requirements to access a Message Provider –ConnectionFactory n Creates connection to JMS providers –Destination Object n The Specific Topic or Queue

24 © 2002, Sonic Software Corporation 24 Obtaining the ConnectionFactory n 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 n JNDI is used for maximum portability QueueConnectionFactory qcf = (QueueConnectionFactory) ctx.lookup("java:comp/env/jms/TrafficConFactory");

25 © 2002, Sonic Software Corporation 25 Accessing the Destination n The Specific Queue or Topic n Retrieved via JNDI –Specified in the Deployment Descriptor –Binding to a real Destination done at deploy time Topic traffic = (Topic) ctx.lookup("java:comp/env/jms/TrafficTopic");

26 © 2002, Sonic Software Corporation 26 What the Java/API looks like // Create a connection factory TopicConnectionFactory factory; factory = (TopicConnectionFactory)jndi.lookup("TopicConnectionF actory"); // 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");

27 © 2002, Sonic Software Corporation 27 What the Java/API looks like // Create Subscriber to application topics. TopicSubscriber subscriber = session.createSubscriber(topic); // Initialize the onMessage() message handler. subscriber.setMessageListener(this); // Create a publisher publsher = session.createPublisher(null); // Topic will be set for each reply // Now setup is complete, start the Connection connect.start();

28 © 2002, Sonic Software Corporation 28 What the Java/API looks like public void onMessage( javax.jms.Message message){ TextMessage textMessage = (TextMessage) message; System.out.println(textMessage.getText()); } -- OR –... while( true ){ textMessage = (javax.jms.TextMessage)qReceiver.receive(1000);...

29 © 2002, Sonic Software Corporation 29 Break

30 © 2002, Sonic Software Corporation 30 Do the Book Raffle

31 © 2002, Sonic Software Corporation 31 Agenda n J2EE Message Driven Topology n JMS Overview n Using JMS With EJBs n JMS and XA Integration n J2EE Connector Architecture n Service Oriented Architectures and Web Services

32 © 2002, Sonic Software Corporation 32 create lookup remove EJB Design Pattern Reminder client Remote interface stubs home object context bean Server provides resource mgmt Container methods Deployment Descriptor Automatically invokes services based on requirements defined in deployment descriptor create lookup remove methods

33 © 2002, Sonic Software Corporation 33 MessageDrivenBean EJB Container Publisher Bean EJB Container Subscriber Msg-driven Instance Database Durable Subscription Client App Publishes Acknowledges Delivers Stores

34 © 2002, Sonic Software Corporation 34 Container Msg-driven Bean Class JMS Provider MessageDrivenBean n Defined in EJB 2.x Specification n Benefits –Simple to write –Allow for asynchronous execution Destination Msg-driven Bean instances Consumer

35 © 2002, Sonic Software Corporation 35 MessageDrivenBean n Executes on receipt of a JMS message –javax.jms.MessageListener interface n 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

36 © 2002, Sonic Software Corporation 36 MessageDrivenBean Interface n javax.ejb.MessageDrivenBean –ejbCreate(), ejbRemove() –setMessageDrivenContext() n Just like a usual javax.jms.MessageListner –onMessage(javax.jms.Message)

37 © 2002, Sonic Software Corporation 37 MessageDrivenContext n get/setRollbackOnly() n getUserTransaction() –For BMT only n Others inherited from EJBContext Interface, but not allowed: –getCallerPrincipal() –isCallerInRole() –getEJBHome(), getEJBLocalHome()

38 © 2002, Sonic Software Corporation 38 Serialization and Concurrency n Container Must Serialize all calls to an MDB –ejbCreate(), ejbRemove(), etc –No need to be coded as re-entrant n Concurrency –Container May Launch Multiple Instances of an MDB n No guarantee of order n “Cancellation” Message May Arrive Before “Reservation” Message

39 © 2002, Sonic Software Corporation 39 MDB Example public class SubscriberMsgBean implements MessageDrivenBean { <… define ejbCreate(), ejbRemove() and setMessageDrivenContext( MessageDrivenContext mdc).. > MessageDrivenContext mdc = null; public void onMessage( Message inMessage) { TextMessage msg = (TextMessage) inMessage; try { } catch( Exception e) { mdc. setRollbackOnly(); }

40 © 2002, Sonic Software Corporation 40 MDB Example – Deployment Descriptors... SubscriberMsgBean Container NewsType='Metro/Region‘ javax.jms.Topic durable...

41 © 2002, Sonic Software Corporation 41 MDB Example – Deployment Descriptors QueueMessageDriven 20 1 sonicQueue com.sun.jndi.fscontext.RefFSContextFactory file://localhost/C:/temp/jndi/fileStore/ myJMSxaqcf

42 © 2002, Sonic Software Corporation 42 Agenda n J2EE Message Driven Topology n JMS Overview n Using JMS With EJBs n JMS and XA Integration n J2EE Connector Architecture n Service Oriented Architectures and Web Services

43 © 2002, Sonic Software Corporation 43 Distributed Transaction Processing (DTP) TM RM XA XA XA TMTM XA XA XA TM RM TMTM XA XA XA TM RM XA XA XA

44 © 2002, Sonic Software Corporation 44 A local instance of a DTP system TM RM JMS Client

45 © 2002, Sonic Software Corporation 45 Local DTP zoom in EJB Application Server SonicMQ Client JMS Provider JMS Provider Transaction Manager JMS Client JMS XA API XA Resource

46 © 2002, Sonic Software Corporation 46 XA interfaces n JMS XA SPI –XAConnectionFactory –XAConnection –XASession –XAQueueConnectionFactory –XAQueueConnection –XAQueueSession –XATopicConnectionFactory –XATopicConnection –XATopicSession

47 © 2002, Sonic Software Corporation 47 Agenda n J2EE Message Driven Topology n JMS Overview n Using JMS With EJBs n JMS and XA Integration n J2EE Connector Architecture n Service Oriented Architectures and Web Services

48 © 2002, Sonic Software Corporation 48 J2EE Directions n J2EE 1.3 –Web Applications –Asynchronous n JMS n MDB –EJB 2.0 n J2EE 1.4 –SOA Platform –Web Services n JAX-RPC n JSR-109 –J2EE Connector Architecture –EJB 2.1 n WSEI

49 © 2002, Sonic Software Corporation 49 J2EE Connector Architecture Overview n Defines standard for connecting J2EE to enterprise information systems (EIS) n System contracts define interface specification with EIS –Connection, Transaction, Security Enterprise Information System Resource Adapter Application Server or EAI Framework System Contract EIS Interface

50 © 2002, Sonic Software Corporation 50 J2EE Connector Architecture Overview n 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 n Common client interface –Standard API for applications to interact with heterogeneous EIS Enterprise Information System Resource Adapter Application Server or EAI Framework System Contract EIS Interface

51 © 2002, Sonic Software Corporation 51 Inbound Communication Model Resource Adapter JMS Destination Enterprise Java Beans JCA Container WorkManager Connection Pool Manager Transaction Manager Security Manager Work Mgmt JMS Disp EJB Disp

52 © 2002, Sonic Software Corporation 52 Agenda n J2EE Message Driven Topology n JMS Overview n Using JMS With EJBs n JMS and XA Integration n J2EE Connector Architecture n Service Oriented Architectures and Web Services

53 © 2002, Sonic Software Corporation 53 Service-Oriented Architecture Global Enterprise Internet Web Service Web Service Credit Check Web Service Credit Check Web Service Supplier Fulfill Service Supplier Fulfill Service Web Service Web Service Invoicing Service Invoicing Service Sales Service Sales Service Special Orders Order Processing Order Processing Regional Sales Regional Sales Partner App Partner App Inventory Lookup Customer App Customer App Partner App Partner App Check Inv Service Check Inv Service Order Entry Service Order Entry Service

54 © 2002, Sonic Software Corporation 54 Service-Oriented Architectures (SOA) n System design methodology using existing application components n Applications expose functionality through service interfaces –Loosely-coupled, asynchronous, coarse-grained n Distributed across internal networks or the Internet n Web services –Software services built on standards: SOAP, WSDL, UDDI, XML, HTTP Architecture for a Distributed World

55 © 2002, Sonic Software Corporation 55 Web Services Technology Stack Publication and Discovery (UDDI, ebXML Registry) Description Language (WSDL) Data Formatting (XML Dujour) Transport (HTTP, SMTP, TCP/IP) XML-RPC (SOAP-RPC, JAX-RPC) XML Messaging (SOAP, ebXML,JAXM)

56 © 2002, Sonic Software Corporation 56 Web Services Technology Stack XML-RPC (SOAP-RPC, JAX-RPC) Publication and Discovery (UDDI, ebXML Registry) Description Language (WSDL) Data Formatting (XML Dujour) Transport (HTTP, SMTP, TCP/IP) XML Messaging (SOAP, ebXML,JAXM) Quality of Service JMS, ebXML-MS, HTTPR

57 © 2002, Sonic Software Corporation 57 Connecting (Web) Services Together n (Web) Services aren’t Islands of Themselves n Network of Cooperative Services n 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 What Else Do You Need?

58 © 2002, Sonic Software Corporation 58 Standards Working Together... JAXM/RPC Client Apache Client Servlet Container.NET SOAP Client JMS message SOAP/HTTP Web Client SOAP/HTTP Internet JMS Messaging Backbone SOAP/HTTP SOAP/JMS SOAP/HTTP SOAP/JMS SOAP/HTTP SOAP/JMS JMS message JCA/EIS EJB Container JMS ClientC++ Client JCA/EIS

59 © 2002, Sonic Software Corporation 59 Contact Information n Chappell@sonicsoftware.co m Chappell@sonicsoftware.co m n http://www.sonicsoftware.c om Integrate with Ease. Extend at Will TM.


Download ppt "Using Message-Driven Beans in a Service-Oriented Architecture Dave Chappell VP & Chief Technology Evangelist, Sonic Software."

Similar presentations


Ads by Google