ARTS打卡计划第二周-Tips-mysql-binlog-connector-java的使用
最近发现一个挺不错的框架mysql-binlog-connector-java,可以实时监控binlog的变化。
首先检查mysql的binlog是否开启,在开启的情况下:
引入依赖
- <dependency>
- <groupId>com.github.shyiko</groupId>
- <artifactId>mysql-binlog-connector-java</artifactId>
- <version>0.18.1</version>
- </dependency>
然后使用如下代码可以测试:
- public class App
- {
- public static void main( String[] args ) throws IOException
- {
- BinaryLogClient client = new BinaryLogClient("xxx", 3306, "xxx", "xxx");
- EventDeserializer eventDeserializer = new EventDeserializer();
- eventDeserializer.setCompatibilityMode(
- EventDeserializer.CompatibilityMode.DATE_AND_TIME_AS_LONG,
- EventDeserializer.CompatibilityMode.CHAR_AND_BINARY_AS_BYTE_ARRAY
- );
- client.setEventDeserializer(eventDeserializer);
- client.registerEventListener(new EventListener() {
- @Override
- public void onEvent(Event event) {
- System.out.println(event);
- EventData data = event.getData();
- if (data instanceof UpdateRowsEventData) {
- System.out.println("Update--------------");
- System.out.println(data.toString());
- } else if (data instanceof WriteRowsEventData) {
- System.out.println("Write---------------");
- System.out.println(data.toString());
- } else if (data instanceof DeleteRowsEventData) {
- System.out.println("Delete--------------");
- System.out.println(data.toString());
- }
- }
- });
- client.connect();
- }
- }
- 实际在使用的时候,这个框架提供列名称表名称不太好用,这个时候需要https://github.com/ngocdaothanh/mydit ,这个是一个将mysql同步到mongdb的,其中一些样例代码可以很方便的获取mysql的元数据。
ARTS打卡计划第二周-Tips-mysql-binlog-connector-java的使用的更多相关文章
- ARTS打卡计划第二周-Review
本周review的文章是:https://medium.com/@hakibenita/optimizing-django-admin-paginator-53c4eb6bfca3 改篇文章的题目是: ...
- ARTS打卡计划第二周
Algorithms: https://leetcode-cn.com/problems/3sum/ 算法是先排序,然后按照两个数和两边逼中,考虑去重. Review: https://www.inf ...
- ARTS打卡计划第二周-Share-使用java注解对方法计时
现在有这样一种常见,系统中有一个接口,该接口执行的方法忽快忽慢,因此你需要去统计改方法的执行时间.刚开始你的代码可能如下: long start = System.currentTimeMillis( ...
- ARTS打卡计划第二周-Algorithm
665. 非递减数列 https://leetcode-cn.com/problems/non-decreasing-array/ 给定一个长度为 n 的整数数组,你的任务是判断在最多改变 1 个元 ...
- ARTS打卡计划第九周
Algorithms: https://leetcode-cn.com/problems/merge-two-sorted-lists/submissions/ 合并两个链表 Review: “Pu ...
- ARTS打卡计划第一周
Algorithms: https://leetcode-cn.com/problems/two-sum/ Review: https://www.infoq.cn/article/EafgGJEtq ...
- ARTS打卡计划第一周-Share-系统字典模块的设计
在软件开发的过程,经常有一些类型的字段信息:性别.学历.职级.车辆类别.公司类型.结算类型等.这些字段有2个特征:1是字段可选的类型是有限,2是字段可能会变化,我们把这种字段描述为字段字段. 本篇文 ...
- ARTS打卡计划第一周-Tips-ControllerAdvice的使用
通常在开发具体项目过程中我们可能会面临如下问题: 统一所有的json返回结果 统一处理所有controller中的异常,并且给不同异常不同的返回状态值 统一对返回的接口做数据校验或者加密,防止篡改 在 ...
- ARTS打卡计划第一周-Review
本周分享的文章来自于medium的 Testing Best Practices for Java + Spring Apps 这个文章主要讲的是java测试的一些最佳实践 1.避免函数返回void, ...
随机推荐
- 一位工作8年的java软件工程师该如何发展
从08年到现在已工作8年多了,但是对职业生涯的规划还没有很清晰的定义,可能之前做的工作太杂太广,回想第一家公司从事了6年有得也有失,虽然涉及到开发.设计.管理等岗位,但从技术上总结并没有很擅长的技术, ...
- tensorboard OSError:[Errno 22] Invalid argument
哈哈 问题解决了.感谢大佬 Bill.Z 附上原文链接:https://blog.csdn.net/u013244846/article/details/88380860 解决方法:更改manager ...
- Java annotation浅析
自定义annotation @Documented@Retention(RetentionPolicy.RUNTIME)@Target({ElementType.FIELD,ElementType.M ...
- pdf.js的使用
下载地址: files.cnblogs.com/zycjwdss/mypdf.zip 把下载后的zip解压,放到web服务器根目录下,打开pdf.html,把这一句取消注释: //window.pd ...
- Some elementary algorithms on discrete differential geometry(DDGSpring2016 Demos)
I studied the on-line course(http://brickisland.net/DDGSpring2016/) by myself, and here are the scre ...
- Python——PyQt GUI编程(python programming)
import sys from math import * from PyQt5.QtCore import * from PyQt5.QtGui import * from PyQt5.QtWidg ...
- Ubuntu下安装Snap
介绍 Snap是一个全新的软件包架构,它与其它包管理器的区别在于snap安装的app互相之间是高度隔离的,减少了互相引用. 避免了很多冲突问题. 不过这也导致了其占用的磁盘比较多. 安装 apt in ...
- 织梦dede文章列表调用标签的用法和规则
织梦dede列表标签在任何模板的网站中都可能会使用到,而且我们在仿站的时候也经常要使用到列表标签.这里主机吧就给大家讲一下文章列表以及图片列表.软件列表以及分类信息列表标签的用法,和结合div+css ...
- .net core下载文件
上传的文件是在wwwroot下 通过保存的路径跟文件名称完成下载 public IActionResult DownloadFile() { var filePath = "/Upload ...
- Bootstrap关闭子类页面,刷新父类页面
关闭子类页面,刷新父类页面 function doBack() { var index = parent.layer.getFrameIndex(window.name) //获取窗口索引值 pare ...