Search in sources :

Example 1 with CanalMessageHandler

use of com.example.canal.CanalMessageHandler in project java-example by 1479005017.

the class CanalTest2 method test.

@Test
public void test() {
    CanalProperties properties = new CanalProperties();
    SocketAddress address = new InetSocketAddress(properties.getHost(), properties.getPort());
    CanalConnector connector = CanalConnectors.newSingleConnector(address, properties.getDestination(), properties.getUsername(), properties.getPassword());
    UserEntryProcessor userEntryProcessor = new UserEntryProcessor();
    CanalMessageHandler handler = new CanalMessageHandler();
    handler.setProperties(properties);
    handler.setConnector(connector);
    handler.addEntryProcessor(userEntryProcessor);
    handler.start();
    while (Thread.activeCount() > 1) Thread.yield();
}
Also used : CanalProperties(com.example.canal.CanalProperties) InetSocketAddress(java.net.InetSocketAddress) CanalConnector(com.alibaba.otter.canal.client.CanalConnector) CanalMessageHandler(com.example.canal.CanalMessageHandler) UserEntryProcessor(com.example.canal.processor.UserEntryProcessor) SocketAddress(java.net.SocketAddress) InetSocketAddress(java.net.InetSocketAddress) Test(org.junit.Test)

Aggregations

CanalConnector (com.alibaba.otter.canal.client.CanalConnector)1 CanalMessageHandler (com.example.canal.CanalMessageHandler)1 CanalProperties (com.example.canal.CanalProperties)1 UserEntryProcessor (com.example.canal.processor.UserEntryProcessor)1 InetSocketAddress (java.net.InetSocketAddress)1 SocketAddress (java.net.SocketAddress)1 Test (org.junit.Test)1