{"id":41938,"date":"2015-07-25T15:00:34","date_gmt":"2015-07-25T12:00:34","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/?p=41938"},"modified":"2015-07-21T11:52:45","modified_gmt":"2015-07-21T08:52:45","slug":"websocket-client-api-in-java-ee-7","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2015\/07\/websocket-client-api-in-java-ee-7.html","title":{"rendered":"WebSocket Client API in Java EE 7"},"content":{"rendered":"<p>In this post, let\u2019s explore the less talked about <em>Web Socket Client API<\/em> and how to leverage it within a Java EE 7 container itself.<\/p>\n<h2>Web Socket Server API rules<\/h2>\n<p>The server side API of <a href=\"https:\/\/jcp.org\/en\/jsr\/detail?id=356\" target=\"_blank\">JSR 356<\/a> (Web Socket API for Java) is most commonly used for building Web Socket endpoint implementations. More often than not, from a client perspective, the standard JavaScript Web Socket API is leveraged by the HTML5 (browser) based clients which attach themselves to web socket server end points and enjoy bi-directional and full-duplex communication. You would have seen common examples such applications such as live maps, stock tickers, games, screen sharing etc \u2013 all these use cases are perfect for Web Sockets and Java EE 7 is the ideal platform for building scalable Web Socket driven back end.<\/p>\n<h2>What about the Web Socket client side API ?<\/h2>\n<p>The Web Socket specification includes a client side API as well and its mandatory for all JSR 356 (e.g. <a href=\"https:\/\/tyrus.java.net\/\" target=\"_blank\">Tyrus<\/a>, <a href=\"http:\/\/undertow.io\/\" target=\"_blank\">Undertow <\/a>etc) implementations to provide one. There are quite a few use cases wherein a browser based \/ end user facing web socket client <em>might not be<\/em> required.<\/p>\n<h4>Example<\/h4>\n<p>Consider a scenario where you want to connect to a third party Web Socket end point, consume it\u2019s information and persist it for later use ? Maybe for further analysis ? In such cases, its useful to leverage the client API within the Java EE container itself.<\/p>\n<p>Let\u2019s explore this with a simple example.<\/p>\n<h4>(annotated) Web Socket Client<\/h4>\n<p><strong>Note:<\/strong> the logic for @OnMessage was excluded on purpose and has been implemented in a different way (clarified later)<\/p>\n<pre class=\"brush:java\">package blog.abhirockzz.wordpress.com;\r\n\r\nimport javax.websocket.ClientEndpoint;\r\nimport javax.websocket.OnClose;\r\nimport javax.websocket.OnError;\r\nimport javax.websocket.Session;\r\n\r\n@ClientEndpoint\r\npublic class StockTickerClient {\r\n\r\n    @OnClose\r\n    public void closed(Session session) {\r\n        System.out.println(\"Session \" + session + \" closed\");\r\n\r\n    }\r\n\r\n    @OnError\r\n    public void error(Throwable error) {\r\n        System.out.println(\"Error: \" + error.getMessage());\r\n\r\n    }\r\n\r\n}<\/pre>\n<h4>A Stock Ticker (info) JPA entity<\/h4>\n<pre class=\"brush:java\">package blog.abhirockzz.wordpress.com;\r\n\r\nimport java.io.Serializable;\r\nimport javax.persistence.Entity;\r\nimport javax.persistence.GeneratedValue;\r\nimport javax.persistence.GenerationType;\r\nimport javax.persistence.Id;\r\nimport javax.persistence.Table;\r\n\r\n@Entity\r\n@Table(name = \"STOCK_TICK\")\r\npublic class StockTick implements Serializable {\r\n\r\n    @Id\r\n    @GeneratedValue(strategy = GenerationType.AUTO)\r\n    private Long id;\r\n\r\n    private String name;\r\n    private String price;\r\n\r\n    public StockTick(String name, String price) {\r\n        this.name = name;\r\n        this.price = price;\r\n    }\r\n\r\n    public StockTick() {\r\n        \/\/for JPA\r\n    }\r\n\r\n    \/\/getters and setters omitted ...\r\n}<\/pre>\n<h4>A Stateless bean<\/h4>\n<ul>\n<li>Handles persistence of Stock Ticker info<\/li>\n<li>Executes its operations against the default JDBC data source provided by the Java EE 7 container (<em>convention over configuration<\/em> in action!)<\/li>\n<\/ul>\n<pre class=\"brush:java\">package blog.abhirockzz.wordpress.com;\r\n\r\nimport javax.ejb.Stateless;\r\nimport javax.persistence.EntityManager;\r\nimport javax.persistence.PersistenceContext;\r\n\r\n@Stateless\r\npublic class StockInfoPersistenceService {\r\n    \r\n    @PersistenceContext\r\n    EntityManager em;\r\n    \r\n    public void save(String name, String price){\r\n        em.persist(new StockTick(name, price));\r\n    }\r\n}<\/pre>\n<h4>Singleton EJB<\/h4>\n<ul>\n<li>Leverages the Web Socket <em>ContainerProvider <\/em>API<\/li>\n<li>Initiates the connection to a web socket server<\/li>\n<li>Injects the <em>StockInfoPersistenceService <\/em>bean and uses it within the <em>addMessageHandler<\/em> implementation<\/li>\n<\/ul>\n<p>As per previous note, the (persistence) logic which could have been embedded in a @OnMessage annotated method within the <a href=\"https:\/\/gist.github.com\/abhirockzz\/1171496eca68d0cac0da\" target=\"_blank\">StockTickerClient <\/a>class has been included here. This is because the injection of the <a href=\"https:\/\/gist.github.com\/abhirockzz\/7695475758e712bb7240\" target=\"_blank\">StockInfoPersistenceService <\/a>(stateless) bean was failing and the instance itself was being resolved to null.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<pre class=\"brush:java;wrap-lines:false\">package blog.abhirockzz.wordpress.com;\r\n\r\nimport java.io.IOException;\r\nimport java.net.URI;\r\nimport java.net.URISyntaxException;\r\nimport java.util.logging.Level;\r\nimport java.util.logging.Logger;\r\nimport javax.annotation.PostConstruct;\r\nimport javax.annotation.PreDestroy;\r\nimport javax.ejb.Singleton;\r\nimport javax.ejb.Startup;\r\nimport javax.inject.Inject;\r\nimport javax.websocket.ContainerProvider;\r\nimport javax.websocket.DeploymentException;\r\nimport javax.websocket.MessageHandler;\r\nimport javax.websocket.Session;\r\nimport javax.websocket.WebSocketContainer;\r\n\r\n@Singleton\r\n@Startup\r\npublic class StockServiceBootstrapBean {\r\n\r\n    private final String WS_SERVER_URL = \"ws:\/\/api.stocks\/ticker\"; \/\/fictitious\r\n    private Session session = null;\r\n\r\n    @Inject\r\n    StockInfoPersistenceService tickRepo;\r\n\r\n    @PostConstruct\r\n    public void bootstrap() {\r\n        WebSocketContainer webSocketContainer = null;\r\n        try {\r\n            webSocketContainer = ContainerProvider.getWebSocketContainer();\r\n            session = webSocketContainer.connectToServer(StockTickerClient.class, new URI(WS_SERVER_URL));\r\n\r\n            System.out.println(\"Connected to WS endpoint \" + WS_SERVER_URL);\r\n            session.addMessageHandler(new MessageHandler.Whole&lt;String&gt;() {\r\n\r\n                @Override\r\n                public void onMessage(String msg) {\r\n                    tickRepo.save(msg.split(\":\")[0], msg.split(\":\")[1]);\r\n                }\r\n            });\r\n        } catch (DeploymentException | IOException | URISyntaxException ex) {\r\n            Logger.getLogger(StockServiceBootstrapBean.class.getName()).log(Level.SEVERE, null, ex);\r\n        }\r\n    }\r\n\r\n    @PreDestroy\r\n    public void destroy() {\r\n        close();\r\n    }\r\n\r\n    private void close() {\r\n        try {\r\n            session.close();\r\n            System.out.println(\"CLOSED Connection to WS endpoint \" + WS_SERVER_URL);\r\n        } catch (IOException ex) {\r\n            Logger.getLogger(StockServiceBootstrapBean.class.getName()).log(Level.SEVERE, null, ex);\r\n        }\r\n    }\r\n}<\/pre>\n<p>That\u2019s pretty much it. Although this was a relatively simple example, its not too hard to imagine that one can apply any sort of complex business logic on the information received by the web socket server endpoint. You might also want to think about sending messages to connected clients in an asynchronous fashion using the <em>session.getAsyncRemote#sendAsync<\/em> method<\/p>\n<p>Cheers!<\/p>\n<div class=\"attribution\">\n<table>\n<tbody>\n<tr>\n<td><span class=\"reference\">Reference: <\/span><\/td>\n<td><a href=\"http:\/\/abhirockzz.wordpress.com\/2015\/07\/20\/websocket-client-api-in-java-ee-7\/\">WebSocket Client API in Java EE 7<\/a> from our <a href=\"http:\/\/www.javacodegeeks.com\/jcg\/\">JCG partner<\/a> Abhishek Gupta at the <a href=\"http:\/\/abhirockzz.wordpress.com\/\">Object Oriented.. <\/a> blog.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this post, let\u2019s explore the less talked about Web Socket Client API and how to leverage it within a Java EE 7 container itself. Web Socket Server API rules The server side API of JSR 356 (Web Socket API for Java) is most commonly used for building Web Socket endpoint implementations. More often than &hellip;<\/p>\n","protected":false},"author":545,"featured_media":112,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[33,885],"class_list":["post-41938","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java","tag-jpa","tag-websocket"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>WebSocket Client API in Java EE 7 - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"In this post, let\u2019s explore the less talked about Web Socket Client API and how to leverage it within a Java EE 7 container itself. Web Socket Server API\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/2015\/07\/websocket-client-api-in-java-ee-7.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"WebSocket Client API in Java EE 7 - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"In this post, let\u2019s explore the less talked about Web Socket Client API and how to leverage it within a Java EE 7 container itself. Web Socket Server API\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2015\/07\/websocket-client-api-in-java-ee-7.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:author\" content=\"http:\/\/www.facebook.com\/100000586869380\" \/>\n<meta property=\"article:published_time\" content=\"2015-07-25T12:00:34+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Abhishek Gupta\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/abhi_tweeter\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Abhishek Gupta\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2015\\\/07\\\/websocket-client-api-in-java-ee-7.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2015\\\/07\\\/websocket-client-api-in-java-ee-7.html\"},\"author\":{\"name\":\"Abhishek Gupta\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/ef37bd58f3ae6f6504852858ad1d7cd7\"},\"headline\":\"WebSocket Client API in Java EE 7\",\"datePublished\":\"2015-07-25T12:00:34+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2015\\\/07\\\/websocket-client-api-in-java-ee-7.html\"},\"wordCount\":456,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2015\\\/07\\\/websocket-client-api-in-java-ee-7.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/enterprise-java-logo.jpg\",\"keywords\":[\"JPA\",\"WebSocket\"],\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2015\\\/07\\\/websocket-client-api-in-java-ee-7.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2015\\\/07\\\/websocket-client-api-in-java-ee-7.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2015\\\/07\\\/websocket-client-api-in-java-ee-7.html\",\"name\":\"WebSocket Client API in Java EE 7 - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2015\\\/07\\\/websocket-client-api-in-java-ee-7.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2015\\\/07\\\/websocket-client-api-in-java-ee-7.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/enterprise-java-logo.jpg\",\"datePublished\":\"2015-07-25T12:00:34+00:00\",\"description\":\"In this post, let\u2019s explore the less talked about Web Socket Client API and how to leverage it within a Java EE 7 container itself. Web Socket Server API\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2015\\\/07\\\/websocket-client-api-in-java-ee-7.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2015\\\/07\\\/websocket-client-api-in-java-ee-7.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2015\\\/07\\\/websocket-client-api-in-java-ee-7.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/enterprise-java-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/enterprise-java-logo.jpg\",\"width\":150,\"height\":150,\"caption\":\"java-interview-questions-answers\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2015\\\/07\\\/websocket-client-api-in-java-ee-7.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enterprise Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\\\/enterprise-java\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"WebSocket Client API in Java EE 7\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/ef37bd58f3ae6f6504852858ad1d7cd7\",\"name\":\"Abhishek Gupta\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3f3fc8e83d92bec29f7cb54bba3d5043d138c479a66a4711483bc6b4d95ae37c?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3f3fc8e83d92bec29f7cb54bba3d5043d138c479a66a4711483bc6b4d95ae37c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3f3fc8e83d92bec29f7cb54bba3d5043d138c479a66a4711483bc6b4d95ae37c?s=96&d=mm&r=g\",\"caption\":\"Abhishek Gupta\"},\"sameAs\":[\"http:\\\/\\\/abhirockzz.wordpress.com\\\/\",\"http:\\\/\\\/www.facebook.com\\\/100000586869380\",\"http:\\\/\\\/in.linkedin.com\\\/pub\\\/abhishek-gupta\\\/27\\\/331\\\/866\",\"https:\\\/\\\/x.com\\\/https:\\\/\\\/twitter.com\\\/abhi_tweeter\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/abhishek-gupta\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"WebSocket Client API in Java EE 7 - Java Code Geeks","description":"In this post, let\u2019s explore the less talked about Web Socket Client API and how to leverage it within a Java EE 7 container itself. Web Socket Server API","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javacodegeeks.com\/2015\/07\/websocket-client-api-in-java-ee-7.html","og_locale":"en_US","og_type":"article","og_title":"WebSocket Client API in Java EE 7 - Java Code Geeks","og_description":"In this post, let\u2019s explore the less talked about Web Socket Client API and how to leverage it within a Java EE 7 container itself. Web Socket Server API","og_url":"https:\/\/www.javacodegeeks.com\/2015\/07\/websocket-client-api-in-java-ee-7.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_author":"http:\/\/www.facebook.com\/100000586869380","article_published_time":"2015-07-25T12:00:34+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg","type":"image\/jpeg"}],"author":"Abhishek Gupta","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/abhi_tweeter","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Abhishek Gupta","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2015\/07\/websocket-client-api-in-java-ee-7.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2015\/07\/websocket-client-api-in-java-ee-7.html"},"author":{"name":"Abhishek Gupta","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/ef37bd58f3ae6f6504852858ad1d7cd7"},"headline":"WebSocket Client API in Java EE 7","datePublished":"2015-07-25T12:00:34+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2015\/07\/websocket-client-api-in-java-ee-7.html"},"wordCount":456,"commentCount":1,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2015\/07\/websocket-client-api-in-java-ee-7.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg","keywords":["JPA","WebSocket"],"articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2015\/07\/websocket-client-api-in-java-ee-7.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2015\/07\/websocket-client-api-in-java-ee-7.html","url":"https:\/\/www.javacodegeeks.com\/2015\/07\/websocket-client-api-in-java-ee-7.html","name":"WebSocket Client API in Java EE 7 - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2015\/07\/websocket-client-api-in-java-ee-7.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2015\/07\/websocket-client-api-in-java-ee-7.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg","datePublished":"2015-07-25T12:00:34+00:00","description":"In this post, let\u2019s explore the less talked about Web Socket Client API and how to leverage it within a Java EE 7 container itself. Web Socket Server API","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2015\/07\/websocket-client-api-in-java-ee-7.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2015\/07\/websocket-client-api-in-java-ee-7.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2015\/07\/websocket-client-api-in-java-ee-7.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg","width":150,"height":150,"caption":"java-interview-questions-answers"},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2015\/07\/websocket-client-api-in-java-ee-7.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/www.javacodegeeks.com\/category\/java"},{"@type":"ListItem","position":3,"name":"Enterprise Java","item":"https:\/\/www.javacodegeeks.com\/category\/java\/enterprise-java"},{"@type":"ListItem","position":4,"name":"WebSocket Client API in Java EE 7"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/ef37bd58f3ae6f6504852858ad1d7cd7","name":"Abhishek Gupta","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/3f3fc8e83d92bec29f7cb54bba3d5043d138c479a66a4711483bc6b4d95ae37c?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/3f3fc8e83d92bec29f7cb54bba3d5043d138c479a66a4711483bc6b4d95ae37c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/3f3fc8e83d92bec29f7cb54bba3d5043d138c479a66a4711483bc6b4d95ae37c?s=96&d=mm&r=g","caption":"Abhishek Gupta"},"sameAs":["http:\/\/abhirockzz.wordpress.com\/","http:\/\/www.facebook.com\/100000586869380","http:\/\/in.linkedin.com\/pub\/abhishek-gupta\/27\/331\/866","https:\/\/x.com\/https:\/\/twitter.com\/abhi_tweeter"],"url":"https:\/\/www.javacodegeeks.com\/author\/abhishek-gupta"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/41938","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/545"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=41938"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/41938\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/112"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=41938"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=41938"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=41938"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}