Search in sources :

Example 1 with PubClientImpl

use of org.apache.eventmesh.runtime.client.impl.PubClientImpl in project incubator-eventmesh by apache.

the class BroadCastPubClient method main.

public static void main(String[] args) throws Exception {
    PubClientImpl pubClient = new PubClientImpl("127.0.0.1", 10000, UserAgentUtils.createUserAgent());
    pubClient.init();
    pubClient.heartbeat();
    for (int i = 0; i < 10000; i++) {
        ThreadUtils.randomSleep(0, 500);
        pubClient.broadcast(MessageUtils.broadcastMessage(ClientConstants.BROADCAST_TOPIC, i), 5000);
    }
}
Also used : PubClientImpl(org.apache.eventmesh.runtime.client.impl.PubClientImpl)

Example 2 with PubClientImpl

use of org.apache.eventmesh.runtime.client.impl.PubClientImpl in project incubator-eventmesh by apache.

the class AsyncPubClient method main.

public static void main(String[] args) throws Exception {
    PubClientImpl pubClient = new PubClientImpl("127.0.0.1", 10000, UserAgentUtils.createUserAgent());
    pubClient.init();
    pubClient.heartbeat();
    pubClient.registerBusiHandler(new ReceiveMsgHook() {

        @Override
        public void handle(Package msg, ChannelHandlerContext ctx) {
            logger.error("receive msg-----------------------------" + msg.toString());
        }
    });
    for (int i = 0; i < 1; i++) {
        ThreadUtils.randomSleep(0, 500);
        pubClient.broadcast(MessageUtils.asyncMessage(ClientConstants.ASYNC_TOPIC, i), 5000);
    }
}
Also used : ReceiveMsgHook(org.apache.eventmesh.runtime.client.hook.ReceiveMsgHook) PubClientImpl(org.apache.eventmesh.runtime.client.impl.PubClientImpl) ChannelHandlerContext(io.netty.channel.ChannelHandlerContext) Package(org.apache.eventmesh.common.protocol.tcp.Package)

Example 3 with PubClientImpl

use of org.apache.eventmesh.runtime.client.impl.PubClientImpl in project incubator-eventmesh by apache.

the class CCPubClient method main.

public static void main(String[] args) throws Exception {
    PubClientImpl pubClient = new PubClientImpl("127.0.0.1", 10000, UserAgentUtils.createUserAgent());
    pubClient.init();
    pubClient.heartbeat();
    pubClient.broadcast(MessageUtils.rrMesssage(ClientConstants.ASYNC_TOPIC, 0), 5000);
}
Also used : PubClientImpl(org.apache.eventmesh.runtime.client.impl.PubClientImpl)

Example 4 with PubClientImpl

use of org.apache.eventmesh.runtime.client.impl.PubClientImpl in project incubator-eventmesh by apache.

the class SyncPubClient method main.

public static void main(String[] args) throws Exception {
    PubClientImpl pubClient = new PubClientImpl("127.0.0.1", 10000, UserAgentUtils.createUserAgent());
    pubClient.init();
    pubClient.heartbeat();
    for (int i = 0; i < 100; i++) {
        Package rr = pubClient.rr(MessageUtils.rrMesssage("TEST-TOPIC-TCP-SYNC", i), 3000);
        if (rr.getBody() instanceof EventMeshMessage) {
            String body = ((EventMeshMessage) rr.getBody()).getBody();
            logger.error("rrMessage: " + body + "             " + "rr-reply-------------------------------------------------" + rr);
        }
    }
}
Also used : PubClientImpl(org.apache.eventmesh.runtime.client.impl.PubClientImpl) Package(org.apache.eventmesh.common.protocol.tcp.Package) EventMeshMessage(org.apache.eventmesh.common.protocol.tcp.EventMeshMessage)

Aggregations

PubClientImpl (org.apache.eventmesh.runtime.client.impl.PubClientImpl)4 Package (org.apache.eventmesh.common.protocol.tcp.Package)2 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)1 EventMeshMessage (org.apache.eventmesh.common.protocol.tcp.EventMeshMessage)1 ReceiveMsgHook (org.apache.eventmesh.runtime.client.hook.ReceiveMsgHook)1