maxjiang153 / Thrift-Connection-Pool

Apache Thrift客户端连接池(client connection pool)
Apache License 2.0
54 stars 39 forks source link

异常:org.apache.thrift.TApplicationException: Invalid method name #12

Open tqknight1984 opened 8 years ago

tqknight1984 commented 8 years ago

我通过单服务正常的: ThriftConnectionPoolConfig config = new ThriftConnectionPoolConfig(); config.setConnectTimeout(3000); config.setThriftProtocol(ThriftConnectionPoolConfig.TProtocolType.BINARY); config.setClientClass(User.Client.class); config.addThriftServer("127.0.0.1", 9818); config.setMaxConnectionPerServer(1); config.setMinConnectionPerServer(1); config.setIdleMaxAge(2, TimeUnit.SECONDS); config.setMaxConnectionAge(2); config.setLazyInit(false); try { ThriftConnectionPool pool = new ThriftConnectionPool(config);

        ThriftConnection<User.Client> tConnection = pool.getConnection();
        User.Client client = tConnection.getClient();

        //client.ping();

        int res = client.regedit_p("tqz001", "tqz001", "15026691001", "1231");
        tConnection.close();
       pool.close();

... ...

但是通过多接口服务,

ThriftConnectionPoolConfig config = new ThriftConnectionPoolConfig(ThriftConnectionPoolConfig.ThriftServiceType.MULTIPLEXED_INTERFACE); config.setConnectTimeout(3000); config.setThriftProtocol(ThriftConnectionPoolConfig.TProtocolType.BINARY); config.addThriftServer("127.0.0.1", 9818); config.addThriftClientClass("user", User.Client.class); //config.addThriftClientClass("example", Example.Client.class);

        config.setMaxConnectionPerServer(2);
        config.setMinConnectionPerServer(1);
        config.setIdleMaxAge(2, TimeUnit.SECONDS);
        config.setMaxConnectionAge(2);
        config.setLazyInit(false);
        config.setAcquireIncrement(2);
        config.setAcquireRetryDelay(2000);

        config.setAcquireRetryAttempts(1);
        config.setMaxConnectionCreateFailedCount(1);
        config.setConnectionTimeoutInMs(5000);

        config.check();

        ThriftConnectionPool<TServiceClient> pool = new ThriftConnectionPool<TServiceClient>(config);
        ThriftConnection<TServiceClient> connection = pool.getConnection();

// example service User.Client userClient = connection.getClient("user", User.Client.class); // userClient.ping();

        int res = userClient.regedit_p("tqz001", "tqz001", "15026691001", "1231");
        connection.close();

.......

报错,如下:

log4j:WARN No such property [maxBackupIndex] in org.apache.log4j.DailyRollingFileAppender. 2016-09-08 16:52:46 INFO ThriftConnectionPoolConfig:423 - 注册服务客户端:user 2016-09-08 16:52:46 INFO ThriftConnectionPoolConfig:423 - 注册服务客户端:user 2016-09-08 16:52:46 DEBUG MulitServiceThriftConnecion:116 - 创建新连接成功:127.0.0.1 端口:9818 2016-09-08 16:52:46 DEBUG MulitServiceThriftConnecion:116 - 创建新连接成功:127.0.0.1 端口:9818 2016-09-08 16:52:51 DEBUG MulitServiceThriftConnecion:116 - 创建新连接成功:127.0.0.1 端口:9818 org.apache.thrift.TApplicationException: Invalid method name: 'user:regedit_p' at org.apache.thrift.TApplicationException.read(TApplicationException.java:111) at org.apache.thrift.TServiceClient.receiveBase(TServiceClient.java:79) at net.gx.thrift.User$Client.recv_regedit_p(User.java:141) at net.gx.thrift.User$Client.regedit_p(User.java:125)

编译环境,intellij IDEA 2016.2.3;jdk1.8

tqknight1984 commented 8 years ago

在线等!!

maxjiang153 commented 8 years ago

@tqknight1984 thrift版本是多少呢? 我暂时没有在jdk1.8中测试过 我公司内的jdk环境为1.7

tqknight1984 commented 8 years ago
 <!-- rpc https://mvnrepository.com/artifact/org.apache.thrift/libthrift -->
    <dependency>
        <groupId>org.apache.thrift</groupId>
        <artifactId>libthrift</artifactId>
        <version>0.9.3</version>
    </dependency>