SlideShare a Scribd company logo
Spring Boot & WebSocket
Present by MingIn Wu
2015/7/15 1
Outline
• Spring Boot
– Introduction
– Spring Boot Quick Start
– Spring Boot External Tomcat plugin
– Spring Boot JSP plugin
– Spring Boot MySQL & JDBC plugin
– Spring Boot Builder Profile
– Spring Boot Log4j Plugin
– Spring Boot Security
• Spring Boot WebSocket
– Introduction
– WebSocket
• Server Side (Spring )
• Client Side (javascript & java)
– WebSocket + SockJS
• Server Side (Spring)
• Client Side (SockJS)
– STOMP + WebSocket + SockJS
• Server Side (Spring)
• Client Side (STOMP)
• Use Case Sequence Diagrams
2015/7/15 2
Spring Boot Introduction
• Primary Goal :
– Provide a faster and accessible getting started experience for all Spring development.
– Be opinionated out of the box, but get out of the way quickly as requirements start to
diverge from the defaults.
– Provide a range of non-functional features that are common to large classes of projects.
(e.g. embedded servers, security, scalability ).
– Absolutely no code generation and no requirement for XML configuration.
• System Requirements:
– Java 7+
– Tomcat 7+ or glassfish 4+
– Spring Framework 4.1.5+
2015/7/15 3
Different between Spring Boot and Spring 3
• No requirement for XML configuration:
• Spring Boot • Spring 3.x
2015/7/15 4
Spring Boot Quick Start
2015/7/15 5
• 1. Create Spring Starter Project guide :
Spring Boot Quick Start (1/3)
2015/7/15 6
• 2. pom.xml setting :
– 2-1. Packaging executable jar and war files :
– 2-2. Use Spring-boot-starter-parent to manage dependencies setting.
Spring Boot Quick Start (2/3)
2015/7/15 7
Spring Boot Quick Start (3/3)
• 3. Project Configuration :
– Spring Boot applications need very little Spring configuration.
– 1. @SpringBootApplication
– 2. @ComponentScan
– 3. extends SpringBootServletInitializer
2015/7/15 8
Spring Boot
External Tomcat plugin
2015/7/15 9
Spring Boot External Tomcat plugin
• pom.xml setting :
– To build a war file that is both executable and deployable into an external container you
need to mark the embedded container dependencies as “provided”.
2015/7/15 10
Spring Boot JSP plugin
2015/7/15 11
Spring Boot JSP plugin
• pom.xml setting :
• JSP files path :
• Set property in the ‘application.properties’
2015/7/15 12
Spring Boot
mySQL & JDBC plugin
2015/7/15 13
Spring Boot mySQL & JDBC plugin (1/4)
• 1. pom.xml setting :
• 2. Set property into the ‘application.properties’
2015/7/15 14
Spring Boot mySQL & JDBC plugin (2/4)
• 3. Create class ProjectDataSource to replace ‘dataSource-context.xml ‘:
– 3-1. Set two pair properties to the data source
2015/7/15 15
Spring Boot mySQL & JDBC plugin (3/4)
• 3. Create class ProjectDataSource to replace ‘dataSource-context.xml’ :
– 3-2. Create two bean classes ‘amway_dataSource’ & ‘sso_dataSource’.
– 3-3. Create "sqlLoader" class which is load SQL commands from ‘sql.properties’.
2015/7/15 16
Spring Boot mySQL & JDBC plugin (4/4)
• 4. Implement interface AppDao and extends by JdbcDaoSupport.
2015/7/15 17
Spring Boot Builder Profile
2015/7/15 18
Spring Boot Builder Profile
• pom.xml setting :
– It's the same configuration as other projects (like xBoard .... etc).
2015/7/15 19
Spring Boot Log4j Plugin
2015/7/15 20
Spring Boot Log4j Plugin (1/2)
• pom.xml setting :
2015/7/15 21
Spring Boot Log4j Plugin (2/2)
• comparing log4j.properties with log4j.xml
• log4j.properties • log4j.xml
2015/7/15 22
Spring Boot Security
2015/7/15 23
Spring Boot Security (1/5)
• pom.xml setting :
• System Login form :
2015/7/15 24
Spring Boot Security (2/5)
• Security Configuration :
– 1. SecurityConfiguration config
2015/7/15 25
Spring Boot Security (3/5)
• Security Configuration :
– 2. Comparing the HttpSecurity setting:
• SecurityConfiguration class • security-context.xml
2015/7/15 26
Spring Boot Security (4/5)
• Security Configuration :
– 3-1. Comparing the authentication-manager & jdbc-user-service setting:
• security-context.xml
– Step1. Setting up JdbcUserDetailsManager.
– Step2. Setting up Md5PasswordEncoder & ReflectionSaltSource.
– Step3. Md5PasswordEncoder & ReflectionSaltSource put in the DaoAuthenticationProvider.
– Step4. DaoAuthenticationProvider put in the AuthenticationManagerBuilder.
Step2
Step1
Step3&4
2015/7/15 27
Spring Boot Security (5/5)
• Security Configuration :
– 3-2. Comparing the authentication-manager & jdbc-user-service setting:
• SecurityConfiguration class
Step1
Step2
Step3
Step4
2015/7/15 28
Spring Boot WebSocket
2015/7/15 29
Spring Boot WebSocket Introduction (1/3)
• Polling vs WebSocket :
– 1. Comparison of the unnecessary network throughput overhead between the polling
and the WebSocket applications.
2015/7/15 30
Spring Boot WebSocket Introduction (2/3)
• Polling vs WebSocket :
– 2. Comparison between the polling and WebSocket applications.
2015/7/15 31
Spring Boot WebSocket Introduction (3/3)
• WebSocket Protocol :
– WebSocket is an extension to HTTP and enables streaming of data.
2015/7/15 32
Spring Boot WebSocket Example (1/5)
• Server Side (Spring) :
– 1. pom.xml setting :
– 2. Configuration (simple) :
2015/7/15 33
Spring Boot WebSocket Example (2/5)
• Server Side (Spring) :
– 4. GreetingHandler :
• extends TextWebSocketHandler class.
• Greeting Handler class can mix with @Controller and @RequestMapping.
2015/7/15 34
Spring Boot WebSocket Example (3/5)
• Client Side (javascript) :
– 1. connect()
2015/7/15 35
Spring Boot WebSocket Example (4/5)
• Client Side (javascript) :
– 2. sendMessage()
– 3. disconnect()
2015/7/15 36
Spring Boot WebSocket Example (5/5)
• Client Side (java) :
– 1. Create ChatClientEndpoint class
– 2. call
2015/7/15 37
Spring Boot WebSocket & SockJS
2015/7/15 38
Spring Boot WebSocket & SockJS Example (1/6)
• Spring Server Side :
– 1. pom.xml setting :
– 2. Configuration (simple) :
2015/7/15 39
Spring Boot WebSocket & SockJS Example (2/6)
• Spring Server Side :
– 3-1. Configuration (websocket session handshake) :
• We can capture the http session for a websocket request.
• The reason was to determine the number of websocket sessions utilizing the same underlying
http session.
2015/7/15 40
Spring Boot WebSocket & SockJS Example (3/6)
• Spring Server Side :
– 3-2. HttpSession Handshake Interceptor :
• beforeHandshake()
• afterHandshake()
2015/7/15 41
Spring Boot WebSocket & SockJS Example (4/6)
• Spring Server Side :
– 4. GreetingHandler :
• extends TextWebSocketHandler class.
• Greeting Handler class can mix with @Controller and @RequestMapping.
2015/7/15 42
Spring Boot WebSocket & SockJS Example (5/6)
• SockJS client side :
– 1. SockJS – connect()
2015/7/15 43
Spring Boot WebSocket & SockJS Example (6/6)
• SockJS client side :
– 2. SockJS – sendMessage()
– 3. SockJS – disconnect()
2015/7/15 44
Spring Boot
WebSocket & STOMP
2015/7/15 45
Spring Boot WebSocket & STOMP Example (1/6)
• STOMP :
– STOMP is a simple text-oriented messaging protocol that was originally created for
scripting languages to connect to enterprise message brokers.
– STOMP is a frame based protocol with frames modeled on HTTP.
– STOMP uses different commands like connect, send, subscribe, disconnect etc to
communicate.
• Command : SEND format (client) Command : SUBSCRIBE format (client)
• Command : MESSAGE format (server) - broadcast messages to all subscribers.
2015/7/15 46
Command
Header
Body
Command
Header
Body
Command
Header
Body
Spring Boot WebSocket & STOMP Example (2/6)
• Spring Server Side :
– 1. Configuration (stomp) :
• extends AbstractWebSocketMessageBrokerConfigurer
• Configure message broker options.
• Configure STOMP over WebSocket end-points.
2015/7/15 47
Spring Boot WebSocket & STOMP Example (3/6)
• Spring Server Side :
– 1. Configuration (stomp) :
• GreetingController class can mix with @Controller and @RequestMapping.
• @MessageMapping
• @SendTo
2015/7/15 48
Spring Boot WebSocket & STOMP Example (4/6)
• STOMP client side :
– 1. STOMP + SockJS – connect()
• 1-1 Create a socket object by SockJS.
• 1-2 Set StompClient to control the socket.
• 1-3 Implement stomp client subscribe function.
2015/7/15 49
Spring Boot WebSocket & STOMP Example (5/6)
• STOMP client side :
– 2. STOMP + SockJS – sendMessage()
– 3. STOMP + SockJS – disconnect()
2015/7/15 50
Spring Boot WebSocket & STOMP Example (6/6)
• Spring - STOMP Architecture :
– AbstractWebSocketMessageBrokerConfigurer setting :
2015/7/15 51
Send request
/app/hello
Send response
/topic/greeting
Client subscribe
/topic/greeting
Client send message
Send request
/topic/greeting
Use Case Sequence Diagrams
2015/7/15 52
Case1. WebSocket + socJS
2015/7/15 53
– Build B2B WebSocket connection between client & server.
Case2. WebSocket + STOMP - 1
– Server Use @SendTo() send message to all of subscriber client.
2015/7/15 54
Case3. WebSocket & STOMP - 2
– Server Use @SendToUser() send message to for the specified subscriber client.
2015/7/15 55
Case4. WebSocket & STOMP - 3
– Remove enableSimpleBroker() & setApplicationDestinationPrefixes() setting within
WebSocketConfig.
2015/7/15 56
End
2015/7/15 57

