到目前为止,没有人回答,我尝试从最新经验中做到这一点。
有用的文档资料:
example2(.ppt)
简化的算法看起来像(实际上是在example2中描述的):
1. 初始化FileResourceManager
2. 启动FileResourceManager
3. 从FileResourceManager实例获取事务ID
4. 从步骤3开始具有事务ID的事务
5. 编写所需的资源-此处提到将其写入 交易
,所以看起来这是主要步骤!
6. 提交或回滚事务
注: RESOURCEID ,约我,我的问题问,仅仅是 命名 的 事务性文件 。此命名不能很好地描述此属性。
代码,我用过:
private static final org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(FileAppender.class);private static LoggerFacade loggerFacade = new Log4jLogger(logger);private static String tempDir = (String) System.getProperties().get("java.io.tmpdir");private FileResourceManager frm = new FileResourceManager(tempDir, tempDir, false, loggerFacade);private static OutputStream outputStream;public void writeOut(E event) throws IOException { Object txId = null; try { frm.start(); txId = frm.generatedUniqueTxId(); frm.startTransaction(txId); outputStream = frm.writeResource(txId, fileName, true); frm.commitTransaction(txId); } catch (Exception e) { throw new IOException("DB rollback"); }}


