Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature request] expose methods for handling raw event data. #28

Closed
thomasdziedzic opened this issue Jan 27, 2015 · 3 comments
Closed

Comments

@thomasdziedzic
Copy link

I would like to publish the raw event data, and then parse the event data on the subscribers to let them handle the events themselves.

@shyiko
Copy link
Owner

shyiko commented Jan 27, 2015

This should do the trick:

BinaryLogClient client = ...
EventDeserializer eventDeserializer = new EventDeserializer(
    new EventHeaderV4Deserializer(),
    new ByteArrayEventDataDeserializer(),
    new HashMap<EventType, EventDataDeserializer>() {{
        // TABLE_MAP and ROTATE events are used internally by EventDeserializer/BinaryLogClient
        put(EventType.TABLE_MAP, new TableMapEventDataDeserializer());
        put(EventType.ROTATE, new RotateEventDataDeserializer());
    }},
    new HashMap<Long, TableMapEventData>()
);
client.setEventDeserializer(eventDeserializer);

Alternatively, you can explicitly specify type of events that should skip payload deserialization. Like so:

    BinaryLogClient client = ...
    EventDeserializer eventDeserializer = new EventDeserializer();
    eventDeserializer.setEventDataDeserializer(EventType.EXT_WRITE_ROWS, 
new ByteArrayEventDataDeserializer());
    eventDeserializer.setEventDataDeserializer(EventType.EXT_UPDATE_ROWS, 
new ByteArrayEventDataDeserializer());
    eventDeserializer.setEventDataDeserializer(EventType.EXT_DELETE_ROWS, 
new ByteArrayEventDataDeserializer());
    client.setEventDeserializer(eventDeserializer);

Let me know if that's enough.

@thomasdziedzic
Copy link
Author

This looks great, is there any way this can be documented somewhere?

I can see a lot of people using this if they want to setup a pub-sub with the binlog data.

@shyiko
Copy link
Owner

shyiko commented Jan 27, 2015

Added a few examples in 024ade9.

@shyiko shyiko closed this as completed Jan 27, 2015
jpechane pushed a commit to jpechane/mysql-binlog-connector-java that referenced this issue Feb 18, 2021
Replace tls hostname verifier, upgrade to JDK 11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants