Subversion Repositories SmartDukaan

Rev

Rev 1953 | Rev 3428 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1946 chandransh 1
package in.shop2020.payment.service;
2
 
3
import org.apache.thrift.protocol.TBinaryProtocol;
4
import org.apache.thrift.protocol.TProtocolFactory;
5
import org.apache.thrift.server.TServer;
6
import org.apache.thrift.server.TThreadPoolServer;
7
import org.apache.thrift.transport.TFramedTransport;
8
import org.apache.thrift.transport.TServerSocket;
9
import org.apache.thrift.transport.TServerTransport;
10
import org.apache.thrift.transport.TTransportFactory;
1953 chandransh 11
import org.slf4j.Logger;
12
import org.slf4j.LoggerFactory;
1946 chandransh 13
 
14
import in.shop2020.payment.service.handler.PaymentServiceHandler;
15
import in.shop2020.payments.PaymentService.Processor;
2885 chandransh 16
import in.shop2020.thrift.clients.config.ConfigClient;
17
import in.shop2020.utils.ConfigClientKeys;
1946 chandransh 18
 
19
public class PaymentServer {
1953 chandransh 20
	private static Logger logger = LoggerFactory.getLogger(PaymentServer.class);
21
 
1946 chandransh 22
	private static PaymentServiceHandler handler;
23
 
24
	private static Processor processor;
25
 
26
	public static void main(String[] args){
27
		try{
28
			handler = new PaymentServiceHandler();
29
			processor = new Processor(handler);
30
 
2885 chandransh 31
			int port = 9012;
32
			try {
33
			    String portNo = ConfigClient.getClient().get(ConfigClientKeys.payments_service_server_port.toString());
34
			    port = Integer.parseInt(portNo);
35
			}catch(Exception e){
36
			    logger.warn("Unable to get port number from the Config server because of:", e);
37
			}
38
 
39
			TServerTransport serverTransport = new TServerSocket(port);
1946 chandransh 40
			TTransportFactory tFactory = new TFramedTransport.Factory();
41
			TProtocolFactory pFactory = new TBinaryProtocol.Factory();
42
			TServer server = new TThreadPoolServer(processor, serverTransport, tFactory, pFactory);
43
 
1953 chandransh 44
			logger.info("Payment service started on port 9012");
1946 chandransh 45
			server.serve();
46
		}catch(Exception ex){
47
			ex.printStackTrace();
48
		}
49
	}
50
}