Maxwell在同步mysql blob到kafka时候,会用Base64进行加密。也就是说在kafka拿到数据时,blob字段的内容和源库中的数据是不一样的。Maxwell会对blob字段进行Base64加密。所以我们需要在入到存储上的时候进行base64的decode。具体方法如下:
import java.util.Base64
public void base64() throws Exception {
final Base64.Decoder decoder = Base64.getDecoder();
final Base64.Encoder encoder = Base64.getEncoder();
final String text ="测试";
final byte[] textByte = text.getBytes("UTF-8");
final String encodedText = encoder.encodeToString(textByte);
##decode##################################################
###new String(decoder.decode(encodeText), "UTF-8"));##############
}
写好这个function, 在使用talend tmap组件时调用这个function,decode这个blob字段,然后再输出就可以了。