ãã©ã¦ã¶ã®æ¹ã¯ããããã«ããã³ã·ã£ã«ã追ãã¤ãã¦ããHTML5ã
ãWebSocket/ServerSentEventsã¨ããã大è¦æ¨¡ãªã·ã¹ãã ã¸ã®å°å ¥ãã¡ãããããã£ã¦ãã¤ãã¦ã¯ãè¡è²ã®è¯ãã£ãã¨ã³ã¸ãã¢ã®èãã¿ãã¿ãéããã¦ãæ£æ°ãï¼ãªãã¨ï¼ï¼ãã¨ãç½µãããã®ãããæè¿ã®ç§ã®è¶£å³ã§ãããã¾ãã
ããã§ã¾ãä¸å¿ãä½æ
ï¼ãã¨èãã¦ã¿ãã®ã§ããããã®çç±ã¯çãã©ãã©ããªã®ã§ãç¾æç¹ã§ã®WebSocket/ServerSentEventsã®å¤§è¦æ¨¡ã·ã¹ãã å°å
¥ã«ã¤ãã¦ã®åé¡ç¹ããã ãããç§ã®ç¥ã£ã¦ããç¯å²ã§ã¾ã¨ãã¦ã¿ã¾ããã
1. JavaEE7対å¿ã®APãµã¼ã製åãå°ãªã
WebSocketãªã©HTML5ã®éä¿¡ç³»æè¡ã使ãã¨ãªãã¨ããã¯ãNode.jsã«ãªãã®ã§ããããããããã¨ã³ã¿ã¼ãã©ã¤ãºã¨ãªãã¨ããã¯ã主åã¯Javaã§ããããªãç¡ããªããªãã¦ãã¨ã¯ãããã¾ããããããªãã¨ãããã³ãã¨ã³ãã®ããã«ãµã¼ãã®ã¢ã¼ããã¯ãã£ãå ¨ã¦è¦ç´ãã¨ããã®ã¯é£ããããµã¼ããµã¤ãã®AP製åããHTML5æ©è½ãã©ã®ç¨åº¦ã¾ã§ãµãã¼ãããããéè¦ã ããï¼ï¼ã£ã¨ããããã£ãèãã®äººãããã®ã§ã¯ãªããã¨æãã¾ãã
å æ¥ã®JavaOneã«ã¦ãWebSocketãServerSentEventsãJavaEE7ã§ãµãã¼ãããã¨å ¬è¡¨ãããããã§ãããå½ç¶ããããµãã¼ãããå®è£ ãååã«æ´ã£ã¦ããã¨ã¯è¨ãã¾ãããã©ã®ç¨åº¦ãµãã¼ããã¦ããããå製åã®å¯¾å¿ç¶æ³ãè¦ã¦ã¿ã¾ãããã
WebLogic
ç§ã®ç¥äººãã2013å¹´ã¯ç§ã12.1.2ãããµãã¼ããããã£ã¦ãä¸ã®äººãï¼ãã£ã¦è¨ã£ã¦ã¾ããããã ãã½ã¼ã¹ãä»å¹´ã®åãã ã£ãã¨ãããã¨ããããæ¬å½ã«ãããªããã¯è¬ã§ããWebLogicã¯ã¨ã³ã¿ã¼ãã©ã¤ãºè£½åã¨ãããã¨ããããOSSã®ããã«æ確ãªãã¼ãããããåºã¦ããªãããã§ãã
å®éã®ã¨ããã¯ã10æã«Oracleãéãå ¥å ´æ2,000ãã«ä»¥ä¸ããããè¶ ç人åãã¨åããããã®ã¤ãã³ãã«è¡ã£ã¦ã¿ãªããã¨ã«ã¯ããããªãã§ããããããªãã¢ãããã¼ãã§å ¥ã£ã¦ãããããã®ã§ãã¦ã©ãããã¦ãããªãã¨ããã¾ããã
JBoss
ã³ãã¥ããã£çã§ã¯æ¢ã«å®è£ ããã¦ãã¾ããGAçã«ã¤ãã¦ã¯2013å¹´11æãªãªã¼ã¹ã®åã§ãµãã¼ããããã¨åããã¦ãã¾ãããå®éã«RedHat社ã®ãã³ãã¼ãµãã¼ããåããã«ã¯ããã®åå¹´å¾ã«ãªãã¾ãããªã®ã§ãç¾å ´ã§ä½¿ããã®ã¯æ¥å¹´ã«ãªãã®ã§ãããã
GlassFish
ã¨ã£ãã«ä½¿ãã¾ããã£ã¨ãããããGlassFish7ã¯ãJava EE 7ã®åç §å®è£ ã§ãï¼ããããå®è£ ãããã§ãããWebLogicãJBossã®Java EE 7ã®ä½¿ç¨æã確ããããªããGlassFishã使ããã¨ã«ãªãã§ãããã
Tomcat
ããæ¢ã«ãµãã¼ããã¦ããããã§ããããã¿ã¾ãããã½ã¼ã¹ãè¦ã¤ããã¾ãããæ¬å½ã«ãµãã¼ããã¦ããã®ã ããããããServletãjspã®åç §å®è£ ã¨ãã¦æ´»ç¨ããã¦ããã¨ã¯èãã¦ãã¾ãããJava EEã®åç §å®è£ ã§ã¯ãªãã£ãã¯ããªã®ã§ããããã¾ããã
Jetty
æ©ãææãããµãã¼ããã¦ããããã§ããããã ããJava EE 7ã®å®è£ ã¨åãã§ã¯ãªããããªæãã§ãããæ®å¿µã§ãã
ã£ã¨ã¾ããå ¨ãåããªãã¨ãã訳ã§ã¯ããã¾ãããããã³ãã¼ãµãã¼ããåãããæåã©ãã製åã¯è»ä¸¦ã¿ãæ¥å¹´ãæ¬æ ¼çãªéå§ã¨ããæãã«ãªã£ã¦ããã¾ãã2014å¹´ãHTML5å å¹´ã¨ããè¨èãé ·ãã¾ãããã¾ããåºã¦ãã¦ããã¨ãããã¨ããããäºææ§é¢ã§ãå¿é ã«ãªãã¾ãããµã¼ããµã¤ãã®äºææ§ã¯ããã³ãã¨ã³ãã«æ¯ã¹ããããã¾ãéè¦ãããªãã£ããããã¾ããããµã¼ããµã¤ããããã³ãã¨ã³ãå´ã®æè¡ã«è¿½ãã¤ãã®ã¯ãããå°ãæéããããã®ããããã¾ãããã
ãæããã¦Javaã§ããã¹ããªã®ãï¼ãã£ã¨ããè°è«ãããã¾ããããã®ãããã¯æ¬¡ç« ã§ã
2. ã¤ã³ãã©ã®è¨è¨ãå°é£
ããã¾ã§ã®HTTPãã¼ã¹ã®éç¨ã¯ããã¹ãã¼ãã¬ã¹ã§ãããã¨ãåæãã§è¨è¨ããã¦ããã®ã§ã¯ãªãã§ãããããå¤å°ã¯æ··ããã£ãããããã®ã®ãM/M/1ã¢ãã«ãåæã«ãè² è·åæ£ã»ä¿¡é ¼æ§åä¸ã®ã¢ããã¼ããè¡ãªã£ã¦ããã®ã§ã¯ãªããã¨æãã¾ãããããWebSocketãªã©ã¯ããããããªããSocket.ioã¿ãããªã³ã³ããã¼ã«ã»ãã·ã§ã³ã¨ãã¼ã¿ã»ãã·ã§ã³ãå¥ã§æã£ã¦ãã¾ãå ´åããã¼ããã©ã³ãµã¼ã«è²ã ä»è¾¼ã¿ãå¿ è¦ã«ãªã£ã¦ãã¾ãã¾ããæ¥åã·ã¹ãã ã ã¨çã§APãè¦ãã¦ãã¾ã£ã¦ãè¯ãã§ãããåææ¥ç¶æ°ãå¤ãã·ã¹ãã ã ã¨ããããããªãã§ãããã
ãªã¹ã¯ãé«ãã¨ããçç±ã§ãã®ããããç¡è¦ãç¶ããã¨ãããã¨ã¯ç¡ãã¨æã£ã¦ã¦ãã©ããã®ã¿ã¤ãã³ã°ã§ãWebSocketãServerSentEventsã®éæ¿ã¿ãããªããæ¹ãè¦ã¤ãããã¦ãä¸ã®ä¸ã«æµ¸éããã®ããªãã¨æãã¾ããå¥ã«æ°ããèãæ¹ãè¦ã¤ãããã¨ããããã§ã¯ãªããFTPã®è² è·åæ£ãªããã¯ãæ®å¿µãªãã¨ã«æ¥åã·ã¹ãã ã®ãããªã¬ã¬ã·ã¼ãªä¸çã ã¨ã¾ã ãã£ã¦ãã¨ããããã£ã¦ãããããã¨ããããè² è·åæ£ã»ä¿¡é ¼æ§åä¸ã¢ããã¼ãé¢ã§ã®ãã¦ãã¦ãæµå ¥ãã¦ããããããã¾ãããããããã°Flexãªããããä¼¼ããããªãã¨ããã£ã¦ããæ°ããã¾ãã
ãµã¼ãèªä½ã®è¨è¨é¢ã§è¨ãã°ããã¹ãã¼ãã¬ã¹ãªã»ãã·ã§ã³ã¨ã¹ãã¼ããã«ãªã»ãã·ã§ã³ã¯ãå¥ã®APã§å¦çãããã¨ããèãæ¹ã¯ãå®ãã¹ãå¿ é ã®èãæ¹ã§ããããä¾ãããªãããããç¨éã¨ãªã³ã©ã¤ã³ç¨éãå¥ã«ãããããªãã®ã§ãããããããªãã¨ãã¨ã¦ãã¨ã¦ãè² è·åæ£ã®ã¢ã¼ããã¯ãã£è¨è¨ãªãã¦ã§ãã¾ããã
ã§ããã®ããããåæã¨ããã¨ããªãã¨ãªãã§ããApacheã«ã¹ãã¼ããã«ãªã»ãã·ã§ã³ãå¦çãããã¨ããã®ãéåæãæãã¾ããããããããã¾ãã¹ãã¼ããã«ãªãã¨ãããããã¨ãæ³å®ãã¦ããªãæ¢åã®ãµã¼ãAPããã®ã¾ã¾ä½¿ãç¶ããã¨ããã®ããããæ°æã¡æªããã¹ãã¼ããã«ãªã»ãã·ã§ã³ã ãã¯å¥ã®AP製åããã¯ããã¸ã¼ã使ã£ã¦å¦çããã¨ããã®ãããä½æ³ãªæ°ããã¦ãã¾ãã
ããããã°å æ¥ããããªè£½åãè¨äºã«ãªã£ã¦ã¾ããã
Kaazing WebSocket Gateway
http://kaazing.com/products/kaazing-websocket-gateway
ãKaazingã¯ãä¸çã§å¯ä¸ã¤ã®ã¨ã³ã¿ã¼ãã©ã¤ãºåãWebSocketã²ã¼ãã¦ã§ã¤ã§ãããã£ã¨ãããææé¤æ©ã彷彿ã¨ããã謳ãæå¥ã«ã¤ãã¤ãç®ãå¼ããã¦ãã¾ãã¾ããã
å°ãã°ããç®çãéã£ã¦ãã¾ãããHPå ã®å³ã«ããMessage Brokerã¨ãTCP Serverã¨å¼ã°ãããã®ãWebSocketã®æ¥ç¶å ã ã¨ãããªããWebSocketãServersentEventsã¯ããããã£ãå°ç¨ã®æè¡ãä»ãã¦å¦çããããã®ãä»å¾ã®ä¸»æµã«ãªãã¨äºæããããã¾ãããåãHTTPã§ãããã¯ããã¸ã¼ã¨ãã¦å¥ç©ã¨ãã¦æããã®ã妥å½ãªãã§ããããIPAã®æ å ±å¦ç試é¨ãããHTTPã¯ã¹ãã¼ãã¬ã¹ãªãããã³ã«ã§ãããã¨ããå 容ãåé¤ãããæ¥ããããé ããªãã®ããããã¾ããã
3. 使ããã³ããããããªã
ã¤ã³ã¿ã¼ãããã¡ãã£ã¢ã¨ã¨ã³ã¿ã¼ãã©ã¤ãºã·ã¹ãã ã¯ãæè¡çã«ã¯ä¼¼ã¦ã¦ããUIãã¶ã¤ã³ã¨ããé¢ã§ã¯èª²é¡ã解決æ¹æ³ãéã£ã¦ããããã«æãã¾ããDBè¨è¨ãããã§ããããããã¨ããã«æ¥çã®ãä½æ³ã¿ãããªã®ããã£ã±ãæ··ãã£ã¦ãã¾ããç¾è¡ã®ã¢ãã ããè¦ã¦ããã¨ãWebSocket/ServerEventã®ä½¿ããã³ããã¤ãã¤ããããããã¾ããã
ãã ãããã¯åã«é©ç¨äºä¾ãå°ãªãããã ã¨æãã¾ãã
ã¹ãã¼ãããã¤ã¹ãæ¥åã·ã¹ãã ã§æ´»ç¨ããå ´åããªãã©ã¤ã³åã¨ãããã£ãéä¿¡æè¡ã¯ã»ããã«ãªãã¨æã£ã¦ã¦ãå®éã«å¶æ¥ããã使ãã·ã¹ãã ã§æ´»ç¨ãããã¨ãã¦ããã¨ãã声ãèããã¦ãã¾ããã¹ãã¼ãããã¤ã¹ã®åºç¾ã§ãä»ã¾ã§å®ç¾ã§ããªãã£ãæ¥åãã·ã¹ãã ã§è¡ããããã«ãªããæ¥åã®æ°è¦éæé åãä¸å¿ã«ããããã£ãæ°ããæè¡ãåºãã£ã¦ããã®ã§ã¯ãªãã§ããããã
ã¦ã¼ã¶ããç®ã«è¦ããå½¢ã§ãã¼ãã¦ã§ã¢ã®å¤åãåã³å¤§ãããªã£ãæ¨ä»ãæ¥åã·ã¹ãã ã¯é¨åçã«ãããã£ãå¤åãèµ·ããã¨æã£ã¦ã¦ããããã¾ã ä¸ã®ä¸ã«åºãã£ã¦ããªãç¾ç¶ã ããè¦ã¦ããã¨ããä»ããã¹ããã«ããè¦ããªãã®ã§ããããªãã®ã¯å½ç¶ã ã¨æããã§ããç§ãå°å¦æ ¡ã®é ãã¾ãããããªæºå¸¯é»è©±ãæã¡æ©ãæ¥ãæ¥ãã ãªãã¦æã£ã¦ããã¾ããã§ãããï¼ç¬ï¼
ã¤ã¾ãä½ãè¨ãããã®ãã¨ããã¨ãHTML5æã®å¤ã®äººéããã¯ã使ãéãããããªããã¨è¨ããã¦ç解ããããããã¨ããªãå¯åæ³ãªWebSocketã§ãããåºå¹¹ã·ã¹ãã ã§ããWebæè¡ä¸å¿ã«ãªããã¹ãã¼ãããã¤ã¹ã®æ¥åã·ã¹ãã æ´»ç¨ãåºããæè¿ã®æè¡é©æ°ã®äºæ ãéã¿ãã«ã"ä»"ã ããè¦ã¦ã使ãéãªãã¦ç¡ãã ãããã¨è¨ãåãã®ã¯ãæ©è¨ã§ã¯ãªããã¨æããã§ãããWebSocketãæ£ãããã¨ã¯è¨ãåããªãã®ã§ãããã¯ã©ã¤ã¢ã³ãã»ãµã¼ãéã®éä¿¡ã®ããããã«ãå¤å°ãªãã¨ãå¤åãèµ·ããã®ã§ã¯ãªããã¨æãã¦ãã¾ãã
ãããªæãã§èª²é¡ã¯å±±ç©ãã¦ãã¾ããã»ã»ã»
HTML5ããã·ã¹ãã ã®ã¢ã¼ããã¯ãã£ãã¶ã¤ã³ã«ã¤ã³ãã¯ããä¸ããæ°ããèãæ¹ãå¿ è¦ã¨ããã¦ããã®ã¯ééããªãã®ã§ãå°æ¥ã©ããªã¢ã¤ãã¢ãçã¾ããã®ããç§ã¯æ¥½ãã¿ã§ä»æ¹ããã¾ããã
ãããããããWebSocketããããã£ã¨æ¬æ°ã§æ°ããèãæ¹ãçã¾ãã¦ã2ã3å¹´å¾ã«ã¯ããããã飲ã¿è¾¼ããããããªãï¼ã¨ã³ã¿ã¼ãã©ã¤ãºç³»ã·ã¹ãã ã®ã©ã¤ããµã¤ã¯ã«ããè¦ãã¨ãåå¼ãã¦ããï¼ãã£ã¦æãã§ãããããå人çãªæ³ãã¨ãã¦ã¯ãæè¡é©æ°ã¯æè¿ãããã£ã¨åºããã¹ãã ã¨æã£ã¦ãã¾ãã®ã§ãã¬ã³ã¬ã³è¡ããããã£ã¦æãã§è¦å®ããã¨æãã¾ãï¼ç¬ï¼