Search in sources :

Example 16 with TransactionAcknowledgement

use of com.sun.messaging.jmq.jmsserver.data.TransactionAcknowledgement in project openmq by eclipse-ee4j.

the class TransactionLogReplayer method replayRemoteAcks.

public void replayRemoteAcks(TransactionAcknowledgement[] txnAcks, DestinationUID[] destIds, TransactionUID tid, HashSet dstLoadedSet) throws IOException, BrokerException {
    if (Store.getDEBUG()) {
        String msg = getPrefix() + " replayRemoteAcks ";
        logger.log(Logger.INFO, msg);
    }
    for (int i = 0; i < txnAcks.length; i++) {
        TransactionAcknowledgement txnAck = txnAcks[i];
        DestinationUID destId = destIds[i];
        SysMessageID mid = txnAck.getSysMessageID();
        ConsumerUID iid = txnAck.getStoredConsumerUID();
        // Destination dest = DestinationList.getDestination(msgStore.parent, destId);
        // make sure it is loaded
        int type = (destId.isQueue() ? DestType.DEST_TYPE_QUEUE : DestType.DEST_TYPE_TOPIC);
        Destination[] ds = DestinationList.getDestination(msgStore.parent, destId.getName(), type, true, true);
        Destination dest = ds[0];
        dest.load();
        PacketReference pr = dest.getMessage(mid);
        if (pr == null) {
            // could have been acknowledged already?
            // TO DO check this further
            String msg = " could not find packet for replayed message ack " + txnAck + " dest " + destId + " in transaction " + tid;
            logger.log(Logger.WARNING, msg);
        } else {
            if (msgStore.containsMessage(destId, mid)) {
                logger.log(logger.FORCE, BrokerResources.I_UPDATE_INT_STATE_TXNLOG, iid, mid);
                // use try using the correct value; see bug 6516160
                if (dest.isQueue() && iid.longValue() != 0) {
                    msgStore.updateInterestState(destId, mid, PacketReference.getQueueUID(), PartitionedStore.INTEREST_STATE_ACKNOWLEDGED, false);
                } else {
                    msgStore.updateInterestState(destId, mid, iid, PartitionedStore.INTEREST_STATE_ACKNOWLEDGED, false);
                }
                acknowledgeOnReplay(dest, mid, iid);
            } else {
                logger.log(logger.FORCE, BrokerResources.I_DISREGARD_INT_STATE_TXNLOG, iid, mid);
            }
        }
    }
}
Also used : Destination(com.sun.messaging.jmq.jmsserver.core.Destination) TransactionAcknowledgement(com.sun.messaging.jmq.jmsserver.data.TransactionAcknowledgement) DestinationUID(com.sun.messaging.jmq.jmsserver.core.DestinationUID) ConsumerUID(com.sun.messaging.jmq.jmsserver.core.ConsumerUID) PacketReference(com.sun.messaging.jmq.jmsserver.core.PacketReference) SysMessageID(com.sun.messaging.jmq.io.SysMessageID)

Example 17 with TransactionAcknowledgement

use of com.sun.messaging.jmq.jmsserver.data.TransactionAcknowledgement in project openmq by eclipse-ee4j.

the class RemoteTransaction2PPrepareEvent method readFromBytes.

@Override
public void readFromBytes(byte[] data) throws IOException, BrokerException {
    ByteArrayInputStream bais = new ByteArrayInputStream(data);
    DataInputStream dis = new DataInputStream(bais);
    remoteTransaction = new RemoteTransaction();
    dis.skip(2);
    remoteTransaction.getTransactionDetails().readContent(dis);
    int objectBodySize = dis.readInt();
    byte[] objectBody = new byte[objectBodySize];
    dis.read(objectBody);
    ByteArrayInputStream bais2 = new ByteArrayInputStream(objectBody);
    ObjectInputStream ois = new FilteringObjectInputStream(bais2);
    try {
        remoteTransaction.setTransactionState((TransactionState) ois.readObject());
        remoteTransaction.setTxnHomeBroker((BrokerAddress) ois.readObject());
        remoteTransaction.setTxnAcks((TransactionAcknowledgement[]) ois.readObject());
        remoteTransaction.setDestIds((DestinationUID[]) ois.readObject());
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    }
    ois.close();
    bais2.close();
    dis.close();
    bais.close();
}
Also used : RemoteTransaction(com.sun.messaging.jmq.jmsserver.data.RemoteTransaction) TransactionAcknowledgement(com.sun.messaging.jmq.jmsserver.data.TransactionAcknowledgement) DestinationUID(com.sun.messaging.jmq.jmsserver.core.DestinationUID) ByteArrayInputStream(java.io.ByteArrayInputStream) FilteringObjectInputStream(com.sun.messaging.jmq.util.io.FilteringObjectInputStream) DataInputStream(java.io.DataInputStream) FilteringObjectInputStream(com.sun.messaging.jmq.util.io.FilteringObjectInputStream) ObjectInputStream(java.io.ObjectInputStream)

Aggregations

TransactionAcknowledgement (com.sun.messaging.jmq.jmsserver.data.TransactionAcknowledgement)17 SysMessageID (com.sun.messaging.jmq.io.SysMessageID)10 ConsumerUID (com.sun.messaging.jmq.jmsserver.core.ConsumerUID)10 TransactionUID (com.sun.messaging.jmq.jmsserver.data.TransactionUID)8 DestinationUID (com.sun.messaging.jmq.jmsserver.core.DestinationUID)6 BrokerException (com.sun.messaging.jmq.jmsserver.util.BrokerException)6 PacketReference (com.sun.messaging.jmq.jmsserver.core.PacketReference)5 Packet (com.sun.messaging.jmq.io.Packet)4 BrokerAddress (com.sun.messaging.jmq.jmsserver.core.BrokerAddress)4 Destination (com.sun.messaging.jmq.jmsserver.core.Destination)4 TransactionBroker (com.sun.messaging.jmq.jmsserver.data.TransactionBroker)4 TransactionList (com.sun.messaging.jmq.jmsserver.data.TransactionList)4 DupKeyException (com.sun.messaging.bridge.api.DupKeyException)3 KeyNotFoundException (com.sun.messaging.bridge.api.KeyNotFoundException)3 Consumer (com.sun.messaging.jmq.jmsserver.core.Consumer)3 TransactionState (com.sun.messaging.jmq.jmsserver.data.TransactionState)3 AckEntryNotFoundException (com.sun.messaging.jmq.jmsserver.util.AckEntryNotFoundException)3 SelectorFormatException (com.sun.messaging.jmq.util.selector.SelectorFormatException)3 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3