| Home >> All >> org >> activemq >> transport >> [ stomp Javadoc ] |
Source code: org/activemq/transport/stomp/Begin.java
1 /* 2 * Copyright (c) 2005 Your Corporation. All Rights Reserved. 3 */ 4 package org.activemq.transport.stomp; 5 6 import org.activemq.message.TransactionInfo; 7 import org.activemq.message.TransactionType; 8 9 import java.io.DataInput; 10 import java.io.IOException; 11 import java.util.Properties; 12 import java.net.ProtocolException; 13 14 public class Begin implements Command 15 { 16 private StompWireFormat format; 17 private static final HeaderParser parser = new HeaderParser(); 18 19 public Begin(StompWireFormat format) 20 { 21 this.format = format; 22 } 23 24 public PacketEnvelope build(String commandLine, DataInput in) throws IOException 25 { 26 Properties headers = parser.parse(in); 27 while (in.readByte() != 0) {} 28 29 TransactionInfo tx = new TransactionInfo(); 30 String user_tx_id = headers.getProperty(Stomp.Headers.TRANSACTION); 31 if (!headers.containsKey(Stomp.Headers.TRANSACTION)) 32 { 33 throw new ProtocolException("Must specify the transaction you are beginning"); 34 } 35 String tx_id = StompWireFormat.clientIds.generateId(); 36 format.registerTransactionId(user_tx_id, tx_id); 37 tx.setTransactionId(tx_id); 38 tx.setType(TransactionType.START); 39 return new PacketEnvelope(tx, headers); 40 } 41 }