| 3024 |
mandeep.dh |
1 |
/**
|
|
|
2 |
*
|
|
|
3 |
*/
|
|
|
4 |
package in.shop2020.crm.service;
|
|
|
5 |
|
| 3428 |
rajveer |
6 |
import in.shop2020.crm.CRMService.Iface;
|
| 3024 |
mandeep.dh |
7 |
import in.shop2020.crm.CRMService.Processor;
|
|
|
8 |
import in.shop2020.crm.service.handler.CRMServiceHandler;
|
|
|
9 |
import in.shop2020.thrift.clients.config.ConfigClient;
|
|
|
10 |
import in.shop2020.utils.ConfigClientKeys;
|
|
|
11 |
|
|
|
12 |
import org.apache.thrift.protocol.TBinaryProtocol;
|
|
|
13 |
import org.apache.thrift.protocol.TProtocolFactory;
|
|
|
14 |
import org.apache.thrift.server.TServer;
|
|
|
15 |
import org.apache.thrift.server.TThreadPoolServer;
|
| 3428 |
rajveer |
16 |
import org.apache.thrift.server.TThreadPoolServer.Args;
|
| 3024 |
mandeep.dh |
17 |
import org.apache.thrift.transport.TFramedTransport;
|
|
|
18 |
import org.apache.thrift.transport.TServerSocket;
|
|
|
19 |
import org.apache.thrift.transport.TServerTransport;
|
|
|
20 |
import org.apache.thrift.transport.TTransportFactory;
|
|
|
21 |
import org.slf4j.Logger;
|
|
|
22 |
import org.slf4j.LoggerFactory;
|
|
|
23 |
|
|
|
24 |
/**
|
|
|
25 |
* Service for accessing all necessary data relevant for CRM tool.
|
|
|
26 |
* Example tickets, activities, agents etc.
|
|
|
27 |
*
|
|
|
28 |
* @author mandeep
|
|
|
29 |
*/
|
|
|
30 |
public class CRMServer {
|
|
|
31 |
private static Logger logger = LoggerFactory.getLogger(CRMServer.class);
|
|
|
32 |
|
|
|
33 |
private static CRMServiceHandler handler;
|
|
|
34 |
|
| 3428 |
rajveer |
35 |
private static Processor<Iface> processor;
|
| 3024 |
mandeep.dh |
36 |
|
|
|
37 |
public static void main(String[] args) {
|
|
|
38 |
try {
|
|
|
39 |
handler = new CRMServiceHandler();
|
| 3428 |
rajveer |
40 |
processor = new Processor<Iface>(handler);
|
| 3024 |
mandeep.dh |
41 |
int port = 9014;
|
|
|
42 |
try {
|
|
|
43 |
String portNo = ConfigClient.getClient().get(
|
|
|
44 |
ConfigClientKeys.crm_service_server_port
|
|
|
45 |
.toString());
|
|
|
46 |
port = Integer.parseInt(portNo);
|
|
|
47 |
} catch (Exception e) {
|
|
|
48 |
logger.warn(
|
|
|
49 |
"Unable to get port number from the Config server because of:",
|
|
|
50 |
e);
|
|
|
51 |
}
|
|
|
52 |
|
|
|
53 |
TServerTransport serverTransport = new TServerSocket(port);
|
|
|
54 |
TTransportFactory tFactory = new TFramedTransport.Factory();
|
|
|
55 |
TProtocolFactory pFactory = new TBinaryProtocol.Factory();
|
| 3428 |
rajveer |
56 |
|
|
|
57 |
Args serverParams = new Args(serverTransport);
|
|
|
58 |
serverParams.processor(processor);
|
|
|
59 |
serverParams.transportFactory(tFactory);
|
|
|
60 |
serverParams.protocolFactory(pFactory);
|
|
|
61 |
|
|
|
62 |
TServer server = new TThreadPoolServer(serverParams);
|
| 3024 |
mandeep.dh |
63 |
|
|
|
64 |
logger.info("CRM service started on port 9014");
|
|
|
65 |
server.serve();
|
|
|
66 |
} catch (Exception ex) {
|
|
|
67 |
ex.printStackTrace();
|
|
|
68 |
}
|
|
|
69 |
}
|
|
|
70 |
}
|