修改:rpc 调用端订阅 topic 逻辑修改
This commit is contained in:
@@ -26,11 +26,11 @@ public class AppTest {
|
||||
//启动并开启消费监听
|
||||
MyConsumer consumer = Application.singleton(MyConsumer.class);
|
||||
|
||||
/*consumer.subscribe("a", str -> {
|
||||
consumer.subscribe("a", str -> {
|
||||
logger.info("我收到了消息 a 事件:" + str);
|
||||
});
|
||||
|
||||
consumer.timer("a", () -> {
|
||||
/*consumer.timer("a", () -> {
|
||||
System.out.println(Utility.now() + " timer a 执行了");
|
||||
try {
|
||||
Thread.sleep(3000);
|
||||
|
37
test/com/zdemo/test/HelloService.java
Normal file
37
test/com/zdemo/test/HelloService.java
Normal file
@@ -0,0 +1,37 @@
|
||||
package com.zdemo.test;
|
||||
|
||||
import com.zdemo.IConsumer;
|
||||
import com.zdemo.zhub.RpcResult;
|
||||
import com.zdemo.zhub.ZHubClient;
|
||||
import org.redkale.net.http.RestService;
|
||||
import org.redkale.service.Service;
|
||||
import org.redkale.util.AnyValue;
|
||||
import org.redkale.util.TypeToken;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@RestService(automapping = true)
|
||||
public class HelloService implements Service {
|
||||
|
||||
@Resource(name = "zhub")
|
||||
private ZHubClient zhub;
|
||||
|
||||
@Override
|
||||
public void init(AnyValue config) {
|
||||
// Function<Rpc<T>, RpcResult<R>> fun
|
||||
zhub.rpcSubscribe("x", new TypeToken<String>() {
|
||||
}, r -> {
|
||||
|
||||
return r.buildResp(r.getValue().toUpperCase() + ": Ok");
|
||||
});
|
||||
}
|
||||
|
||||
public RpcResult<String> x(String v) {
|
||||
if (v == null) {
|
||||
v = "";
|
||||
}
|
||||
RpcResult<String> x = zhub.rpc("x", v, IConsumer.TYPE_TOKEN_STRING).join();
|
||||
|
||||
return x;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user