org.enodeframework.mysql.MysqlEventStore Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of enode-mysql Show documentation
Show all versions of enode-mysql Show documentation
MySQL driver for enodeframework.
package org.enodeframework.mysql;
import org.enodeframework.eventing.IEventSerializer;
import org.enodeframework.jdbc.DBConfiguration;
import org.enodeframework.jdbc.JDBCEventStore;
import javax.sql.DataSource;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* @author [email protected]
*/
public class MysqlEventStore extends JDBCEventStore {
private static final Pattern PATTERN_MYSQL = Pattern.compile("^Duplicate entry '.*-(.*)' for key");
public MysqlEventStore(DataSource dataSource, IEventSerializer eventSerializer) {
super(dataSource, eventSerializer);
}
public MysqlEventStore(DataSource dataSource, DBConfiguration setting, IEventSerializer eventSerializer) {
super(dataSource, setting, eventSerializer);
}
@Override
public String parseDuplicateCommandId(String errMsg) {
Matcher matcher = PATTERN_MYSQL.matcher(errMsg);
if (!matcher.find()) {
return "";
}
if (matcher.groupCount() == 0) {
return "";
}
return matcher.group(1);
}
}