Skip to content

Commit 024ade9

Browse files
committed
Added "Controlling event deserialization" section to the readme.md
1 parent 3196dc5 commit 024ade9

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

readme.md

+25-1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,29 @@ client.connect();
8383
> By default, BinaryLogClient starts from the current (at the time of connect) master binlog position. If you wish to
8484
kick off from a specific filename or position, use client.setBinlogFilename(...) + client.setBinlogPosition(...).
8585

86+
### Controlling event deserialization
87+
88+
```java
89+
EventDeserializer eventDeserializer = new EventDeserializer();
90+
91+
// do not deserialize EXT_DELETE_ROWS event data, return it as a byte array
92+
eventDeserializer.setEventDataDeserializer(EventType.EXT_DELETE_ROWS,
93+
new ByteArrayEventDataDeserializer());
94+
95+
// skip EXT_WRITE_ROWS event data altogether
96+
eventDeserializer.setEventDataDeserializer(EventType.EXT_WRITE_ROWS,
97+
new NullEventDataDeserializer());
98+
99+
// use custom event data deserializer for EXT_DELETE_ROWS
100+
eventDeserializer.setEventDataDeserializer(EventType.EXT_DELETE_ROWS,
101+
new EventDataDeserializer() {
102+
...
103+
});
104+
105+
BinaryLogClient client = ...
106+
client.setEventDeserializer(eventDeserializer);
107+
```
108+
86109
### Making client available through JMX
87110

88111
```java
@@ -92,7 +115,8 @@ BinaryLogClient binaryLogClient = ...
92115
ObjectName objectName = new ObjectName("mysql.binlog:type=BinaryLogClient");
93116
mBeanServer.registerMBean(binaryLogClient, objectName);
94117

95-
// following bean accumulates various BinaryLogClient stats (e.g. number of disconnects, skipped events)
118+
// following bean accumulates various BinaryLogClient stats
119+
// (e.g. number of disconnects, skipped events)
96120
BinaryLogClientStatistics stats = new BinaryLogClientStatistics(binaryLogClient);
97121
ObjectName statsObjectName = new ObjectName("mysql.binlog:type=BinaryLogClientStatistics");
98122
mBeanServer.registerMBean(stats, statsObjectName);

0 commit comments

Comments
 (0)