More Related Content

What's hot

Spring data presentation
Spring data presentationSpring data presentation
Spring data presentation
Oleksii Usyk
 
Xke spring boot
Xke spring bootXke spring boot
Xke spring boot
sourabh aggarwal
 
Spring Security 5
Spring Security 5Spring Security 5
Spring Security 5
Jesus Perez Franco
 
Spring data jpa
Spring data jpaSpring data jpa
Spring data jpa
Jeevesh Pandey
 
Spring boot Introduction
Spring boot IntroductionSpring boot Introduction
Spring boot Introduction
Jeevesh Pandey
 
Spring Framework - MVC
Spring Framework - MVCSpring Framework - MVC
Spring Framework - MVC
Dzmitry Naskou
 
Spring Core
Spring CoreSpring Core
Spring Core
Pushan Bhattacharya
 
APIC/DataPower security
APIC/DataPower securityAPIC/DataPower security
APIC/DataPower security
Shiu-Fun Poon
 
Spring Boot Tutorial
Spring Boot TutorialSpring Boot Tutorial
Spring Boot Tutorial
Naphachara Rattanawilai
 
Spring boot - an introduction
Spring boot - an introductionSpring boot - an introduction
Spring boot - an introduction
Jonathan Holloway
 
Securing Serverless Workloads with Cognito and API Gateway Part II - AWS Secu...
Securing Serverless Workloads with Cognito and API Gateway Part II - AWS Secu...Securing Serverless Workloads with Cognito and API Gateway Part II - AWS Secu...
Securing Serverless Workloads with Cognito and API Gateway Part II - AWS Secu...
Amazon Web Services
 
