Search in sources :

Example 1 with EventMeshTCPClientConfig

use of org.apache.eventmesh.client.tcp.conf.EventMeshTCPClientConfig in project incubator-eventmesh by apache.

the class AsyncPublish method main.

public static void main(String[] args) throws Exception {
    Properties properties = Utils.readPropertiesFile(ExampleConstants.CONFIG_FILE_NAME);
    final String eventMeshIp = properties.getProperty(ExampleConstants.EVENTMESH_IP);
    final int eventMeshTcpPort = Integer.parseInt(properties.getProperty(ExampleConstants.EVENTMESH_TCP_PORT));
    try {
        UserAgent userAgent = EventMeshTestUtils.generateClient1();
        EventMeshTCPClientConfig eventMeshTcpClientConfig = EventMeshTCPClientConfig.builder().host(eventMeshIp).port(eventMeshTcpPort).userAgent(userAgent).build();
        client = EventMeshTCPClientFactory.createEventMeshTCPClient(eventMeshTcpClientConfig, EventMeshMessage.class);
        client.init();
        for (int i = 0; i < 5; i++) {
            EventMeshMessage eventMeshMessage = EventMeshTestUtils.generateAsyncEventMqMsg();
            logger.info("begin send async msg[{}]: {}", i, eventMeshMessage);
            client.publish(eventMeshMessage, EventMeshCommon.DEFAULT_TIME_OUT_MILLS);
            Thread.sleep(1000);
        }
        Thread.sleep(2000);
    } catch (Exception e) {
        logger.warn("AsyncPublish failed", e);
    }
}
Also used : EventMeshTCPClientConfig(org.apache.eventmesh.client.tcp.conf.EventMeshTCPClientConfig) UserAgent(org.apache.eventmesh.common.protocol.tcp.UserAgent) Properties(java.util.Properties) EventMeshMessage(org.apache.eventmesh.common.protocol.tcp.EventMeshMessage)

Example 2 with EventMeshTCPClientConfig

use of org.apache.eventmesh.client.tcp.conf.EventMeshTCPClientConfig in project incubator-eventmesh by apache.

the class SyncRequest method main.

public static void main(String[] args) throws Exception {
    Properties properties = Utils.readPropertiesFile(ExampleConstants.CONFIG_FILE_NAME);
    final String eventMeshIp = properties.getProperty(ExampleConstants.EVENTMESH_IP);
    final int eventMeshTcpPort = Integer.parseInt(properties.getProperty(ExampleConstants.EVENTMESH_TCP_PORT));
    UserAgent userAgent = EventMeshTestUtils.generateClient1();
    EventMeshTCPClientConfig eventMeshTcpClientConfig = EventMeshTCPClientConfig.builder().host(eventMeshIp).port(eventMeshTcpPort).userAgent(userAgent).build();
    try {
        client = EventMeshTCPClientFactory.createEventMeshTCPClient(eventMeshTcpClientConfig, EventMeshMessage.class);
        client.init();
        EventMeshMessage eventMeshMessage = EventMeshTestUtils.generateSyncRRMqMsg();
        log.info("begin send rr msg: {}", eventMeshMessage);
        Package response = client.rr(eventMeshMessage, EventMeshCommon.DEFAULT_TIME_OUT_MILLS);
        log.info("receive rr reply: {}", response);
    } catch (Exception e) {
        log.warn("SyncRequest failed", e);
    }
}
Also used : EventMeshTCPClientConfig(org.apache.eventmesh.client.tcp.conf.EventMeshTCPClientConfig) UserAgent(org.apache.eventmesh.common.protocol.tcp.UserAgent) Package(org.apache.eventmesh.common.protocol.tcp.Package) Properties(java.util.Properties) EventMeshMessage(org.apache.eventmesh.common.protocol.tcp.EventMeshMessage)

Example 3 with EventMeshTCPClientConfig

use of org.apache.eventmesh.client.tcp.conf.EventMeshTCPClientConfig in project incubator-eventmesh by apache.

the class SyncResponse method main.

public static void main(String[] args) throws Exception {
    Properties properties = Utils.readPropertiesFile(ExampleConstants.CONFIG_FILE_NAME);
    final String eventMeshIp = properties.getProperty(ExampleConstants.EVENTMESH_IP);
    final int eventMeshTcpPort = Integer.parseInt(properties.getProperty(ExampleConstants.EVENTMESH_TCP_PORT));
    UserAgent userAgent = EventMeshTestUtils.generateClient2();
    EventMeshTCPClientConfig eventMeshTcpClientConfig = EventMeshTCPClientConfig.builder().host(eventMeshIp).port(eventMeshTcpPort).userAgent(userAgent).build();
    try {
        client = EventMeshTCPClientFactory.createEventMeshTCPClient(eventMeshTcpClientConfig, CloudEvent.class);
        client.init();
        client.subscribe(ExampleConstants.EVENTMESH_TCP_SYNC_TEST_TOPIC, SubscriptionMode.CLUSTERING, SubscriptionType.SYNC);
        // Synchronize RR messages
        client.registerSubBusiHandler(handler);
        client.listen();
    } catch (Exception e) {
        log.warn("SyncResponse failed", e);
    }
}
Also used : EventMeshTCPClientConfig(org.apache.eventmesh.client.tcp.conf.EventMeshTCPClientConfig) UserAgent(org.apache.eventmesh.common.protocol.tcp.UserAgent) Properties(java.util.Properties) CloudEvent(io.cloudevents.CloudEvent)

