• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Realtime web application with java
 

Realtime web application with java

on

  • 5,181 views

JCO 2011에서 발표한 슬라이드

JCO 2011에서 발표한 슬라이드

Statistics

Views

Total Views
5,181
Views on SlideShare
4,031
Embed Views
1,150

Actions

Likes
0
Downloads
81
Comments
0

6 Embeds 1,150

http://blog.outsider.ne.kr 1113
http://www.hanrss.com 16
http://intranet.netville.co.kr:8080 7
http://dc.inogard.co.kr 7
http://feeds2.feedburner.com 6
http://local.netville.co.kr:8080 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Realtime web application with java Realtime web application with java Presentation Transcript

    • RealtimeWeb Application withJava Arawn&Outsiderin봄싹 2011.6.19
    • RealTimeWeb
    • ServerPush
    • 리얼타임웹에 대해서얼마나 알고계십니까?
    • http://springsprout.org:10000/
    • Client-side Server-side
    • 일단.... Client-side
    • 현재 (어쩌면약간과거)
    • Polling
    • 브라우저 서버
    • 요청브라우저 서버
    • 요청 응답브라우저 서버
    • 요청 응답 이벤트브라우저 서버
    • 요청 응답주기 이벤트브라우저 서버
    • 요청 응답주기 이벤트 요청브라우저 서버
    • 요청 응답주기 이벤트 요청 응답브라우저 서버
    • 사실... 서버푸시라고 하기는어렵습니다.
    • Comet WebSocket &
    • Comet
    • Ajax처럼 특정기술이 아닌패턴
    • LongLived HTTP Connection
    • Long Polling
    • 브라우저 서버
    • 요청브라우저 서버
    • 요청 대기브라우저 서버
    • 요청 대기 이벤트브라우저 서버
    • 요청 대기 응답 이벤트브라우저 서버
    • 요청 대기 응답 이벤트 요청브라우저 서버
    • JSONP Polling
    • JSONP== JSONwithpadding
    • 스크립트태그로호출<scriptsrc=”http://domain.com/?callback=process”></script>서버에서콜백함수로JSON객체리턴 process({ “key”:“value”, “key2”:“value2” });
    • 동일출처정책 SameOriginPolicy
    • 도메인당 커넥션2개제한
    • Streaming
    • 브라우저 서버
    • 요청브라우저 서버
    • 요청 대기브라우저 서버
    • 요청 대기 이벤트브라우저 서버
    • 요청 대기 이벤트 응답(Chunked)브라우저 서버
    • 요청 대기 이벤트 응답(Chunked) 이벤트브라우저 서버
    • 요청 대기 이벤트 응답(Chunked) 응답(Chunked) 이벤트브라우저 서버
    • varxhr=newXMLHttpRequest();xhr.oepn(GET,/comet,true);xhr.onreadystatechange=function(){if(xhr.readyState==3&&xhr.status==200){//xhr.responseText}}
    • Chunked???
    • IE는지원하지않습니다
    • Foreveriframe (Hiddeniframe)
    • 웹페이지 서버
    • 웹페이지 hiddeniframe 서버
    • 웹페이지 요청 hiddeniframe 서버
    • 웹페이지 요청 hiddeniframe ChunkedData 서버
    • 웹페이지 요청 hiddeniframe ChunkedData <script>데이터</script> 서버
    • 클릭소리 로딩바문제
    • ActiveXObject(“htmlfile”)
    • WebSocket
    • HTML5 W3C/IETF표준 WebSocket프로토콜사용 진정한양방향통신
    • HTTP를 업그래이드해서 웹소켓프로토콜을 연결한다
    • HTTP호환handshake80/443으로동작Proxy/firewall에친화적ws://와wss://사용
    • //요청 GET/demoHTTP/1.1 Upgrade:WebSocket Connection:Upgrade Host:example.com Origin:http://example.com Websocket-Protocol:sample //응답 HTTP/1.1101WebSocketProtocolHandshake Upgrade:Websocket Connection:Upgrade Websocket-Origin:http://example.com WebSocket-Location:ws://example.com/demo WebSocket-Protocol:sample
    • varws= newWebSocket("ws://domain.com"); ws.onOpen= function(e){console.log("opened");} ws.onRead= function(e){console.log(e.data);} ws.onClose= function(e){console.log("closed");} ws.send("HelloWorld");
    • Adobe Flash Socket
    • Server-side
    • 지속적인연결! (persistentconnection)
    • Thread per Request
    • ThreadperRequest ServletContainer Request Thread ServletPool Request Servlet Thread Servlet Request Servlet Thread Servlet .... Request Thread
    • Servlet Container Comet지원
    • Resin (3.1+)
    • CometServletpublicinterface CometServletextendsServlet{booleanservice(ServletRequest,ServletResponse,CometController)throwsServletException,IOException;booleanresume(ServletRequest,ServletResponse,CometController)throwsServletException,IOException;}
    • ResinComet SampleCode
    • ResinCometServlet처리흐름 Job Client CometServlet Executor service(cometCtrl) execute(cometCtrl) suspend cometCtrl.wake() resume resume(cometCtrl)
    • Jetty (3.0+)
    • Continuation publicinterface Continuation{  publicbooleansuspend(longtimeout);  publicvoidresume(); ... }
    • Tomcat (6.0+)
    • CometProcessor publicinterface CometProcessor extendsServlet{ publicvoidevent(CometEvent) throwsIOException, ServletException; }
    • Servlet3.0 (JSR315)
    • <servlet><servlet-name>AsyncMessageListenServlet</servlet-name><servlet-class>...</servlet-class><async-supported>true</async-supported></servlet><servlet-mapping><servlet-name>AsyncMessageListenServlet</servlet-name><url-pattern>/messageListen</url-pattern></servlet-mapping>
    • interface HttpServletRequest extendsServletRequest{ AsyncContextstartAsync(); AsyncContextstartAsync( ServletRequest,ServletResponse); }
    • publicinterface AsyncContext{ publicServletRequestgetRequest(); publicServletResponsegetResponse(); }
    • Servlet3.0 Sample Code
    • AsynchronousServlet처리흐름 Job Client AsyncServlet Executor request.startAsync() execute(asyncContext) asyncContext.complete()
    • WebSocket Server
    • -jWebSocket(http://jwebsocket.org/)-Netty(http://www.jboss.org/netty)-Grizzly(http://grizzly.java.net/)
    • 추상화
    • Clientside WebBrowser InternetExplorer/FireFox/Chrome/Safari... CometClient LongPolling/Streaming(XMLHttpRequest,foreveriframe)/WebSocket Serverside CometServer
    • Comet Library
    • Lightstreamer scalableandreliableServerfor pushinglivedatatoRich InternetApplications
    • Socket.IO J2EEServletbasedSocket.IO serverimplementation.
    • Project Atmosphere aportableAjaxPush/Comet andWebSocketFramework
    • Streamhub HTTPCometand ReverseAjaxserver
    • Server Long Hidden Web Flash Push polling iframe Socket SocketLightstreamer O O O O O Socket.IO O O X O OAtmosphere O O O O X Streamhub O O O O O
    • Streamhub - QXQuiz CodeReview https://github.com /spring-sprout /jco-2011-realtime
    • Thread vs Evented
    • Questions...?Arawnarawn.kr@gmail.comhttp://arawn.tistory.comOutsideroutsideris@gmail.comhttp://blog.outsider.ne.kr