Giter VIP home page Giter VIP logo

hello-apache-thrift's Introduction

Apache Thrift - Esempio base

Il repository contiene un esempio in Java di comunicazione server-client, in cui la classe service è creata automaticamente utilizzando la libreria Apache Thrift.

L'esempio è ispirato al Quickstart di Dzone.

Installazione Apache Thrift

Per installare thrift è sufficiente seguire le istruzioni raccolte sul sito ufficiale. Personalmente, ho avuto i seguenti problemi:

  • la versione di libboost consigliata sul sito è troppo vecchia (ho dovuto installare la v.1.58.)
  • ANT è necessario per poter generare le classi Java con thrift
  • è stato necessario aggiungere export LD_LIBRARY_PATH=/usr/local/lib/:${LD_LIBRARY_PATH} nel file .bashrc

Utilizzo di Thrift

Per generare la classe AdditionService.java è utilizzato il file add.thrift nel seguente modo:
thrift --gen java -out ./thrift-sample-server/src/main/java/ add.thrift
Le restanti classi dei pacchetti server e client sono costruite a mano.

Organizzazione con Maven

I pacchetti server, client e parent sono stati "pommizzati" per automatizzare la compilazione degli esempi. I file pom.xml necessitano comunque di miglioramento.

Per generare insieme i due file .jar, spostarsi in thrift-sample-parent e digitare:
mvn clean install

Per generare uno solo dei file .jar, spostarsi nella cartella desiderata e digitare:
mvn clean compile assembly:single
In questo modo saranno generati i file .jar contenenti le dipendenze necessarie.

Provare l'esempio

Una volta generati i due file .jar, eseguire prima il server ed in seguito il client con il comando java -jar.
Se tutto è andato a buon fine, dovreste vedere un 42 sulla console del client.

hello-apache-thrift's People

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.