如何从php调用drpc风暴?

zwghvu4y  于 2021-06-24  发布在  Storm
关注(0)|答案(1)|浏览(251)

考虑storm drpc拓扑,如下所示:

public static void main(String[] args) {
    LinearDRPCTopologyBuilder builder = new LinearDRPCTopologyBuilder("exclamation");  
    builder.addBolt(new ExclamationBolt()); 
    Config conf = new Config();  
    try {
        StormSubmitter.submitTopology("exclaim", conf, builder.createRemoteTopology());
    } catch (AlreadyAliveException e) { 
        e.printStackTrace();
    } catch (InvalidTopologyException e) { 
        e.printStackTrace();
    } 
}

测试 LocalClusterdrpc.execute("exclamation", "aaa") ,它起作用了。但问题是如何从php远程调用?
更新:我安装了thrift并通过运行 thrift --gen php storm.thrift &有一个包含一堆php类的gen php目录。
有人能举个例子或链接来说明实现吗?

eaf3rand

eaf3rand1#

我们只需要在生成的类文件之上编写一个抽象层,就像java客户机一样。
您可以通过以下方式生成drpc类文件:

thrift --gen php storm.thrift

你必须在你的代码中使用php节俭库。
我已将工作代码放在下面的repo中:
https://github.com/mithunsatheesh/php-drpc

相关问题