- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中org.bytesoft.transaction.xa.XidFactory.createGlobalXid()
方法的一些代码示例,展示了XidFactory.createGlobalXid()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XidFactory.createGlobalXid()
方法的具体详情如下:
包路径:org.bytesoft.transaction.xa.XidFactory
类名称:XidFactory
方法名:createGlobalXid
暂无
代码示例来源:origin: liuyangming/ByteTCC
@RequestMapping(value = "/org/bytesoft/bytetcc/forget/{xid}", method = RequestMethod.POST)
@ResponseBody
public void forget(@PathVariable("xid") String identifier, HttpServletResponse response) {
try {
XidFactory xidFactory = this.beanFactory.getCompensableXidFactory();
byte[] byteArray = ByteUtils.stringToByteArray(identifier);
Xid xid = xidFactory.createGlobalXid(byteArray);
this.compensableCoordinator.forget(xid);
} catch (XAException ex) {
logger.error("Error occurred while forgetting transaction: {}.", identifier, ex);
response.addHeader("failure", "true");
response.addHeader("XA_XAER", String.valueOf(ex.errorCode));
response.setStatus(500);
} catch (RuntimeException ex) {
logger.error("Error occurred while forgetting transaction: {}.", identifier, ex);
response.addHeader("failure", "true");
response.setStatus(500);
}
}
代码示例来源:origin: liuyangming/ByteTCC
@RequestMapping(value = "/org/bytesoft/bytetcc/forget/{xid}", method = RequestMethod.POST)
@ResponseBody
public void forget(@PathVariable("xid") String identifier, HttpServletResponse response) {
try {
XidFactory xidFactory = this.beanFactory.getCompensableXidFactory();
byte[] byteArray = ByteUtils.stringToByteArray(identifier);
Xid xid = xidFactory.createGlobalXid(byteArray);
this.compensableCoordinator.forget(xid);
} catch (XAException ex) {
logger.error("Error occurred while forgetting transaction: {}.", identifier, ex);
response.addHeader("failure", "true");
response.addHeader("XA_XAER", String.valueOf(ex.errorCode));
response.setStatus(500);
} catch (RuntimeException ex) {
logger.error("Error occurred while forgetting transaction: {}.", identifier, ex);
response.addHeader("failure", "true");
response.setStatus(500);
}
}
代码示例来源:origin: liuyangming/ByteTCC
@RequestMapping(value = "/org/bytesoft/bytetcc/commit/{xid}/{opc}", method = RequestMethod.POST)
@ResponseBody
public void commit(@PathVariable("xid") String identifier, @PathVariable("opc") boolean onePhase,
HttpServletResponse response) {
try {
XidFactory xidFactory = this.beanFactory.getCompensableXidFactory();
byte[] byteArray = ByteUtils.stringToByteArray(identifier);
Xid xid = xidFactory.createGlobalXid(byteArray);
this.compensableCoordinator.commit(xid, onePhase);
} catch (XAException ex) {
logger.error("Error occurred while committing transaction: {}.", identifier, ex);
response.addHeader("failure", "true");
response.addHeader("XA_XAER", String.valueOf(ex.errorCode));
response.setStatus(500);
} catch (RuntimeException ex) {
logger.error("Error occurred while committing transaction: {}.", identifier, ex);
response.addHeader("failure", "true");
response.setStatus(500);
}
}
代码示例来源:origin: liuyangming/ByteTCC
@RequestMapping(value = "/org/bytesoft/bytetcc/rollback/{xid}", method = RequestMethod.POST)
@ResponseBody
public void rollback(@PathVariable("xid") String identifier, HttpServletResponse response) {
try {
XidFactory xidFactory = this.beanFactory.getCompensableXidFactory();
byte[] byteArray = ByteUtils.stringToByteArray(identifier);
Xid xid = xidFactory.createGlobalXid(byteArray);
this.compensableCoordinator.rollback(xid);
} catch (XAException ex) {
logger.error("Error occurred while rolling back transaction: {}.", identifier, ex);
response.addHeader("failure", "true");
response.addHeader("XA_XAER", String.valueOf(ex.errorCode));
response.setStatus(500);
} catch (RuntimeException ex) {
logger.error("Error occurred while rolling back transaction: {}.", identifier, ex);
response.addHeader("failure", "true");
response.setStatus(500);
}
}
代码示例来源:origin: liuyangming/ByteTCC
@RequestMapping(value = "/org/bytesoft/bytetcc/rollback/{xid}", method = RequestMethod.POST)
@ResponseBody
public void rollback(@PathVariable("xid") String identifier, HttpServletResponse response) {
try {
XidFactory xidFactory = this.beanFactory.getCompensableXidFactory();
byte[] byteArray = ByteUtils.stringToByteArray(identifier);
Xid xid = xidFactory.createGlobalXid(byteArray);
this.compensableCoordinator.rollback(xid);
} catch (XAException ex) {
logger.error("Error occurred while rolling back transaction: {}.", identifier, ex);
response.addHeader("failure", "true");
response.addHeader("XA_XAER", String.valueOf(ex.errorCode));
response.setStatus(500);
} catch (RuntimeException ex) {
logger.error("Error occurred while rolling back transaction: {}.", identifier, ex);
response.addHeader("failure", "true");
response.setStatus(500);
}
}
代码示例来源:origin: liuyangming/ByteTCC
@RequestMapping(value = "/org/bytesoft/bytetcc/commit/{xid}/{opc}", method = RequestMethod.POST)
@ResponseBody
public void commit(@PathVariable("xid") String identifier, @PathVariable("opc") boolean onePhase,
HttpServletResponse response) {
try {
XidFactory xidFactory = this.beanFactory.getCompensableXidFactory();
byte[] byteArray = ByteUtils.stringToByteArray(identifier);
Xid xid = xidFactory.createGlobalXid(byteArray);
this.compensableCoordinator.commit(xid, onePhase);
} catch (XAException ex) {
logger.error("Error occurred while committing transaction: {}.", identifier, ex);
response.addHeader("failure", "true");
response.addHeader("XA_XAER", String.valueOf(ex.errorCode));
response.setStatus(500);
} catch (RuntimeException ex) {
logger.error("Error occurred while committing transaction: {}.", identifier, ex);
response.addHeader("failure", "true");
response.setStatus(500);
}
}
代码示例来源:origin: liuyangming/ByteTCC
@RequestMapping(value = "/org/bytesoft/bytetcc/prepare/{xid}", method = RequestMethod.POST)
@ResponseBody
public int prepare(@PathVariable("xid") String identifier, HttpServletResponse response) {
try {
XidFactory xidFactory = this.beanFactory.getCompensableXidFactory();
byte[] byteArray = ByteUtils.stringToByteArray(identifier);
Xid xid = xidFactory.createGlobalXid(byteArray);
return this.compensableCoordinator.prepare(xid);
} catch (XAException ex) {
logger.error("Error occurred while preparing transaction: {}.", identifier, ex);
response.addHeader("failure", "true");
response.addHeader("XA_XAER", String.valueOf(ex.errorCode));
response.setStatus(500);
return -1;
} catch (RuntimeException ex) {
logger.error("Error occurred while preparing transaction: {}.", identifier, ex);
response.addHeader("failure", "true");
response.setStatus(500);
return -1;
}
}
代码示例来源:origin: liuyangming/ByteTCC
@RequestMapping(value = "/org/bytesoft/bytetcc/prepare/{xid}", method = RequestMethod.POST)
@ResponseBody
public int prepare(@PathVariable("xid") String identifier, HttpServletResponse response) {
try {
XidFactory xidFactory = this.beanFactory.getCompensableXidFactory();
byte[] byteArray = ByteUtils.stringToByteArray(identifier);
Xid xid = xidFactory.createGlobalXid(byteArray);
return this.compensableCoordinator.prepare(xid);
} catch (XAException ex) {
logger.error("Error occurred while preparing transaction: {}.", identifier, ex);
response.addHeader("failure", "true");
response.addHeader("XA_XAER", String.valueOf(ex.errorCode));
response.setStatus(500);
return -1;
} catch (RuntimeException ex) {
logger.error("Error occurred while preparing transaction: {}.", identifier, ex);
response.addHeader("failure", "true");
response.setStatus(500);
return -1;
}
}
代码示例来源:origin: liuyangming/ByteTCC
public void onRecovery(Transaction transaction) {
org.bytesoft.transaction.TransactionContext transactionContext = transaction.getTransactionContext();
TransactionXid xid = transactionContext.getXid();
XidFactory xidFactory = this.beanFactory.getCompensableXidFactory();
TransactionXid globalXid = xidFactory.createGlobalXid(xid.getGlobalTransactionId());
this.recovered.put(globalXid, transaction);
}
代码示例来源:origin: liuyangming/ByteTCC
buffer.get(resourceByteArray);
TransactionXid globalXid = xidFactory.createGlobalXid(globalByteArray);
TransactionXid branchXid = xidFactory.createBranchXid(globalXid, branchByteArray);
String resourceId = StringUtils.trimToNull(new String(resourceByteArray));
代码示例来源:origin: liuyangming/ByteTCC
public void registerCompensable(CompensableInvocation invocation) {
XidFactory xidFactory = this.beanFactory.getTransactionXidFactory();
invocation.setEnlisted(true);
CompensableArchive archive = new CompensableArchive();
TransactionXid globalXid = xidFactory.createGlobalXid(this.transactionContext.getXid().getGlobalTransactionId());
TransactionXid branchXid = xidFactory.createBranchXid(globalXid);
archive.setIdentifier(branchXid);
archive.setCompensable(invocation);
this.archiveList.add(archive);
this.currentArchiveList.add(archive);
logger.info("{}| register compensable service: {}.",
ByteUtils.byteArrayToString(this.transactionContext.getXid().getGlobalTransactionId()),
ByteUtils.byteArrayToString(archive.getIdentifier().getGlobalTransactionId()));
}
代码示例来源:origin: liuyangming/ByteTCC
public void begin() throws NotSupportedException, SystemException {
CompensableTransaction compensable = this.getCompensableTransactionQuietly();
if (compensable == null || compensable.getTransaction() != null) {
throw new SystemException(XAException.XAER_PROTO);
}
TransactionContext compensableContext = compensable.getTransactionContext();
XidFactory transactionXidFactory = this.beanFactory.getTransactionXidFactory();
TransactionXid transactionXid = transactionXidFactory.createGlobalXid();
TransactionContext transactionContext = compensableContext.clone();
transactionContext.setXid(transactionXid);
this.invokeBegin(transactionContext, false);
}
代码示例来源:origin: liuyangming/ByteTCC
public void onEnlistResource(Xid xid, XAResource xares) {
String resourceKey = null;
if (XAResourceDescriptor.class.isInstance(xares)) {
XAResourceDescriptor descriptor = (XAResourceDescriptor) xares;
resourceKey = descriptor.getIdentifier();
} else if (XAResourceArchive.class.isInstance(xares)) {
XAResourceArchive resourceArchive = (XAResourceArchive) xares;
XAResourceDescriptor descriptor = resourceArchive.getDescriptor();
resourceKey = descriptor == null ? null : descriptor.getIdentifier();
}
CompensableLogger compensableLogger = this.beanFactory.getCompensableLogger();
if (this.transactionContext.isCompensating()) {
// this.archive.setCompensableXid(xid); // preset the compensable-xid.
this.archive.setCompensableResourceKey(resourceKey);
compensableLogger.updateCompensable(this.archive);
} else {
for (int i = 0; i < this.currentArchiveList.size(); i++) {
CompensableArchive compensableArchive = this.currentArchiveList.get(i);
compensableArchive.setTransactionXid(xid);
compensableArchive.setTransactionResourceKey(resourceKey);
XidFactory transactionXidFactory = this.beanFactory.getTransactionXidFactory();
TransactionXid globalXid = transactionXidFactory.createGlobalXid(xid.getGlobalTransactionId());
TransactionXid branchXid = transactionXidFactory.createBranchXid(globalXid);
compensableArchive.setCompensableXid(branchXid); // preset the compensable-xid.
compensableLogger.createCompensable(compensableArchive);
}
}
}
代码示例来源:origin: liuyangming/ByteTCC
public void recover(org.bytesoft.compensable.archive.TransactionArchive archive) {
XidFactory transactionXidFactory = beanFactory.getTransactionXidFactory();
CompensableTransactionImpl transaction = reconstruct(archive);
TransactionContext transactionContext = transaction.getTransactionContext();
TransactionXid compensableXid = transactionContext.getXid();
if (transactionContext.isCompensable() == false) {
TransactionXid transactionXid = transactionXidFactory
.createGlobalXid(compensableXid.getGlobalTransactionId());
Transaction tx = recovered.get(transactionXid);
if (tx != null) {
tx.setTransactionalExtra(transaction);
transaction.setTransactionalExtra(tx); // TODO different thread
}
} else {
recoverStatusIfNecessary(transaction);
} // end-if (transactionContext.isCoordinator())
transactionRepository.putTransaction(compensableXid, transaction);
transactionRepository.putErrorTransaction(compensableXid, transaction);
}
});
代码示例来源:origin: liuyangming/ByteTCC
public void forget(Xid xid) throws XAException {
this.checkParticipantReadyIfNecessary();
if (xid == null) {
throw new XAException(XAException.XAER_INVAL);
}
TransactionRepository compensableRepository = this.beanFactory.getCompensableRepository();
XidFactory xidFactory = this.beanFactory.getCompensableXidFactory();
TransactionXid globalXid = xidFactory.createGlobalXid(xid.getGlobalTransactionId());
CompensableTransaction transaction = null;
try {
transaction = (CompensableTransaction) compensableRepository.getTransaction(globalXid);
} catch (TransactionException tex) {
throw new XAException(XAException.XAER_RMERR);
}
if (transaction == null) {
throw new XAException(XAException.XAER_NOTA);
}
try {
transaction.forget();
} catch (SystemException ex) {
logger.error("Error occurred while forgetting transaction: {}." //
, ByteUtils.byteArrayToString(xid.getGlobalTransactionId()), ex);
throw new XAException(XAException.XAER_RMERR);
} catch (RuntimeException rex) {
logger.error("Error occurred while forgetting transaction: {}." //
, ByteUtils.byteArrayToString(xid.getGlobalTransactionId()), rex);
throw new XAException(XAException.XAER_RMERR);
}
}
代码示例来源:origin: liuyangming/ByteTCC
TransactionXid globalXid = compensableXidFactory.createGlobalXid(globalByteArray);
archive.setXid(globalXid);
代码示例来源:origin: liuyangming/ByteTCC
transactionContext.setCompensating(archive.isPropagated() == false);
transactionContext.setRecoveried(true);
transactionContext.setXid(xidFactory.createGlobalXid(archive.getXid().getGlobalTransactionId()));
transactionContext.setPropagatedBy(transactionArchive.getPropagatedBy());
transactionContext.setRecoveredTimes(transactionArchive.getRecoveredTimes());
代码示例来源:origin: liuyangming/ByteTCC
public void rollback(Xid xid) throws XAException {
this.checkParticipantReadyIfNecessary();
if (xid == null) {
throw new XAException(XAException.XAER_INVAL);
}
XidFactory xidFactory = this.beanFactory.getCompensableXidFactory();
TransactionLock compensableLock = this.beanFactory.getCompensableLock();
TransactionXid globalXid = xidFactory.createGlobalXid(xid.getGlobalTransactionId());
CompensableTransaction transaction = null;
boolean success = false;
boolean locked = false;
try {
if ((locked = compensableLock.lockTransaction(globalXid, this.endpoint)) == false) {
throw new XAException(XAException.XAER_RMERR);
}
transaction = this.invokeRollback(globalXid);
success = true;
} catch (RuntimeException ex) {
logger.error("Error occurred while rolling back transaction: {}." //
, ByteUtils.byteArrayToString(xid.getGlobalTransactionId()), ex);
throw new XAException(XAException.XAER_RMERR); // should never happen
} finally {
if (locked) {
compensableLock.unlockTransaction(globalXid, this.endpoint);
} // end-if (locked)
if (success) {
transaction.forgetQuietly(); // forget transaction
} // end-if (success)
}
}
代码示例来源:origin: liuyangming/ByteTCC
public TransactionXid compensableBegin() throws NotSupportedException, SystemException {
RemoteCoordinator compensableCoordinator = (RemoteCoordinator) this.beanFactory.getCompensableNativeParticipant();
CompensableManager tompensableManager = this.beanFactory.getCompensableManager();
XidFactory compensableXidFactory = this.beanFactory.getCompensableXidFactory();
CompensableTransactionImpl compensable = (CompensableTransactionImpl) tompensableManager
.getCompensableTransactionQuietly();
if (compensable != null) {
throw new NotSupportedException();
}
TransactionXid compensableXid = compensableXidFactory.createGlobalXid();
TransactionContext compensableContext = new TransactionContext();
compensableContext.setCoordinator(true);
compensableContext.setPropagated(true);
compensableContext.setCompensable(true);
compensableContext.setStatefully(this.statefully);
compensableContext.setXid(compensableXid);
compensableContext.setPropagatedBy(compensableCoordinator.getIdentifier());
compensable = new CompensableTransactionImpl(compensableContext);
compensable.setBeanFactory(this.beanFactory);
try {
compensableCoordinator.start(compensableContext, XAResource.TMNOFLAGS);
} catch (XAException ex) {
logger.error("Error occurred while beginning an compensable transaction!", ex);
throw new SystemException(ex.getMessage());
}
return compensableXid;
}
代码示例来源:origin: liuyangming/ByteTCC
TransactionXid globalXid = xidFactory.createGlobalXid(xid.getGlobalTransactionId());
CompensableTransaction transaction = null;
try {
使用此代码我无法获得 xa 或非 xa 的连接 DatabaseMetaData dbmd = con.getMetaData(); dbmd.getDriverName(); System.out.
我们可以在同一存储库类中使用 xa 和非 xa 资源的组合吗?如果可以的话,有人可以解释一下它的行为方式以及交易将如何进行吗?目前,我们在存储库中使用 2 个 xa 资源和 2 个非 xa 资源。我们
我试图了解 Java XA 数据源的使用。但我仍然不知道何时使用它,何时不使用它。 我读到当我们使用两个数据库时使用 XA 数据源。但我不确定两个数据库是什么意思。 例如: 我有两层类(Service
我们在不需要的情况下使用 XA JDBC 驱动程序(不参与分布式事务的只读工作)。 只是想知道是否有任何已知的性能提升必须切换到非 XA JDBC 驱动程序 - 如果没有,它可能不值得切换? FWIW
在我的 Spring Boot 应用程序中,我有以下场景: 从 JMS 队列读取消息 利用数据做一些事情。 对 Oracle 数据库执行 JDBC 插入 如果在任何阶段发生异常,我希望确保消息不会丢失
我对 XA 和非 XA 世界还很陌生。我的要求是从队列中读取一条消息,直到没有消息为止。对于队列中的每条消息,转到数据库并执行一些事务,例如选择、插入、更新。 是否可以使用非 XA 数据源实现此目的?
问题 我正在尝试使用geopandas绘制每个地区的犯罪数据。我已合并 shapefile 数据和犯罪数据: merged = merged[['geometry','Extortion']] mer
我使用两个单独的数据源。使用 EJB3.0,我使用的是 non-Xa-datasources。我遇到这样的错误:无法打开连接,状态感知对象。这是因为在一个无状态 bean 中我调用了第二个无状态 be
oracle.jdbc.xa.OracleXADataSource 和 oracle.jdbc.xa.client.OracleXADataSource 黑白有什么区别 ,我知道两者都是 XA 兼容的
在我们的新项目中,我们希望实现涉及 jpa (mysql) 和消息总线 (rabbitmq) 的事务 我们开始使用 mysql 和 rabbitmq(通过 spring amqp 模块)使用 spri
在 mysql 重新启动时提交 XA 待处理事务时,出现以下错误。请帮助我解决这个错误。 mysql> XA RECOVER CONVERT XID; +----------+------------
我将两个 XA 数据源用于 EAP7 和 MySQL。应用程序正在运行,但在调用驾驶舱后抛出了很多异常。 7.5 版中的 Camunda 两者的配置相同。 (由红帽 EAP Docker 镜像生成)
有谁知道为什么 Mysql 需要可序列化隔离级别来实现 XA 事务的 ACID 属性,或者如果使用可重复读取和 XA 会丢失什么? However, for a distributed transac
假设我们有一个数据库(例如 Oracle)和一个 JMS 提供者(例如 HornetQ)参与 XA 事务。一条消息被发送到一个 JMS 队列,并且一些数据在同一个分布式事务中保存在数据库中。事务提交后
我们认为这是一个相当常见的 XA 用例: 从队列中读取消息 将一些数据写入数据库 向出队列(与入队列不同)写入响应消息 然而,我们还需要一种方法来处理内部错误和有害消息。我们想到的控制流程是这样的:
我想在 2 个不同位置的数据库中分离 2 个表...因此 1 个 MySQL 数据库位于一个数据中心,另外 1 个位于另一个数据中心。 我在 Wildfly 中使用普通数据源,并使用 JPA 连接到
我的 Websphere 应用程序有 3 个数据源。其中两个是 XA,另一个是非 XA。 我通过使用 @transactional 注释对方法进行注释,使 Java 方法具有事务性。 在该方法中,执行
背景知识:我遇到了一个问题,我越深入地研究它,就越发现 XA 似乎是正确的解决方案。我有一个“缓存”,它基本上是一个内存数据结构(树形结构),用于保存一些处理过的信息。使用Spring,我们设置了数据
我有一个关于 this 的问题 假设我有一些联系 $conn_site = mysqli_connect("localhost", "us", "ps"); mysqli_select_db("sit
我在 Mint 18 上使用 MySQL 5.7.19-0ubuntu0.16.04.1。我发现当我准备 XA 事务时,然后服务器崩溃了。服务重启后,我就不能再碰交易了。它仍然锁定了 table 。
我是一名优秀的程序员,十分优秀!