J2EE Lecture 13: JMS and WebSocket

Slides:



Advertisements
Similar presentations
16 Copyright © 2005, Oracle. All rights reserved. Developing Message-Driven Beans.
Advertisements

11 Copyright © 2005, Oracle. All rights reserved. Creating the Business Tier: Enterprise JavaBeans.
.NET Remoting. .Net Remoting Replaces DCOM (Distributed Component Object Model – a proprietary Microsoft technology for communication among software components.
An architecture for webb applications, J2EE
Oracle Fusion Middleware 11g Abhishek Khanolkar. What is Oracle Fusion? “Oracle Fusion Middleware is a ‘preintegrated’ portfolio of customer- proven software.
University of British Columbia Software Practices Lab Introduction to Middleware for Software Engineering Eric Wohlstadter 539D.
Developing a Message Driven Architecture with Spring – an Overview Silicon India Java Conference, Hyderabad October 15, 2011.
Application Servers What is it? General A set of software frameworks, components, utilities, functionality that enables you to develop and deliver n-tiered.
Introduction to Enterprise JavaBeans. Integrating Software Development Server-side Component Model Distributed Object Architecture –CORBA –DCOM –Java.
Java Messaging Services CS-328. Messaging Systems A messaging System allows and promotes the loose coupling of components –allows components to post messages.
Java Message Service API CSE 487/587 Feb 17, 2005 References: JRun Programmer’s Guide.
JMS Java Message Service Instructor Professor: Charles Tappert By Student: Amr Fouda.
ECSE Software Engineering 1I HO 7 © HY 2012 Lecture 7 Publish/Subscribe.
Introduction to EJB INFORMATICS ENGINEERING – UNIVERSITY OF BRAWIJAYA Eriq Muhammad Adams J
Session-01. What is a Servlet? Servlet can be described in many ways, depending on the context: 1.Servlet is a technology i.e. used to create web application.
Messaging Technologies Group: Yuzhou Xia Yi Tan Jianxiao Zhai.
Messaging in Java Rafał Witkowski Marek Kałużny.
Enterprise Java Beans CS-422. Application Servers In the late 1980s and though the mid 1990s a number of corporations (Broadvision, Netscape…) marketed.
1 Session Bean Chuyên đề Lập trình Java & J2EE Chương 14 Biên soạn: Th.S Nguyễn văn Lành.
Ing. Ignacio Roqueta ARTech GeneXus and J2EE.
Enterprise JavaBeans. What is EJB? l An EJB is a specialized, non-visual JavaBean that runs on a server. l EJB technology supports application development.
EJB Framework.  As we know, EJB is the center of the J2EE architecture that provides a sturdy framework for building enterprise applications. The major.
Message-Driven Beans and EJB Security Lesson 4B / Slide 1 of 37 J2EE Server Components Objectives In this lesson, you will learn about: Identify features.
Message Driven Beans & Web Services INFORMATICS ENGINEERING – UNIVERSITY OF BRAWIJAYA Eriq Muhammad Adams J
Lecture 15 Introduction to Web Services Web Service Applications.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved Chapter 4 Communication.
Asynchronous Communication Between Components Presented By: Sachin Singh.
OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 5: JMS.
National Institute of Science & Technology Architecture of Message Oriented Middleware Anindya Kumar Jena [1] Architecture of Message Oriented Middleware.
Architecture of Message Oriented Middleware [1]
1 Java Message Service Манин П Enterprise messaging Key concept: 1. Messages are delivered asynchronously 2. Sender is not required to wait for.
Databases JDBC (Java Database Connectivity) –Thin clients – servlet,JavaServer Pages (JSP) –Thick clients – RMI to remote databases –most recommended way.
Collaborate Lesson 4C / Slide 1 of 22 Collaborate Knowledge Byte In this section, you will learn about: The EJB timer service Message linking in EJB 2.1.
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Introduction to Spring Remoting Simplifying.
Session 7: JMS, JCA, JSF Dr. Nipat Jongsawat.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
AMQP, Message Broker Babu Ram Dawadi. overview Why MOM architecture? Messaging broker like RabbitMQ in brief RabbitMQ AMQP – What is it ?
Spring RabbitMQ Martin Toshev.
Introduction to EJB. What is an EJB ?  An enterprise java bean is a server-side component that encapsulates the business logic of an application. By.
Java Programming: Advanced Topics 1 Enterprise JavaBeans Chapter 14.
©NIIT Introducing Enterprise JavaBeans (EJB) Lesson 1A / Slide 1 of 43J2EE Server Components Objectives In this lesson, you will learn about: The features.
EJB Enterprise Java Beans JAVA Enterprise Edition
September 28, 2010COMS W41561 COMS W4156: Advanced Software Engineering Prof. Gail Kaiser
Enterprise Java Beans. Contents  Understanding EJBs  Practice Section.
Windows Communication Foundation and Web Services
J2EE Lecture 10: EJB 3.0 Overview
J2EE Platform Overview (Application Architecture)
J2EE Lecture 6: Spring – IoC and Dependency Injection
Replicated LevelDB on JBoss Fuse
Chapter 3 Internet Applications and Network Programming
A Messaging Infrastructure for WLCG
Introduction to J2EE Architecture
Knowledge Byte In this section, you will learn about:
Java EE Overview The problem Java Enterprise Edition attempts to solve: maximize the use of Java technologies by providing a suite of Java technology specifications.
Java Messaging Service (JMS)
Java Messaging Service (JMS)
Java EE Overview The problem Java Enterprise Edition attempts to solve: maximize the use of Java technologies by providing a suite of Java technology specifications.
Java Messaging Service (JMS)
Harjutus 3: Aünkroonne hajussüsteemi päring
Inventory of Distributed Computing Concepts
Message Service System
Message Queuing.
Component-based Applications
Introduction to Web Services
J2EE Lecture 1:Servlet and JSP
Anyware's Implementation of the Target Communication Framework
Enterprise Java Beans.
Seminarium on Component-based Software Engineering
Standards, APIs, and Applications
Knowledge Byte In this section, you will learn about:
Presentation transcript:

J2EE Lecture 13: JMS and WebSocket Dr. Ming Qiu Xiamen University Software School mingqiu@xmu.edu.cn http://docs.huihoo.com/jboss/online_manual/3.0/index.html

13.1 Introduction to MDB How to implement messaging Mastering EJB3.0, Chap 7 13.1 Introduction to MDB How to implement messaging An overview of asynchronous behavior and message-oriented middleware (MOM) How to use the Java Message Service(JMS), MOM framework for JMS-based message-driven beans The features of message-driven beans Compared with entity and session beans How to develop message-driven beans

13.1 Introduction to MDB Motivations for Messaging Mastering EJB3.0, Chap 7 13.1 Introduction to MDB Motivations for Messaging Several areas are challenging for RMI-IIOP Asynchrony Decoupling Reliability Support for multiple senders and receivers

Mastering EJB3.0, Chap 7 13.1 Introduction to MDB

EJB in Action, Chap 4 13.1 Introduction to MDB

13.1 Motivations for Messaging Mastering EJB3.0, Chap 7 13.1 Motivations for Messaging Message-oriented middleware(MOM) Tibco Rendezvous IBM WebSphere MQ BEA Tuxedo/Q Sun Java System Messaging Server Microsoft MSMQ JBoss MQ RabbitMQ ActiveMQ

13.2 The Java Message Service (JMS) Mastering EJB3.0, Chap 7 13.2 The Java Message Service (JMS) A messaging standard, which has two parts an API Write code to send and receive messages A Service Provider Interface (SPI) Plug in JMS provider Know how to talk to specific MOM implementation

13.2 The Java Message Service (JMS)

13.2 The Java Message Service (JMS) Message Domains Publish/subscribe (pub/sub)

13.2 The Java Message Service (JMS) Point-to-point (PTP)

13.2 The Java Message Service (JMS) Mastering EJB3.0, Chap 7 13.2 The Java Message Service (JMS) EJB in Action, Chap 4 JMS API Locate the JMS Provider’s ConnectionFactory instance (javax.jms.ConnectionFactory) Look it up in JNDI Create a JMS connection (javax.jms.Connection) A active connection to the JMS provider Thread-safe and designed to be sharable Create a JMS session (javax.jms.Session) provides a single-threaded, task-oriented context for sending and receiving messages.

13.2 The Java Message Service (JMS) Mastering EJB3.0, Chap 7 13.2 The Java Message Service (JMS) Locate the JMS Destination The channel to which you’re sending or from with you’re receiving messages Set up by deployer in advances Looked up from JNDI Create a JMS Producer or a JMS Consumer JMS Producer Call it to pass your message JMS Consumer Call it to ask for a message Send or receive your message

Mastering EJB3.0, Chap 7

13.2 The Java Message Service (JMS) Mastering EJB3.0, Chap 7 13.2 The Java Message Service (JMS)

Mastering EJB3.0, Chap 7

13.2 The Java Message Service (JMS) Mastering EJB3.0, Chap 7 13.2 The Java Message Service (JMS)

13.2 The Java Message Service (JMS) EJB in Action, Chap 4 13.2 The Java Message Service (JMS)

13.3 Working with MDB What is a Message-Driven Bean? Mastering EJB3.0, Chap 7 13.3 Working with MDB EJB in Action, Chap 4 What is a Message-Driven Bean? EJB components designed to consume the asynchronous messages Does not have a remote or local business interface Support generic listener methods for message delivery Called by an EJB container upon arrival of a message Do not have return values and not send exceptions back to clients Message-driven beans are stateless Message-driven beans are single-threaded The container is responsible for serializing messages The container provide concurrent message consumption by pooling multiple message-driven beans

EJB in Action, Chap 4 13.3 Working with MDB

13.4 Developing Message-Driven Beans EJB in Action, Chap 4 13.4 Developing Message-Driven Beans MDBs must follow these rules Must implement javax.jms.MessageListener Must be concrete. It cannot be either a final or an abstract class. Must be a POJO class and not a subclass of another MDB. Must be declared public. Must have a no-argument constructor. Cannot define a finalize method in the bean class. Must not throw the javax.rmi.RemoteException or any runtime exceptions.

13.4 Developing Message-Driven Beans EJB in Action, Chap 4 13.4 Developing Message-Driven Beans

13.4 Developing Message-Driven Beans EJB in Action, Chap 4 13.4 Developing Message-Driven Beans

13.4 Developing Message-Driven Beans EJB in Action, Chap 4 13.4 Developing Message-Driven Beans

13.4 Developing Message-Driven Beans Mastering EJB3.0, Chap 7 13.4 Developing Message-Driven Beans

13.4 Developing Message-Driven Beans EJB in Action, Chap 4 13.4 Developing Message-Driven Beans acknowledgeMode Messages are not actually removed from the queue until the consumer acknowledges them.

13.4 Developing Message-Driven Beans EJB in Action, Chap 4 13.4 Developing Message-Driven Beans subscriptionDurability specify whether the topic subscription is durable or nondurable durable subscription all messages sent to the topic are guaranteed to be delivered to that consumer

Spring Framework Doc 13.5 Spring JMS Provides a JMS integration framework that simplifies the use of the JMS API JmsTemplate Message-Driven POJOS (MDPs)

13.5 Spring JMS Sending a Message - JmsTemplate Spring Framework Doc 13.5 Spring JMS Sending a Message - JmsTemplate the central class in the JMS core package Requires a reference to a ConnectionFactory. ConnectionFactory is used by the client application as a factory to create connections with the JMS provider and encapsulates various configuration parameters.

Spring Framework Doc

Spring Framework Doc 13.5 Spring JMS

Spring Framework Doc 13.5 Spring JMS

Spring Framework Doc 13.5 Spring JMS

Spring Framework Doc

Spring Framework Doc 13.5 Spring JMS Receiving a Message - MDPs

Spring Framework Doc 13.5 Spring JMS

13.6 WebSocket HTTP Protocol

13.6 WebSocket HTTP Protocol

13.6 WebSocket WebSocket is a protocol which communicates between browser and web server. works over TCP protocol. opens a socket connection between browser and web server and start communication.

13.6 WebSocket

13.6 WebSocket SockJS is a java script library which provides websocket like object for browsers. provides cross browser compatibility and supports STOMP protocol to communicate with any message broker. works in the way that we need to provide URL to connect with message broker and then get the stomp client to communicate.

13.6 WebSocket STOMP is Streaming Text Oriented Messaging Protocol. A STOMP client communicates to a message broker which supports STOMP protocol. STOMP uses different commands like connect, send, subscribe, disconnect etc to communicate.

13.6 WebSocket Configuration Class to Support Spring 4 WebSocket

13.6 WebSocket

13.6 WebSocket @EnableWebSocketMessageBroker enables a configuration class to support WebSocket AbstractWebSocketMessageBrokerConfigurer is extended by WebSocket Configuration class

13.6 WebSocket MessageBrokerRegistry helps to register message broker. topic : there are more than one subscribers for a message. queue : peer to peer communication. StompEndpointRegistry register an end point for the STOMP over WebSocket.

13.6 WebSocket Controller class for WebSocket

13.6 WebSocket STOMP Client

13.6 WebSocket

13.6 WebSocket

13.6 WebSocket

13.6 WebSocket

13.6 WebSocket The return value from an @MessageMapping method is converted with a MessageConverter and used as the body of a new message that is then sent, by default, to the "brokerChannel" with the same destination as the client message but using the prefix "/topic" by default. An @SendTo message level annotation can be used to specify any other destination instead.

13.6 WebSocket Flow of Messages