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);
}
}
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);
}
}
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);
}
}
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);
}
}
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());
}
Aggregations