sequelize-xa-plugin
v1.1.1
Published
sequelize plugin XA transaction
Downloads
55
Maintainers
Readme
sequelize-XA-plugin
sequelize XA plugin
support sequelize for xa distribute protocol
Usage
Prepare Environment,support postgres only,edit postgresql.conf set max_prepared_transactions = 10
Init sequelize
let xaPlugin = require('sequelize-xa-plugin');
let sequelize = new Sequelize('database', 'user', 'pwd', {
dialect: 'postgres',
host: 'localhost',
port: 5432,
timezone: '+00:00',
logging: undefined,
pool: {
maxConnections: 10
}
});
sequelize = xaPlugin(sequelize);
- XATransaction function
yield db.XATransaction({
transactionManager: 'TM URL',
xid: 'TM ID',
name: 'child service name',
callback: 'child transaction callback',
isolationLevel: Sequelize.Transaction.ISOLATION_LEVELS.READ_UNCOMMITTED
}, function(t) {
return co(function*() {
//...do something to database
});
});
- XA callback to commit or roolback prepared transaction
yield sequelize.finishPrepared(transactionId, action);