public static Xid decodeXid(final ActiveMQBuffer in) { int formatID = in.readInt(); byte[] bq = new byte[in.readInt()]; in.readBytes(bq); byte[] gtxid = new byte[in.readInt()]; in.readBytes(gtxid); Xid xid = new XidImpl(bq, formatID, gtxid); return xid; }
@Override public String toString() { return "XidImpl (" + System.identityHashCode(this) + " bq:" + stringRep(branchQualifier) + " formatID:" + formatId + " gtxid:" + stringRep(globalTransactionId) + " base64:" + toBase64String(this); }
@Override public int hashCode() { if (!hashCalculated) { calcHash(); } return hash; }
@Override public String[] listPreparedTransactions() { checkStarted(); clearIO(); try { DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM); Map<Xid, Long> xids = resourceManager.getPreparedTransactionsWithCreationTime(); ArrayList<Entry<Xid, Long>> xidsSortedByCreationTime = new ArrayList<>(xids.entrySet()); Collections.sort(xidsSortedByCreationTime, new Comparator<Entry<Xid, Long>>() { @Override public int compare(final Entry<Xid, Long> entry1, final Entry<Xid, Long> entry2) { // sort by creation time, oldest first return (int) (entry1.getValue() - entry2.getValue()); } }); String[] s = new String[xidsSortedByCreationTime.size()]; int i = 0; for (Map.Entry<Xid, Long> entry : xidsSortedByCreationTime) { Date creation = new Date(entry.getValue()); Xid xid = entry.getKey(); s[i++] = dateFormat.format(creation) + " base64: " + XidImpl.toBase64String(xid) + " " + xid.toString(); } return s; } finally { blockOnIO(); } }
Xid xid = new XidImpl("xa1".getBytes(), 1, globalTransactionId); Xid xid2 = new XidImpl("xa2".getBytes(), 1, globalTransactionId); ServerLocator locator = createInVMNonHALocator(); ClientSessionFactory csf = createSessionFactory(locator); receiveLocator.close(); boolean success = serverControl.commitPreparedTransaction(XidImpl.toBase64String(xid)); success = serverControl.commitPreparedTransaction(XidImpl.toBase64String(xid));
private void calcHash() { byte[] hashBytes = XidImpl.toByteArray(this); hash = Arrays.hashCode(hashBytes); hashCalculated = true; }
@Override public String[] listHeuristicCommittedTransactions() { checkStarted(); clearIO(); try { List<Xid> xids = resourceManager.getHeuristicCommittedTransactions(); String[] s = new String[xids.size()]; int i = 0; for (Xid xid : xids) { s[i++] = XidImpl.toBase64String(xid); } return s; } finally { blockOnIO(); } }
public static String toBase64String(final Xid xid) { byte[] data = XidImpl.toByteArray(xid); return Base64.encodeBytes(data, 0, data.length, Base64.DONT_BREAK_LINES | Base64.URL_SAFE); }
protected XidImpl newXID(byte[] bytes) { return new XidImpl("amqp".getBytes(), 1, bytes); }
@Override public String toString() { return "XidImpl (" + System.identityHashCode(this) + " bq:" + stringRep(branchQualifier) + " formatID:" + formatId + " gtxid:" + stringRep(globalTransactionId) + " base64:" + toBase64String(this); }
@Override public String[] listHeuristicRolledBackTransactions() { checkStarted(); clearIO(); try { List<Xid> xids = resourceManager.getHeuristicRolledbackTransactions(); String[] s = new String[xids.size()]; int i = 0; for (Xid xid : xids) { s[i++] = XidImpl.toBase64String(xid); } return s; } finally { blockOnIO(); } }
private void calcHash() { byte[] hashBytes = XidImpl.toByteArray(this); hash = Arrays.hashCode(hashBytes); hashCalculated = true; }
@Override public int hashCode() { if (!hashCalculated) { calcHash(); } return hash; }
protected XidImpl newXID(byte[] bytes) { return new XidImpl("amqp".getBytes(), 1, bytes); }
@Override public String toString() { return "XidImpl (" + System.identityHashCode(this) + " bq:" + stringRep(branchQualifier) + " formatID:" + formatId + " gtxid:" + stringRep(globalTransactionId) + " base64:" + toBase64String(this); }
public JsonObject toJSON() throws Exception { DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM); JsonObjectBuilder detailJson = JsonLoader.createObjectBuilder().add(KEY_CREATION_TIME, dateFormat.format(new Date(this.creationTime))).add(KEY_XID_AS_BASE64, XidImpl.toBase64String(this.xid)).add(KEY_XID_FORMAT_ID, this.xid.getFormatId()).add(KEY_XID_GLOBAL_TXID, new String(this.xid.getGlobalTransactionId())).add(KEY_XID_BRANCH_QUAL, new String(this.xid.getBranchQualifier()));
private void calcHash() { byte[] hashBytes = XidImpl.toByteArray(this); hash = Arrays.hashCode(hashBytes); hashCalculated = true; }