All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.enodeframework.mysql.MysqlEventStore Maven / Gradle / Ivy

There is a newer version: 1.1.10
Show newest version
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);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy