Package org.activemq.transport.stomp

Source Code of org.activemq.transport.stomp.Commit

/*
* Copyright (c) 2005 Your Corporation. All Rights Reserved.
*/
package org.activemq.transport.stomp;

import org.activemq.message.TransactionInfo;
import org.activemq.message.TransactionType;

import java.io.DataInput;
import java.io.IOException;
import java.net.ProtocolException;
import java.util.Properties;

class Commit implements Command
{
    private StompWireFormat format;
    private static final HeaderParser parser = new HeaderParser();

    Commit(StompWireFormat format)
    {
        this.format = format;
    }

    public PacketEnvelope build(String commandLine, DataInput in) throws IOException
    {
        Properties headers = parser.parse(in);
        while (in.readByte() != 0) {}

        if (!format.isInTransaction())
        {
            throw new ProtocolException("Cannot COMMIT when not in a transaction");
        }
        TransactionInfo tx = new TransactionInfo();
        tx.setTransactionId(format.getTransactionId());
        tx.setType(TransactionType.COMMIT);
        format.clearTransactionId();
        return new PacketEnvelope(tx, headers);
    }
}
TOP

Related Classes of org.activemq.transport.stomp.Commit

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.