Implementing security requirements for banking API system using Open Source ...
 Implementing security requirements for banking API system using Open Source ... Implementing security requirements for banking API system using Open Source ...
Implementing security requirements for banking API system using Open Source ...
Yuichi Nakamura
 
REST APIs with Spring
REST APIs with SpringREST APIs with Spring
REST APIs with Spring
Joshua Long
 
Spring boot introduction
Spring boot introductionSpring boot introduction
Spring boot introduction
Rasheed Waraich
 
Introduction to Spring Boot
Introduction to Spring BootIntroduction to Spring Boot
Introduction to Spring Boot
Purbarun Chakrabarti
 
Spring - Part 2 - Autowiring, Annotations, Java based Configuration - slides
Spring - Part 2 - Autowiring, Annotations, Java based Configuration - slidesSpring - Part 2 - Autowiring, Annotations, Java based Configuration - slides
Spring - Part 2 - Autowiring, Annotations, Java based Configuration - slides
Hitesh-Java
 
What's new in API Connect and DataPower - 2019
What's new in API Connect and DataPower - 2019What's new in API Connect and DataPower - 2019
What's new in API Connect and DataPower - 2019
IBM DataPower Gateway
 
Building secure applications with keycloak
Building secure applications with keycloak Building secure applications with keycloak
Building secure applications with keycloak
Abhishek Koserwal
 
Spring boot
Spring bootSpring boot
Spring boot
Pradeep Shanmugam
 
Maven Introduction
Maven IntroductionMaven Introduction
Maven Introduction
Sandeep Chawla
 

What's hot (20)

Spring data presentation
Spring data presentationSpring data presentation
Spring data presentation
 
Xke spring boot
Xke spring bootXke spring boot
Xke spring boot
 
Spring Security 5
Spring Security 5Spring Security 5
Spring Security 5
 
Spring data jpa
Spring data jpaSpring data jpa
Spring data jpa
 
Spring boot Introduction
Spring boot IntroductionSpring boot Introduction
Spring boot Introduction
 
Spring Framework - MVC
Spring Framework - MVCSpring Framework - MVC
Spring Framework - MVC
 
Spring Core
Spring CoreSpring Core
Spring Core
 
APIC/DataPower security
APIC/DataPower securityAPIC/DataPower security
APIC/DataPower security
 
Spring Boot Tutorial
Spring Boot TutorialSpring Boot Tutorial
Spring Boot Tutorial
 
Spring boot - an introduction
Spring boot - an introductionSpring boot - an introduction
Spring boot - an introduction
 
Securing Serverless Workloads with Cognito and API Gateway Part II - AWS Secu...
Securing Serverless Workloads with Cognito and API Gateway Part II - AWS Secu...Securing Serverless Workloads with Cognito and API Gateway Part II - AWS Secu...
Securing Serverless Workloads with Cognito and API Gateway Part II - AWS Secu...
 
Implementing security requirements for banking API system using Open Source ...
 Implementing security requirements for banking API system using Open Source ... Implementing security requirements for banking API system using Open Source ...
Implementing security requirements for banking API system using Open Source ...
 
REST APIs with Spring
REST APIs with SpringREST APIs with Spring
REST APIs with Spring
 
Spring boot introduction
Spring boot introductionSpring boot introduction
Spring boot introduction
 
Introduction to Spring Boot
Introduction to Spring BootIntroduction to Spring Boot
Introduction to Spring Boot
 
Spring - Part 2 - Autowiring, Annotations, Java based Configuration - slides
Spring - Part 2 - Autowiring, Annotations, Java based Configuration - slidesSpring - Part 2 - Autowiring, Annotations, Java based Configuration - slides
Spring - Part 2 - Autowiring, Annotations, Java based Configuration - slides
 
What's new in API Connect and DataPower - 2019
What's new in API Connect and DataPower - 2019What's new in API Connect and DataPower - 2019
What's new in API Connect and DataPower - 2019
 
Building secure applications with keycloak
Building secure applications with keycloak Building secure applications with keycloak
Building secure applications with keycloak
 
Spring boot
Spring bootSpring boot
Spring boot
 
Maven Introduction
Maven IntroductionMaven Introduction
Maven Introduction
 

Viewers also liked

Spring + WebSocket integration
Spring + WebSocket integrationSpring + WebSocket integration
Spring + WebSocket integration
Oleksandr Semenov
 
Websockets and SockJS, Real time chatting
Websockets and SockJS, Real time chattingWebsockets and SockJS, Real time chatting
Websockets and SockJS, Real time chatting
University of Alabama at Birmingham
 
SockJS Intro
SockJS IntroSockJS Intro
SockJS IntroNgoc Dao
 
Realtime web application with java
Realtime web application with javaRealtime web application with java
Realtime web application with java
JeongHun Byeon
 
게임 고객 사례를 통해 살펴보는 AWS 활용 전략 :: 이경안 :: AWS Summit Seoul 2016
게임 고객 사례를 통해 살펴보는 AWS 활용 전략 :: 이경안 :: AWS Summit Seoul 2016게임 고객 사례를 통해 살펴보는 AWS 활용 전략 :: 이경안 :: AWS Summit Seoul 2016
게임 고객 사례를 통해 살펴보는 AWS 활용 전략 :: 이경안 :: AWS Summit Seoul 2016
Amazon Web Services Korea
 