Example 4 with EventMeshTCPClientConfig

use of org.apache.eventmesh.client.tcp.conf.EventMeshTCPClientConfig in project incubator-eventmesh by apache.

the class SyncResponse method main.

public static void main(String[] args) throws Exception {
    Properties properties = Utils.readPropertiesFile(ExampleConstants.CONFIG_FILE_NAME);
    final String eventMeshIp = properties.getProperty(ExampleConstants.EVENTMESH_IP);
    final int eventMeshTcpPort = Integer.parseInt(properties.getProperty(ExampleConstants.EVENTMESH_TCP_PORT));
    UserAgent userAgent = EventMeshTestUtils.generateClient2();
    EventMeshTCPClientConfig eventMeshTcpClientConfig = EventMeshTCPClientConfig.builder().host(eventMeshIp).port(eventMeshTcpPort).userAgent(userAgent).build();
    try {
        client = EventMeshTCPClientFactory.createEventMeshTCPClient(eventMeshTcpClientConfig, EventMeshMessage.class);
        client.init();
        client.subscribe(ExampleConstants.EVENTMESH_TCP_SYNC_TEST_TOPIC, SubscriptionMode.CLUSTERING, SubscriptionType.SYNC);
        // Synchronize RR messages
        client.registerSubBusiHandler(handler);
        client.listen();
    } catch (Exception e) {
        log.warn("SyncResponse failed", e);
    }
}
Also used : EventMeshTCPClientConfig(org.apache.eventmesh.client.tcp.conf.EventMeshTCPClientConfig) UserAgent(org.apache.eventmesh.common.protocol.tcp.UserAgent) Properties(java.util.Properties) EventMeshMessage(org.apache.eventmesh.common.protocol.tcp.EventMeshMessage)

Example 5 with EventMeshTCPClientConfig

use of org.apache.eventmesh.client.tcp.conf.EventMeshTCPClientConfig in project incubator-eventmesh by apache.

the class EventMeshTCPClientFactoryTest method createEventMeshTCPClient.

@Test
public void createEventMeshTCPClient() {
    EventMeshTCPClientConfig meshTCPClientConfig = EventMeshTCPClientConfig.builder().host("localhost").port(1234).build();
    EventMeshTCPClient<EventMeshMessage> eventMeshMessageTCPClient = EventMeshTCPClientFactory.createEventMeshTCPClient(meshTCPClientConfig, EventMeshMessage.class);
    Assert.assertEquals(EventMeshMessageTCPClient.class, eventMeshMessageTCPClient.getClass());
    EventMeshTCPClient<CloudEvent> cloudEventTCPClient = EventMeshTCPClientFactory.createEventMeshTCPClient(meshTCPClientConfig, CloudEvent.class);
    Assert.assertEquals(CloudEventTCPClient.class, cloudEventTCPClient.getClass());
    EventMeshTCPClient<Message> openMessageTCPClient = EventMeshTCPClientFactory.createEventMeshTCPClient(meshTCPClientConfig, Message.class);
    Assert.assertEquals(OpenMessageTCPClient.class, openMessageTCPClient.getClass());
}
Also used : EventMeshTCPClientConfig(org.apache.eventmesh.client.tcp.conf.EventMeshTCPClientConfig) Message(io.openmessaging.api.Message) EventMeshMessage(org.apache.eventmesh.common.protocol.tcp.EventMeshMessage) CloudEvent(io.cloudevents.CloudEvent) EventMeshMessage(org.apache.eventmesh.common.protocol.tcp.EventMeshMessage) Test(org.junit.Test)

Aggregations

EventMeshTCPClientConfig (org.apache.eventmesh.client.tcp.conf.EventMeshTCPClientConfig)11 Properties (java.util.Properties)10 UserAgent (org.apache.eventmesh.common.protocol.tcp.UserAgent)10 EventMeshMessage (org.apache.eventmesh.common.protocol.tcp.EventMeshMessage)7 CloudEvent (io.cloudevents.CloudEvent)5 Package (org.apache.eventmesh.common.protocol.tcp.Package)2 Message (io.openmessaging.api.Message)1 Test (org.junit.Test)1