Package org.activemq.transport.stomp

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

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

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

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

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

    public Begin(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())
        {
            return new PacketEnvelope(new KeepAlive(), headers);
        }
        TransactionInfo tx = new TransactionInfo();
        String tx_id = StompWireFormat.clientIds.generateId();
        format.setTransactionId(tx_id);
        tx.setTransactionId(tx_id);
        tx.setType(TransactionType.START);
        return new PacketEnvelope(tx, headers);
    }
}
TOP

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

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.