{"id":1009,"date":"2012-03-14T01:34:00","date_gmt":"2012-03-14T01:34:00","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/2012\/10\/apache-thrift-quickstart-tutorial.html"},"modified":"2012-10-21T23:16:13","modified_gmt":"2012-10-21T23:16:13","slug":"apache-thrift-quickstart-tutorial","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2012\/03\/apache-thrift-quickstart-tutorial.html","title":{"rendered":"Apache Thrift Quickstart Tutorial"},"content":{"rendered":"<div dir=\"ltr\" style=\"text-align: left\"><a href=\"http:\/\/thrift.apache.org\/\">Thrift <\/a>is a cross language RPC framework initially developed at Facebook, now open sourced as an Apache project. This post will describe how to write a thrift service and client in different modes such as blocking, non blocking and asynchronous.<\/p>\n<p>(I felt latter two modes are less documented and needed some tutorial type introduction, hence the motivation of this post). To easily follow the tutorial it\u2019s beneficial that you have a basic understanding of Thrift architecture consisting of Transports, Protocols and Processors. (A good paper can be found at [1]). Here I will be using Thrift version 0.7 and Thrift\u2019s Java binding.<\/p>\n<p>Thrift Installation<br \/>\nInstallation instructions can be found at<a href=\"http:\/\/wiki.apache.org\/thrift\/ThriftInstallation\"> http:\/\/wiki.apache.org\/thrift\/ThriftInstallation<\/a>.<\/p>\n<p>To sum up Ubuntu installation steps.<\/p>\n<p>1. Install required dependencies.<br \/>\n<i>$ sudo apt-get install libboost-dev libboost-test-dev libboost-program-options-dev libevent-dev automake libtool flex bison pkg-config g++ libssl-dev<\/i><br \/>\n2. Go to the installation root directory.<br \/>\n3.<i>  $ .\/configure<\/i><br \/>\n4.  <i>$ make<\/i><br \/>\n5. Become super user and<br \/>\n&nbsp; &nbsp;<i>$ make install<\/i><\/p>\n<p>Now let\u2019s get on with creating the service and consuming it.<\/p>\n<p>Service Definition<\/p>\n<p>Here a service with simple arithmetic operations is defined. Note the use of typedef directive to declare alternative names for base types i64 and i32. Add following in a file named  \u2018<strong>arithmetic.thrift<\/strong>\u2019.<\/p>\n<pre class=\"brush:bash\">namespace java tutorial.arithmetic.gen  \/\/ define namespace for java code\r\n\r\ntypedef i64 long\r\ntypedef i32 int\r\nservice ArithmeticService {  \/\/ defines simple arithmetic service\r\nlong add(1:int num1, 2:int num2),\r\nlong multiply(1:int num1, 2:int num2),\r\n}\r\n<\/pre>\n<p>Code will be generated under \u2018<strong>tutorial.arithmetic.gen<\/strong>\u2019 package.<\/p>\n<p>Now generate Java code using following command line.<\/p>\n<p>$ thrift \u2013gen java arithmetic.thrift<\/p>\n<p>The source <strong>tutorial.arithmetic.gen.ArithmeticService.java<\/strong> will be generated.<\/p>\n<p>Blocking Mode<\/p>\n<p>Let\u2019s create a blocking mode server and a client to consume the service.<\/p>\n<p>First we need to implement the service using generated service skeleton. The interface to implement is ArithmeticService.Iface.<\/p>\n<pre class=\"brush:java\">public class ArithmeticServiceImpl implements ArithmeticService.Iface {\r\n\r\n    public long add(int num1, int num2) throws TException {\r\n        return num1 + num2;\r\n    }\r\n\r\n    public long multiply(int num1, int num2) throws TException {\r\n        return num1 * num2;\r\n    }\r\n\r\n}\r\n<\/pre>\n<p>Now that being done let\u2019s create the Thrift server which would server request for this service. Remember this is a blocking server so the server threads doing I\/O will wait.<\/p>\n<pre class=\"brush:java\">public class Server {\r\n\r\n    private void start() {\r\n        try {\r\n            TServerSocket serverTransport = new TServerSocket(7911);\r\n\r\n            ArithmeticService.Processor processor = new ArithmeticService.Processor(new ArithmeticServiceImpl());\r\n\r\n            TServer server = new TThreadPoolServer(new TThreadPoolServer.Args(serverTransport).\r\n                    processor(processor));\r\n            System.out.println(\"Starting server on port 7911 ...\");\r\n            server.serve();\r\n        } catch (TTransportException e) {\r\n            e.printStackTrace();\r\n        }\r\n    }\r\n\r\n    public static void main(String[] args) {\r\n        Server srv = new Server();\r\n        srv.start();\r\n    }\r\n\r\n}\r\n<\/pre>\n<p>Here TThreadPoolServer implementation is used which would utilize a thread pool to serve incoming requests.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<p>Now let\u2019s write the client.<\/p>\n<pre class=\"brush:java\">public class ArithmeticClient {\r\n\r\n    private void invoke() {\r\n        TTransport transport;\r\n        try {\r\n            transport = new TSocket(\"localhost\", 7911);\r\n\r\n            TProtocol protocol = new TBinaryProtocol(transport);\r\n\r\n            ArithmeticService.Client client = new ArithmeticService.Client(protocol);\r\n            transport.open();\r\n\r\n            long addResult = client.add(100, 200);\r\n            System.out.println(\"Add result: \" + addResult);\r\n            long multiplyResult = client.multiply(20, 40);\r\n            System.out.println(\"Multiply result: \" + multiplyResult);\r\n\r\n            transport.close();\r\n        } catch (TTransportException e) {\r\n            e.printStackTrace();\r\n        } catch (TException e) {\r\n            e.printStackTrace();\r\n        }\r\n    }\r\n\r\n    public static void main(String[] args) {\r\n        ArithmeticClient c = new ArithmeticClient();\r\n        c.invoke();\r\n\r\n    }\r\n}\r\n<\/pre>\n<p>TBinaryProtocol is used for encoding data transferred between server and client. Now start the server and invoke the service using client to results.<\/p>\n<p>Non Blocking Mode<br \/>\nNow lets create a non blocking server which uses Java non blocking I\/O underneath. We can use the same service implementation as before (ArithmeticServiceImpl).<\/p>\n<pre class=\"brush:java\">public class NonblockingServer {\r\n\r\n    private void start() {\r\n        try {\r\n            TNonblockingServerTransport serverTransport = new TNonblockingServerSocket(7911);\r\n            ArithmeticService.Processor processor = new ArithmeticService.Processor(new ArithmeticServiceImpl());\r\n\r\n            TServer server = new TNonblockingServer(new TNonblockingServer.Args(serverTransport).\r\n                    processor(processor));\r\n            System.out.println(\"Starting server on port 7911 ...\");\r\n            server.serve();\r\n        } catch (TTransportException e) {\r\n            e.printStackTrace();\r\n        }\r\n    }\r\n\r\n    public static void main(String[] args) {\r\n        NonblockingServer srv = new NonblockingServer();\r\n        srv.start();\r\n    }\r\n}\r\n<\/pre>\n<p>Here TNonblockingServerSocket is used which encapsulates a ServerSocketChannel.<\/p>\n<p>Code for the non blocking client is as follows.<\/p>\n<pre class=\"brush:java\">public class NonblockingClient {\r\n\r\n    private void invoke() {\r\n        TTransport transport;\r\n        try {\r\n            transport = new TFramedTransport(new TSocket(\"localhost\", 7911));\r\n            TProtocol protocol = new TBinaryProtocol(transport);\r\n\r\n            ArithmeticService.Client client = new ArithmeticService.Client(protocol);\r\n            transport.open();\r\n\r\n            long addResult = client.add(100, 200);\r\n            System.out.println(\"Add result: \" + addResult);\r\n            long multiplyResult = client.multiply(20, 40);\r\n            System.out.println(\"Multiply result: \" + multiplyResult);\r\n\r\n            transport.close();\r\n        } catch (TTransportException e) {\r\n            e.printStackTrace();\r\n        } catch (TException e) {\r\n            e.printStackTrace();\r\n        }\r\n    }\r\n\r\n    public static void main(String[] args) {\r\n        NonblockingClient c = new NonblockingClient();\r\n        c.invoke();\r\n    }\r\n\r\n}\r\n<\/pre>\n<p>Note the usage of TFramedTransport wrapping normal TSocket transport. Non blocking server requires client to use TFramedTransport which would frame the data sent over the wire. Fire up the server and send a request using the client. You will see the same results as before, this time using non blocking mode.<\/p>\n<p>Asynchronous Mode<\/p>\n<p>We can write asynchronous clients to call a Thrift service. A callback needs to be registered which will get invoked at successful completion of the request. Blocking mode server didn\u2019t work (method invocation returns with an empty response) with the asynchronous client (May be it\u2019s because we are using TNonblockingSocket at the client side. See construction of <i>ArithmeticService.AsyncClient<\/i>. So this may be the proper behaviour). Non blocking mode  server seems to work without an issue. So you can use the non blocking server from earlier with the client shown below.<\/p>\n<pre class=\"brush:java\">public class AsyncClient {\r\n\r\n    private void invoke() {\r\n        try {\r\n            ArithmeticService.AsyncClient client = new ArithmeticService.\r\n                    AsyncClient(new TBinaryProtocol.Factory(), new TAsyncClientManager(),\r\n                                new TNonblockingSocket(\"localhost\", 7911));\r\n\r\n            client.add(200, 400, new AddMethodCallback());\r\n\r\n            client = new ArithmeticService.\r\n                    AsyncClient(new TBinaryProtocol.Factory(), new TAsyncClientManager(),\r\n                                new TNonblockingSocket(\"localhost\", 7911));\r\n            client.multiply(20, 50, new MultiplyMethodCallback());\r\n\r\n        } catch (TTransportException e) {\r\n            e.printStackTrace();\r\n        } catch (TException e) {\r\n            e.printStackTrace();\r\n        } catch (IOException e) {\r\n            e.printStackTrace();\r\n        }\r\n    }\r\n\r\n    public static void main(String[] args) {\r\n        AsyncClient c = new AsyncClient();\r\n        c.invoke();\r\n\r\n    }\r\n\r\n    class AddMethodCallback\r\n            implements AsyncMethodCallback&lt;ArithmeticService.AsyncClient.add_call&gt; {\r\n\r\n        public void onComplete(ArithmeticService.AsyncClient.add_call add_call) {\r\n            try {\r\n                long result = add_call.getResult();\r\n                System.out.println(\"Add from server: \" + result);\r\n            } catch (TException e) {\r\n                e.printStackTrace();\r\n            }\r\n        }\r\n\r\n        public void onError(Exception e) {\r\n            System.out.println(\"Error : \");\r\n            e.printStackTrace();\r\n        }\r\n\r\n    }\r\n\r\n    class MultiplyMethodCallback\r\n            implements AsyncMethodCallback&lt;ArithmeticService.AsyncClient.multiply_call&gt; {\r\n\r\n        public void onComplete(ArithmeticService.AsyncClient.multiply_call multiply_call) {\r\n            try {\r\n                long result = multiply_call.getResult();\r\n                System.out.println(\"Multiply from server: \" + result);\r\n            } catch (TException e) {\r\n                e.printStackTrace();\r\n            }\r\n        }\r\n\r\n        public void onError(Exception e) {\r\n            System.out.println(\"Error : \");\r\n            e.printStackTrace();\r\n        }\r\n\r\n    }\r\n\r\n}\r\n<\/pre>\n<p>Two callbacks have been defined corresponding to each operation of the service. Note the usage of two client instances for the two invocations. Each invocation needs a separate client instance or otherwise client will fail with following exception<\/p>\n<p>\u201c<i>Exception in thread \u201cmain\u201d java.lang.IllegalStateException: Client is currently executing another method: tutorial.arithmetic.gen.ArithmeticService$AsyncClient$add_call<\/i>\u201c<\/p>\n<p>So this wraps up my quick start on Thrift with different modes of operation. Hope somebody may find this useful. For any suggestions or corrections do not hesitate to comment.<\/p>\n<p>[1] <a href=\"http:\/\/thrift.apache.org\/static\/thrift-20070401.pdf\">http:\/\/thrift.apache.org\/static\/thrift-20070401.pdf<\/a><\/p>\n<p><strong><i>Reference: <\/i><\/strong><a href=\"http:\/\/chamibuddhika.wordpress.com\/2011\/10\/02\/apache-thrift-quickstart-tutorial\/\">Apache Thrift Quickstart Tutorial<\/a>&nbsp;from our <a href=\"http:\/\/www.javacodegeeks.com\/p\/jcg.html\">JCG partner<\/a><span class=\"Apple-style-span\"><span class=\"Apple-style-span\" style=\"line-height: 18px\"><strong>&nbsp;<\/strong><\/span><\/span>Buddhika Chamith at the&nbsp;<a href=\"http:\/\/chamibuddhika.wordpress.com\/\">Source Open<\/a>&nbsp;blog.  <\/div>\n","protected":false},"excerpt":{"rendered":"<p>Thrift is a cross language RPC framework initially developed at Facebook, now open sourced as an Apache project. This post will describe how to write a thrift service and client in different modes such as blocking, non blocking and asynchronous. (I felt latter two modes are less documented and needed some tutorial type introduction, hence &hellip;<\/p>\n","protected":false},"author":184,"featured_media":82,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[406],"class_list":["post-1009","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java","tag-apache-thrift"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Apache Thrift Quickstart Tutorial - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"Thrift is a cross language RPC framework initially developed at Facebook, now open sourced as an Apache project. This post will describe how to write a\" \/>\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\/2012\/03\/apache-thrift-quickstart-tutorial.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Apache Thrift Quickstart Tutorial - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"Thrift is a cross language RPC framework initially developed at Facebook, now open sourced as an Apache project. This post will describe how to write a\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2012\/03\/apache-thrift-quickstart-tutorial.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:published_time\" content=\"2012-03-14T01:34:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2012-10-21T23:16:13+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/apache-thrift-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=\"Buddhika Chamith\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Buddhika Chamith\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/03\\\/apache-thrift-quickstart-tutorial.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/03\\\/apache-thrift-quickstart-tutorial.html\"},\"author\":{\"name\":\"Buddhika Chamith\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/7af2cea55ca73fc3e60af1916f30f854\"},\"headline\":\"Apache Thrift Quickstart Tutorial\",\"datePublished\":\"2012-03-14T01:34:00+00:00\",\"dateModified\":\"2012-10-21T23:16:13+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/03\\\/apache-thrift-quickstart-tutorial.html\"},\"wordCount\":654,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/03\\\/apache-thrift-quickstart-tutorial.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/apache-thrift-logo.jpg\",\"keywords\":[\"Apache Thrift\"],\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/03\\\/apache-thrift-quickstart-tutorial.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/03\\\/apache-thrift-quickstart-tutorial.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/03\\\/apache-thrift-quickstart-tutorial.html\",\"name\":\"Apache Thrift Quickstart Tutorial - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/03\\\/apache-thrift-quickstart-tutorial.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/03\\\/apache-thrift-quickstart-tutorial.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/apache-thrift-logo.jpg\",\"datePublished\":\"2012-03-14T01:34:00+00:00\",\"dateModified\":\"2012-10-21T23:16:13+00:00\",\"description\":\"Thrift is a cross language RPC framework initially developed at Facebook, now open sourced as an Apache project. This post will describe how to write a\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/03\\\/apache-thrift-quickstart-tutorial.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/03\\\/apache-thrift-quickstart-tutorial.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/03\\\/apache-thrift-quickstart-tutorial.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/apache-thrift-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/apache-thrift-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/03\\\/apache-thrift-quickstart-tutorial.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\":\"Apache Thrift Quickstart Tutorial\"}]},{\"@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\\\/7af2cea55ca73fc3e60af1916f30f854\",\"name\":\"Buddhika Chamith\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/79e0891b29887f100b22a526408e01007cbb10ae2cf302541d1884315933d3d8?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/79e0891b29887f100b22a526408e01007cbb10ae2cf302541d1884315933d3d8?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/79e0891b29887f100b22a526408e01007cbb10ae2cf302541d1884315933d3d8?s=96&d=mm&r=g\",\"caption\":\"Buddhika Chamith\"},\"sameAs\":[\"http:\\\/\\\/chamibuddhika.wordpress.com\\\/\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/Buddhika-Chamith\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Apache Thrift Quickstart Tutorial - Java Code Geeks","description":"Thrift is a cross language RPC framework initially developed at Facebook, now open sourced as an Apache project. This post will describe how to write a","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\/2012\/03\/apache-thrift-quickstart-tutorial.html","og_locale":"en_US","og_type":"article","og_title":"Apache Thrift Quickstart Tutorial - Java Code Geeks","og_description":"Thrift is a cross language RPC framework initially developed at Facebook, now open sourced as an Apache project. This post will describe how to write a","og_url":"https:\/\/www.javacodegeeks.com\/2012\/03\/apache-thrift-quickstart-tutorial.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2012-03-14T01:34:00+00:00","article_modified_time":"2012-10-21T23:16:13+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/apache-thrift-logo.jpg","type":"image\/jpeg"}],"author":"Buddhika Chamith","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Buddhika Chamith","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2012\/03\/apache-thrift-quickstart-tutorial.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/03\/apache-thrift-quickstart-tutorial.html"},"author":{"name":"Buddhika Chamith","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/7af2cea55ca73fc3e60af1916f30f854"},"headline":"Apache Thrift Quickstart Tutorial","datePublished":"2012-03-14T01:34:00+00:00","dateModified":"2012-10-21T23:16:13+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/03\/apache-thrift-quickstart-tutorial.html"},"wordCount":654,"commentCount":2,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/03\/apache-thrift-quickstart-tutorial.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/apache-thrift-logo.jpg","keywords":["Apache Thrift"],"articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2012\/03\/apache-thrift-quickstart-tutorial.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2012\/03\/apache-thrift-quickstart-tutorial.html","url":"https:\/\/www.javacodegeeks.com\/2012\/03\/apache-thrift-quickstart-tutorial.html","name":"Apache Thrift Quickstart Tutorial - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/03\/apache-thrift-quickstart-tutorial.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/03\/apache-thrift-quickstart-tutorial.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/apache-thrift-logo.jpg","datePublished":"2012-03-14T01:34:00+00:00","dateModified":"2012-10-21T23:16:13+00:00","description":"Thrift is a cross language RPC framework initially developed at Facebook, now open sourced as an Apache project. This post will describe how to write a","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/03\/apache-thrift-quickstart-tutorial.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2012\/03\/apache-thrift-quickstart-tutorial.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2012\/03\/apache-thrift-quickstart-tutorial.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/apache-thrift-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/apache-thrift-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2012\/03\/apache-thrift-quickstart-tutorial.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":"Apache Thrift Quickstart Tutorial"}]},{"@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\/7af2cea55ca73fc3e60af1916f30f854","name":"Buddhika Chamith","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/79e0891b29887f100b22a526408e01007cbb10ae2cf302541d1884315933d3d8?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/79e0891b29887f100b22a526408e01007cbb10ae2cf302541d1884315933d3d8?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/79e0891b29887f100b22a526408e01007cbb10ae2cf302541d1884315933d3d8?s=96&d=mm&r=g","caption":"Buddhika Chamith"},"sameAs":["http:\/\/chamibuddhika.wordpress.com\/"],"url":"https:\/\/www.javacodegeeks.com\/author\/Buddhika-Chamith"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/1009","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\/184"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=1009"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/1009\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/82"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=1009"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=1009"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=1009"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}