WebSockets and Java
WebSockets and JavaWebSockets and Java
WebSockets and Java
Bozhidar Bozhanov
 
Dynamic Apps with WebSockets and MQTT - IBM Impact 2014
Dynamic Apps with WebSockets and MQTT - IBM Impact 2014Dynamic Apps with WebSockets and MQTT - IBM Impact 2014
Dynamic Apps with WebSockets and MQTT - IBM Impact 2014
Bryan Boyd
 
Consuming web services asynchronously with Futures and Rx Observables (svcc, ...
Consuming web services asynchronously with Futures and Rx Observables (svcc, ...Consuming web services asynchronously with Futures and Rx Observables (svcc, ...
Consuming web services asynchronously with Futures and Rx Observables (svcc, ...
Chris Richardson
 
Big Data - Linked In_DEEPU
Big Data - Linked In_DEEPUBig Data - Linked In_DEEPU
Big Data - Linked In_DEEPUDeepu M
 
Creating a Java EE 7 Websocket Chat Application
Creating a Java EE 7 Websocket Chat ApplicationCreating a Java EE 7 Websocket Chat Application
Creating a Java EE 7 Websocket Chat Application
Micha Kops
 
웹소켓 (WebSocket)
웹소켓 (WebSocket)웹소켓 (WebSocket)
웹소켓 (WebSocket)
jeongseokoh
 
Note - (EDK2) Acpi Tables Compile and Install
Note - (EDK2) Acpi Tables Compile and InstallNote - (EDK2) Acpi Tables Compile and Install
Note - (EDK2) Acpi Tables Compile and Installboyw165
 
Javantura v4 - CroDuke Indy and the Kingdom of Java Skills - Branko Mihaljevi...
Javantura v4 - CroDuke Indy and the Kingdom of Java Skills - Branko Mihaljevi...Javantura v4 - CroDuke Indy and the Kingdom of Java Skills - Branko Mihaljevi...
Javantura v4 - CroDuke Indy and the Kingdom of Java Skills - Branko Mihaljevi...
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
Javantura v4 - Java or Scala – Web development with Playframework 2.5.x - Kre...
Javantura v4 - Java or Scala – Web development with Playframework 2.5.x - Kre...Javantura v4 - Java or Scala – Web development with Playframework 2.5.x - Kre...
Javantura v4 - Java or Scala – Web development with Playframework 2.5.x - Kre...
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
Javantura v4 - DMN – supplement your BPMN - Željko Šmaguc
Javantura v4 - DMN – supplement your BPMN - Željko ŠmagucJavantura v4 - DMN – supplement your BPMN - Željko Šmaguc
Javantura v4 - DMN – supplement your BPMN - Željko Šmaguc
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
Javantura v4 - JVM++ The GraalVM - Martin Toshev
Javantura v4 - JVM++ The GraalVM - Martin ToshevJavantura v4 - JVM++ The GraalVM - Martin Toshev
Javantura v4 - JVM++ The GraalVM - Martin Toshev
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
Javantura v4 - FreeMarker in Spring web - Marin Kalapać
Javantura v4 - FreeMarker in Spring web - Marin KalapaćJavantura v4 - FreeMarker in Spring web - Marin Kalapać
Javantura v4 - FreeMarker in Spring web - Marin Kalapać
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
Javantura v4 - Getting started with Apache Spark - Dinko Srkoč
Javantura v4 - Getting started with Apache Spark - Dinko SrkočJavantura v4 - Getting started with Apache Spark - Dinko Srkoč
Javantura v4 - Getting started with Apache Spark - Dinko Srkoč
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
Javantura v4 - Let me tell you a story why Scrum is not for you - Roko Roić
Javantura v4 - Let me tell you a story why Scrum is not for you - Roko RoićJavantura v4 - Let me tell you a story why Scrum is not for you - Roko Roić
Javantura v4 - Let me tell you a story why Scrum is not for you - Roko Roić
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
Javantura v4 - KumuluzEE – Microservices with Java - Matjaž B. Jurič & Tilen ...
Javantura v4 - KumuluzEE – Microservices with Java - Matjaž B. Jurič & Tilen ...Javantura v4 - KumuluzEE – Microservices with Java - Matjaž B. Jurič & Tilen ...
Javantura v4 - KumuluzEE – Microservices with Java - Matjaž B. Jurič & Tilen ...
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 

Viewers also liked (20)

Spring + WebSocket integration
Spring + WebSocket integrationSpring + WebSocket integration
Spring + WebSocket integration
 
Websockets and SockJS, Real time chatting
Websockets and SockJS, Real time chattingWebsockets and SockJS, Real time chatting
Websockets and SockJS, Real time chatting
 
SockJS Intro
SockJS IntroSockJS Intro
SockJS Intro
 
Realtime web application with java
Realtime web application with javaRealtime web application with java
Realtime web application with java
 
게임 고객 사례를 통해 살펴보는 AWS 활용 전략 :: 이경안 :: AWS Summit Seoul 2016
게임 고객 사례를 통해 살펴보는 AWS 활용 전략 :: 이경안 :: AWS Summit Seoul 2016게임 고객 사례를 통해 살펴보는 AWS 활용 전략 :: 이경안 :: AWS Summit Seoul 2016
게임 고객 사례를 통해 살펴보는 AWS 활용 전략 :: 이경안 :: AWS Summit Seoul 2016
 
WebSockets and Java
WebSockets and JavaWebSockets and Java
WebSockets and Java
 
Dynamic Apps with WebSockets and MQTT - IBM Impact 2014
Dynamic Apps with WebSockets and MQTT - IBM Impact 2014Dynamic Apps with WebSockets and MQTT - IBM Impact 2014
Dynamic Apps with WebSockets and MQTT - IBM Impact 2014
 
Consuming web services asynchronously with Futures and Rx Observables (svcc, ...
Consuming web services asynchronously with Futures and Rx Observables (svcc, ...Consuming web services asynchronously with Futures and Rx Observables (svcc, ...
Consuming web services asynchronously with Futures and Rx Observables (svcc, ...
 
Big Data - Linked In_DEEPU
Big Data - Linked In_DEEPUBig Data - Linked In_DEEPU
Big Data - Linked In_DEEPU
 
Creating a Java EE 7 Websocket Chat Application
Creating a Java EE 7 Websocket Chat ApplicationCreating a Java EE 7 Websocket Chat Application
Creating a Java EE 7 Websocket Chat Application
 
웹소켓 (WebSocket)
웹소켓 (WebSocket)웹소켓 (WebSocket)
웹소켓 (WebSocket)
 
Note - (EDK2) Acpi Tables Compile and Install
Note - (EDK2) Acpi Tables Compile and InstallNote - (EDK2) Acpi Tables Compile and Install
Note - (EDK2) Acpi Tables Compile and Install
 
Javantura v4 - CroDuke Indy and the Kingdom of Java Skills - Branko Mihaljevi...
Javantura v4 - CroDuke Indy and the Kingdom of Java Skills - Branko Mihaljevi...Javantura v4 - CroDuke Indy and the Kingdom of Java Skills - Branko Mihaljevi...
Javantura v4 - CroDuke Indy and the Kingdom of Java Skills - Branko Mihaljevi...
 
Javantura v4 - Java or Scala – Web development with Playframework 2.5.x - Kre...
Javantura v4 - Java or Scala – Web development with Playframework 2.5.x - Kre...Javantura v4 - Java or Scala – Web development with Playframework 2.5.x - Kre...
Javantura v4 - Java or Scala – Web development with Playframework 2.5.x - Kre...
 
Javantura v4 - DMN – supplement your BPMN - Željko Šmaguc
Javantura v4 - DMN – supplement your BPMN - Željko ŠmagucJavantura v4 - DMN – supplement your BPMN - Željko Šmaguc
Javantura v4 - DMN – supplement your BPMN - Željko Šmaguc
 
Javantura v4 - JVM++ The GraalVM - Martin Toshev
Javantura v4 - JVM++ The GraalVM - Martin ToshevJavantura v4 - JVM++ The GraalVM - Martin Toshev
Javantura v4 - JVM++ The GraalVM - Martin Toshev
 
Javantura v4 - FreeMarker in Spring web - Marin Kalapać
Javantura v4 - FreeMarker in Spring web - Marin KalapaćJavantura v4 - FreeMarker in Spring web - Marin Kalapać
Javantura v4 - FreeMarker in Spring web - Marin Kalapać
 
Javantura v4 - Getting started with Apache Spark - Dinko Srkoč
Javantura v4 - Getting started with Apache Spark - Dinko SrkočJavantura v4 - Getting started with Apache Spark - Dinko Srkoč
Javantura v4 - Getting started with Apache Spark - Dinko Srkoč
 
Javantura v4 - Let me tell you a story why Scrum is not for you - Roko Roić
Javantura v4 - Let me tell you a story why Scrum is not for you - Roko RoićJavantura v4 - Let me tell you a story why Scrum is not for you - Roko Roić
Javantura v4 - Let me tell you a story why Scrum is not for you - Roko Roić
 
Javantura v4 - KumuluzEE – Microservices with Java - Matjaž B. Jurič & Tilen ...
Javantura v4 - KumuluzEE – Microservices with Java - Matjaž B. Jurič & Tilen ...Javantura v4 - KumuluzEE – Microservices with Java - Matjaž B. Jurič & Tilen ...
Javantura v4 - KumuluzEE – Microservices with Java - Matjaž B. Jurič & Tilen ...
 

Similar to Spring Boot & WebSocket

Spring Boot
Spring BootSpring Boot
Spring Boot
koppenolski
 
Spring boot wednesday
Spring boot wednesdaySpring boot wednesday
Spring boot wednesday
Vinay Prajapati
 
Spring_Boot_Microservices-5_Day_Session.pptx
Spring_Boot_Microservices-5_Day_Session.pptxSpring_Boot_Microservices-5_Day_Session.pptx
Spring_Boot_Microservices-5_Day_Session.pptx
Prabhakaran Ravichandran
 
Bootify your spring application
Bootify your spring applicationBootify your spring application
Bootify your spring application
Jimmy Lu
 
Spring Boot. Boot up your development
Spring Boot. Boot up your developmentSpring Boot. Boot up your development
Spring Boot. Boot up your development
Strannik_2013
 
Testing Spring MVC and REST Web Applications
Testing Spring MVC and REST Web ApplicationsTesting Spring MVC and REST Web Applications
Testing Spring MVC and REST Web Applications
Sam Brannen
 
Cloud compiler - Minor Project by students of CBPGEC
Cloud compiler - Minor Project by students of CBPGEC  Cloud compiler - Minor Project by students of CBPGEC
Cloud compiler - Minor Project by students of CBPGEC
vipin kumar
 
"Spring Boot. Boot up your development" Сергей Моренец
"Spring Boot. Boot up your development" Сергей Моренец"Spring Boot. Boot up your development" Сергей Моренец
"Spring Boot. Boot up your development" Сергей Моренец
Fwdays
 
Integrating Servlets and JSP (The MVC Architecture)
Integrating Servlets and JSP  (The MVC Architecture)Integrating Servlets and JSP  (The MVC Architecture)
Integrating Servlets and JSP (The MVC Architecture)
Amit Ranjan
 
Next stop: Spring 4
Next stop: Spring 4Next stop: Spring 4
Next stop: Spring 4
Oleg Tsal-Tsalko
 
Spring data jpa are used to develop spring applications
Spring data jpa are used to develop spring applicationsSpring data jpa are used to develop spring applications
Spring data jpa are used to develop spring applications
michaelaaron25322
 
Tuning and development with SIP Servlets on Mobicents
Tuning and development with SIP Servlets on MobicentsTuning and development with SIP Servlets on Mobicents
Tuning and development with SIP Servlets on Mobicents
Jean Deruelle
 
Microservice test strategies for applications based on Spring, K8s and Istio
Microservice test strategies for applications based on Spring, K8s and IstioMicroservice test strategies for applications based on Spring, K8s and Istio
Microservice test strategies for applications based on Spring, K8s and Istio
Ahmed Misbah
 
Struts 2-overview2
Struts 2-overview2Struts 2-overview2
Struts 2-overview2divzi1913
 
Struts 2-overview2
Struts 2-overview2Struts 2-overview2
Struts 2-overview2Long Nguyen
 
Session 41 - Struts 2 Introduction
Session 41 - Struts 2 IntroductionSession 41 - Struts 2 Introduction
Session 41 - Struts 2 Introduction
PawanMM
 
Struts 2 - Introduction
Struts 2 - Introduction Struts 2 - Introduction
Struts 2 - Introduction
Hitesh-Java
 
Servlets Java Slides & Presentation
Servlets Java Slides & Presentation Servlets Java Slides & Presentation
Servlets Java Slides & Presentation
Anas Sa
 

Similar to Spring Boot & WebSocket (20)

Spring Boot
Spring BootSpring Boot
Spring Boot
 
Spring boot wednesday
Spring boot wednesdaySpring boot wednesday
Spring boot wednesday
 
Spring_Boot_Microservices-5_Day_Session.pptx
Spring_Boot_Microservices-5_Day_Session.pptxSpring_Boot_Microservices-5_Day_Session.pptx
Spring_Boot_Microservices-5_Day_Session.pptx
 
Bootify your spring application
Bootify your spring applicationBootify your spring application
Bootify your spring application
 
Spring Boot. Boot up your development
Spring Boot. Boot up your developmentSpring Boot. Boot up your development
Spring Boot. Boot up your development
 
Testing Spring MVC and REST Web Applications
Testing Spring MVC and REST Web ApplicationsTesting Spring MVC and REST Web Applications
Testing Spring MVC and REST Web Applications
 
Cloud compiler - Minor Project by students of CBPGEC
Cloud compiler - Minor Project by students of CBPGEC  Cloud compiler - Minor Project by students of CBPGEC
Cloud compiler - Minor Project by students of CBPGEC
 
"Spring Boot. Boot up your development" Сергей Моренец
"Spring Boot. Boot up your development" Сергей Моренец"Spring Boot. Boot up your development" Сергей Моренец
"Spring Boot. Boot up your development" Сергей Моренец
 
Integrating Servlets and JSP (The MVC Architecture)
Integrating Servlets and JSP  (The MVC Architecture)Integrating Servlets and JSP  (The MVC Architecture)
Integrating Servlets and JSP (The MVC Architecture)
 
Next stop: Spring 4
Next stop: Spring 4Next stop: Spring 4
Next stop: Spring 4
 
Spring data jpa are used to develop spring applications
Spring data jpa are used to develop spring applicationsSpring data jpa are used to develop spring applications
Spring data jpa are used to develop spring applications
 
Tuning and development with SIP Servlets on Mobicents
Tuning and development with SIP Servlets on MobicentsTuning and development with SIP Servlets on Mobicents
Tuning and development with SIP Servlets on Mobicents
 
Microservice test strategies for applications based on Spring, K8s and Istio
Microservice test strategies for applications based on Spring, K8s and IstioMicroservice test strategies for applications based on Spring, K8s and Istio
Microservice test strategies for applications based on Spring, K8s and Istio
 
Struts 2-overview2
Struts 2-overview2Struts 2-overview2
Struts 2-overview2
 
Struts 2-overview2
Struts 2-overview2Struts 2-overview2
Struts 2-overview2
 
Session 41 - Struts 2 Introduction
Session 41 - Struts 2 IntroductionSession 41 - Struts 2 Introduction
Session 41 - Struts 2 Introduction
 
Struts 2 - Introduction
Struts 2 - Introduction Struts 2 - Introduction
Struts 2 - Introduction
 
19servlets
19servlets19servlets
19servlets
 
Servlets
ServletsServlets
Servlets
 
Servlets Java Slides & Presentation
Servlets Java Slides & Presentation Servlets Java Slides & Presentation
Servlets Java Slides & Presentation
 

Recently uploaded

weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
Pratik Pawar
 
ethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.pptethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.ppt
Jayaprasanna4
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
TeeVichai
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
Jayaprasanna4
 
Vaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdfVaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdf
Kamal Acharya
 
WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234
AafreenAbuthahir2
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Sreedhar Chowdam
 
Courier management system project report.pdf
Courier management system project report.pdfCourier management system project report.pdf
Courier management system project report.pdf
Kamal Acharya
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
gerogepatton
 
Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.
PrashantGoswami42
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
bakpo1
 
The role of big data in decision making.
The role of big data in decision making.The role of big data in decision making.
The role of big data in decision making.
ankuprajapati0525
 
Democratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek AryaDemocratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek Arya
abh.arya
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
Robbie Edward Sayers
 
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
H.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdfH.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdf
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
MLILAB
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation & Control
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
AhmedHussein950959
 
Forklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella PartsForklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella Parts
Intella Parts
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
seandesed
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
gdsczhcet
 

Recently uploaded (20)

weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
 
ethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.pptethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.ppt
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
 
Vaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdfVaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdf
 
WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
 
Courier management system project report.pdf
Courier management system project report.pdfCourier management system project report.pdf
Courier management system project report.pdf
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
 
Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
 
The role of big data in decision making.
The role of big data in decision making.The role of big data in decision making.
The role of big data in decision making.
 
Democratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek AryaDemocratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek Arya
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
 
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
H.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdfH.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdf
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
 
Forklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella PartsForklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella Parts
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
 

Spring Boot & WebSocket

  • 1. Spring Boot & WebSocket Present by MingIn Wu 2015/7/15 1
  • 2. Outline • Spring Boot – Introduction – Spring Boot Quick Start – Spring Boot External Tomcat plugin – Spring Boot JSP plugin – Spring Boot MySQL & JDBC plugin – Spring Boot Builder Profile – Spring Boot Log4j Plugin – Spring Boot Security • Spring Boot WebSocket – Introduction – WebSocket • Server Side (Spring ) • Client Side (javascript & java) – WebSocket + SockJS • Server Side (Spring) • Client Side (SockJS) – STOMP + WebSocket + SockJS • Server Side (Spring) • Client Side (STOMP) • Use Case Sequence Diagrams 2015/7/15 2
  • 3. Spring Boot Introduction • Primary Goal : – Provide a faster and accessible getting started experience for all Spring development. – Be opinionated out of the box, but get out of the way quickly as requirements start to diverge from the defaults. – Provide a range of non-functional features that are common to large classes of projects. (e.g. embedded servers, security, scalability ). – Absolutely no code generation and no requirement for XML configuration. • System Requirements: – Java 7+ – Tomcat 7+ or glassfish 4+ – Spring Framework 4.1.5+ 2015/7/15 3
  • 4. Different between Spring Boot and Spring 3 • No requirement for XML configuration: • Spring Boot • Spring 3.x 2015/7/15 4
  • 5. Spring Boot Quick Start 2015/7/15 5
  • 6. • 1. Create Spring Starter Project guide : Spring Boot Quick Start (1/3) 2015/7/15 6
  • 7. • 2. pom.xml setting : – 2-1. Packaging executable jar and war files : – 2-2. Use Spring-boot-starter-parent to manage dependencies setting. Spring Boot Quick Start (2/3) 2015/7/15 7
  • 8. Spring Boot Quick Start (3/3) • 3. Project Configuration : – Spring Boot applications need very little Spring configuration. – 1. @SpringBootApplication – 2. @ComponentScan – 3. extends SpringBootServletInitializer 2015/7/15 8
  • 9. Spring Boot External Tomcat plugin 2015/7/15 9
  • 10. Spring Boot External Tomcat plugin • pom.xml setting : – To build a war file that is both executable and deployable into an external container you need to mark the embedded container dependencies as “provided”. 2015/7/15 10
  • 11. Spring Boot JSP plugin 2015/7/15 11
  • 12. Spring Boot JSP plugin • pom.xml setting : • JSP files path : • Set property in the ‘application.properties’ 2015/7/15 12
  • 13. Spring Boot mySQL & JDBC plugin 2015/7/15 13
  • 14. Spring Boot mySQL & JDBC plugin (1/4) • 1. pom.xml setting : • 2. Set property into the ‘application.properties’ 2015/7/15 14
  • 15. Spring Boot mySQL & JDBC plugin (2/4) • 3. Create class ProjectDataSource to replace ‘dataSource-context.xml ‘: – 3-1. Set two pair properties to the data source 2015/7/15 15
  • 16. Spring Boot mySQL & JDBC plugin (3/4) • 3. Create class ProjectDataSource to replace ‘dataSource-context.xml’ : – 3-2. Create two bean classes ‘amway_dataSource’ & ‘sso_dataSource’. – 3-3. Create "sqlLoader" class which is load SQL commands from ‘sql.properties’. 2015/7/15 16
  • 17. Spring Boot mySQL & JDBC plugin (4/4) • 4. Implement interface AppDao and extends by JdbcDaoSupport. 2015/7/15 17
  • 18. Spring Boot Builder Profile 2015/7/15 18
  • 19. Spring Boot Builder Profile • pom.xml setting : – It's the same configuration as other projects (like xBoard .... etc). 2015/7/15 19
  • 20. Spring Boot Log4j Plugin 2015/7/15 20
  • 21. Spring Boot Log4j Plugin (1/2) • pom.xml setting : 2015/7/15 21
  • 22. Spring Boot Log4j Plugin (2/2) • comparing log4j.properties with log4j.xml • log4j.properties • log4j.xml 2015/7/15 22
  • 24. Spring Boot Security (1/5) • pom.xml setting : • System Login form : 2015/7/15 24
  • 25. Spring Boot Security (2/5) • Security Configuration : – 1. SecurityConfiguration config 2015/7/15 25
  • 26. Spring Boot Security (3/5) • Security Configuration : – 2. Comparing the HttpSecurity setting: • SecurityConfiguration class • security-context.xml 2015/7/15 26
  • 27. Spring Boot Security (4/5) • Security Configuration : – 3-1. Comparing the authentication-manager & jdbc-user-service setting: • security-context.xml – Step1. Setting up JdbcUserDetailsManager. – Step2. Setting up Md5PasswordEncoder & ReflectionSaltSource. – Step3. Md5PasswordEncoder & ReflectionSaltSource put in the DaoAuthenticationProvider. – Step4. DaoAuthenticationProvider put in the AuthenticationManagerBuilder. Step2 Step1 Step3&4 2015/7/15 27
  • 28. Spring Boot Security (5/5) • Security Configuration : – 3-2. Comparing the authentication-manager & jdbc-user-service setting: • SecurityConfiguration class Step1 Step2 Step3 Step4 2015/7/15 28
  • 30. Spring Boot WebSocket Introduction (1/3) • Polling vs WebSocket : – 1. Comparison of the unnecessary network throughput overhead between the polling and the WebSocket applications. 2015/7/15 30
  • 31. Spring Boot WebSocket Introduction (2/3) • Polling vs WebSocket : – 2. Comparison between the polling and WebSocket applications. 2015/7/15 31
  • 32. Spring Boot WebSocket Introduction (3/3) • WebSocket Protocol : – WebSocket is an extension to HTTP and enables streaming of data. 2015/7/15 32
  • 33. Spring Boot WebSocket Example (1/5) • Server Side (Spring) : – 1. pom.xml setting : – 2. Configuration (simple) : 2015/7/15 33
  • 34. Spring Boot WebSocket Example (2/5) • Server Side (Spring) : – 4. GreetingHandler : • extends TextWebSocketHandler class. • Greeting Handler class can mix with @Controller and @RequestMapping. 2015/7/15 34
  • 35. Spring Boot WebSocket Example (3/5) • Client Side (javascript) : – 1. connect() 2015/7/15 35
  • 36. Spring Boot WebSocket Example (4/5) • Client Side (javascript) : – 2. sendMessage() – 3. disconnect() 2015/7/15 36
  • 37. Spring Boot WebSocket Example (5/5) • Client Side (java) : – 1. Create ChatClientEndpoint class – 2. call 2015/7/15 37
  • 38. Spring Boot WebSocket & SockJS 2015/7/15 38
  • 39. Spring Boot WebSocket & SockJS Example (1/6) • Spring Server Side : – 1. pom.xml setting : – 2. Configuration (simple) : 2015/7/15 39
  • 40. Spring Boot WebSocket & SockJS Example (2/6) • Spring Server Side : – 3-1. Configuration (websocket session handshake) : • We can capture the http session for a websocket request. • The reason was to determine the number of websocket sessions utilizing the same underlying http session. 2015/7/15 40
  • 41. Spring Boot WebSocket & SockJS Example (3/6) • Spring Server Side : – 3-2. HttpSession Handshake Interceptor : • beforeHandshake() • afterHandshake() 2015/7/15 41
  • 42. Spring Boot WebSocket & SockJS Example (4/6) • Spring Server Side : – 4. GreetingHandler : • extends TextWebSocketHandler class. • Greeting Handler class can mix with @Controller and @RequestMapping. 2015/7/15 42
  • 43. Spring Boot WebSocket & SockJS Example (5/6) • SockJS client side : – 1. SockJS – connect() 2015/7/15 43
  • 44. Spring Boot WebSocket & SockJS Example (6/6) • SockJS client side : – 2. SockJS – sendMessage() – 3. SockJS – disconnect() 2015/7/15 44
  • 45. Spring Boot WebSocket & STOMP 2015/7/15 45
  • 46. Spring Boot WebSocket & STOMP Example (1/6) • STOMP : – STOMP is a simple text-oriented messaging protocol that was originally created for scripting languages to connect to enterprise message brokers. – STOMP is a frame based protocol with frames modeled on HTTP. – STOMP uses different commands like connect, send, subscribe, disconnect etc to communicate. • Command : SEND format (client) Command : SUBSCRIBE format (client) • Command : MESSAGE format (server) - broadcast messages to all subscribers. 2015/7/15 46 Command Header Body Command Header Body Command Header Body
  • 47. Spring Boot WebSocket & STOMP Example (2/6) • Spring Server Side : – 1. Configuration (stomp) : • extends AbstractWebSocketMessageBrokerConfigurer • Configure message broker options. • Configure STOMP over WebSocket end-points. 2015/7/15 47
  • 48. Spring Boot WebSocket & STOMP Example (3/6) • Spring Server Side : – 1. Configuration (stomp) : • GreetingController class can mix with @Controller and @RequestMapping. • @MessageMapping • @SendTo 2015/7/15 48
  • 49. Spring Boot WebSocket & STOMP Example (4/6) • STOMP client side : – 1. STOMP + SockJS – connect() • 1-1 Create a socket object by SockJS. • 1-2 Set StompClient to control the socket. • 1-3 Implement stomp client subscribe function. 2015/7/15 49
  • 50. Spring Boot WebSocket & STOMP Example (5/6) • STOMP client side : – 2. STOMP + SockJS – sendMessage() – 3. STOMP + SockJS – disconnect() 2015/7/15 50
  • 51. Spring Boot WebSocket & STOMP Example (6/6) • Spring - STOMP Architecture : – AbstractWebSocketMessageBrokerConfigurer setting : 2015/7/15 51 Send request /app/hello Send response /topic/greeting Client subscribe /topic/greeting Client send message Send request /topic/greeting
  • 52. Use Case Sequence Diagrams 2015/7/15 52
  • 53. Case1. WebSocket + socJS 2015/7/15 53 – Build B2B WebSocket connection between client & server.
  • 54. Case2. WebSocket + STOMP - 1 – Server Use @SendTo() send message to all of subscriber client. 2015/7/15 54
  • 55. Case3. WebSocket & STOMP - 2 – Server Use @SendToUser() send message to for the specified subscriber client. 2015/7/15 55
  • 56. Case4. WebSocket & STOMP - 3 – Remove enableSimpleBroker() & setApplicationDestinationPrefixes() setting within WebSocketConfig. 2015/7/15 56

Editor's Notes

  1. 1. 提供更快和方便入門體驗所有的Spring開發。 2. 希望能跳開種種限制,卻走不出的方式達到迅速開始的要求。 3. 提供一系列的非功能特性的常用大類的項目。(例如嵌入式服務器,安全性,可擴展性)。 4. 沒有代碼產生和XML配置要求。
  2. 1. STOMP是最初創建的腳本語言來連接到企業信息經紀人簡單的文本為導向的消息傳遞協議。 2. STOMP是仿照HTTP幀一幀的基礎協議。 3. STOMP使用不同的命令狀連接,發送,訂閱,斷開等進行溝通。