download
LZ downloads the windows version, there is only one exe file, LZ is renamed to thritf.exe, you can add the path where the exe file is located to the environment variable, so that you can run the thrift command directly on the command line, LZ is not configured , so every time you go to the file where the exe is located to run this command, and finally write a script directly, saving you from using the command line every time, just click this script to run
@echo off
D:\thrift\thrift -v --gen java --out ../java Hello.thrift
@pause
-v is to display the process of execution (can be ignored)
–gen is to specify the language
–out specifies which folder to generate
Hello.thrift as the file name
structure
Hierarchy | effect |
---|---|
Transport | network read/write network |
Protocol | A protocol specifies how a data type encodes/decodes itself using the underlying transport, such as JSON, XML, plain text, binary |
Processor | A processor encapsulates the ability to read data from an input stream and write to an output stream |
Server | The server brings together all the above features |
interface TProcessor {
bool process(TProtocol in, TProtocol out) throws TException
}
Transfer Protocol | describe |
---|---|
TBinaryProtocol | Binary encoding format for data transmission |
TCompactProtocol | Efficient, dense binary encoding format for data transmission |
TJSONProtocol | Data transfer using JSON's data encoding protocol |
TSimpleJSONProtocol | Provides only a JSON write-only protocol, suitable for parsing through scripting languages |
server type | describe |
---|---|
TSimpleServer | Single-threaded server side using standard blocking I/O |
TThreadPoolServer | Multithreaded server side uses standard blocking I/O |
TNonblockingServer | Multithreaded server side using non-blocking I/O |
example
Reference blog
[1]https://www.cnblogs.com/fingerboy/p/6424248.html
[2]https://www.ibm.com/developerworks/cn/java/j-lo-apachethrift/
[3]https://www.cnblogs.com/johnc/archive/2011/06/19/2084508.html
[4]http://www.micmiu.com/soa/rpc/thrift-sample/
Spring Boot集成thrift
[5]https://cloud.tencent.com/developer/article/1050391