From ac4036d979f2c7711b4b6349baf6ba5c1b16edff Mon Sep 17 00:00:00 2001 From: gaojie Date: Tue, 21 May 2019 13:38:29 +0800 Subject: [PATCH] rpc --- src/main/java/com/jmfy/Application.java | 4 +++- .../java/com/jmfy/controller/RechargeController.java | 12 +++++++++--- .../java/com/jmfy/controller/SendMailController.java | 8 +++++++- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/jmfy/Application.java b/src/main/java/com/jmfy/Application.java index 89b6741..7d65b19 100644 --- a/src/main/java/com/jmfy/Application.java +++ b/src/main/java/com/jmfy/Application.java @@ -17,6 +17,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration; import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration; import org.springframework.context.ConfigurableApplicationContext; +import ch.qos.logback.classic.spi.ThrowableProxy; @SpringBootApplication(exclude = {MongoAutoConfiguration.class,MongoDataAutoConfiguration.class}) public class Application { @@ -25,7 +26,8 @@ public class Application { public static void main(String[] args) throws Exception { ConfigurableApplicationContext configurableApplicationContext = SpringApplication.run(Application.class, args); - + String name = ThrowableProxy.class.getName(); + LOGGER.info("ThrowableProxy is name ={}",name); //初使化连接池util类 ThriftPoolUtils.getInstance().initContext(configurableApplicationContext); ServerConfiguration serverConfiguration = configurableApplicationContext.getBean(ServerConfiguration.class); diff --git a/src/main/java/com/jmfy/controller/RechargeController.java b/src/main/java/com/jmfy/controller/RechargeController.java index 07eea2e..1f6153c 100644 --- a/src/main/java/com/jmfy/controller/RechargeController.java +++ b/src/main/java/com/jmfy/controller/RechargeController.java @@ -86,20 +86,26 @@ public class RechargeController { cPayOrder.setCreditId(creditId); Result result = null; String userAddress = cuserDao.findUserInfo(Integer.parseInt(serverCode), Integer.parseInt(creditId)); - LOGGER.info("callback==>userAddress={} ",userAddress); if (userAddress != null) { + LOGGER.info("callback==>userAddress={} ",userAddress); String[] split = userAddress.split(":"); String ip = split[0]; String port = split[1]; LOGGER.info("RPC address --> IP : " + ip + "; PORT : " + port); - ClientAdapterPo rPCClient; + ClientAdapterPo rPCClient = null; String serviceKey = JsonUtil.getServiceKey(ServiceKey.RPCCore, ip, port); LOGGER.info("serviceKey : " + serviceKey); try { rPCClient = ClientAdapterPo.getClientAdapterPo(serviceKey); result = rPCClient.getClient().deliveryRecharge(Integer.parseInt(creditId),stone,productId, amount,activityExtra,isOfficial,plat,payType,pOrderId); } catch (Exception e) { - e.printStackTrace(); + LOGGER.info("callback=>",e); + }finally { + if (rPCClient != null){ + rPCClient.returnObject(serviceKey); + }else{ + LOGGER.info("callback=> rPCClient is null "); + } } } if (result != null && result.getResultCode() == 0) { diff --git a/src/main/java/com/jmfy/controller/SendMailController.java b/src/main/java/com/jmfy/controller/SendMailController.java index 6b2958e..80c575a 100644 --- a/src/main/java/com/jmfy/controller/SendMailController.java +++ b/src/main/java/com/jmfy/controller/SendMailController.java @@ -69,7 +69,7 @@ public class SendMailController { String ip = split[0]; String port = split[1]; LOGGER.info("efun_reward ==>RPC address --> IP : "+ ip + "; PORT : "+ port); - ClientAdapterPo rPCClient; + ClientAdapterPo rPCClient = null; String serviceKey = JsonUtil.getServiceKey(ServiceKey.RPCCore,ip,port); LOGGER.info("serviceKey : "+ serviceKey); try { @@ -78,6 +78,12 @@ public class SendMailController { cuserDao.addMailSeriaNo(serialNo); } catch (Exception e) { e.printStackTrace(); + }finally { + if (rPCClient != null){ + rPCClient.returnObject(serviceKey); + }else{ + LOGGER.info("callback=> rPCClient is null "); + } } } ResultVo resultVo;