Rev 2885 | Rev 4619 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
package in.shop2020.payment.service;import org.apache.thrift.protocol.TBinaryProtocol;import org.apache.thrift.protocol.TProtocolFactory;import org.apache.thrift.server.TServer;import org.apache.thrift.server.TThreadPoolServer;import org.apache.thrift.server.TThreadPoolServer.Args;import org.apache.thrift.transport.TFramedTransport;import org.apache.thrift.transport.TServerSocket;import org.apache.thrift.transport.TServerTransport;import org.apache.thrift.transport.TTransportFactory;import org.slf4j.Logger;import org.slf4j.LoggerFactory;import in.shop2020.payment.service.handler.PaymentServiceHandler;import in.shop2020.payments.PaymentService.Iface;import in.shop2020.payments.PaymentService.Processor;import in.shop2020.thrift.clients.config.ConfigClient;import in.shop2020.utils.ConfigClientKeys;public class PaymentServer {private static Logger logger = LoggerFactory.getLogger(PaymentServer.class);private static PaymentServiceHandler handler;private static Processor<Iface> processor;public static void main(String[] args){try{handler = new PaymentServiceHandler();processor = new Processor<Iface>(handler);int port = 9012;try {String portNo = ConfigClient.getClient().get(ConfigClientKeys.payments_service_server_port.toString());port = Integer.parseInt(portNo);}catch(Exception e){logger.warn("Unable to get port number from the Config server because of:", e);}TServerTransport serverTransport = new TServerSocket(port);TTransportFactory tFactory = new TFramedTransport.Factory();TProtocolFactory pFactory = new TBinaryProtocol.Factory();Args serverParams = new Args(serverTransport);serverParams.processor(processor);serverParams.transportFactory(tFactory);serverParams.protocolFactory(pFactory);TServer server = new TThreadPoolServer(serverParams);logger.info("Payment service started on port 9012");server.serve();}catch(Exception ex){ex.printStackTrace();}}}