org.activemq.transport.stomp
Class StompWireFormat

java.lang.Object
  extended by org.activemq.transport.stomp.StompWireFormat
All Implemented Interfaces:
WireFormat

public class StompWireFormat
extends Object
implements WireFormat

Implements the TTMP protocol.


Field Summary
 
Fields inherited from interface org.activemq.io.WireFormat
DEFAULT_MAXIMUM_MESSAGE_SIZE
 
Constructor Summary
StompWireFormat()
           
 
Method Summary
 void addAckListener(org.activemq.transport.stomp.AckListener listener)
           
 void addSubscription(org.activemq.transport.stomp.Subscription s)
           
 boolean canProcessWireFormatVersion(int version)
          Can this wireformat process packets of this version
 WireFormat copy()
          Creates a new copy of this wire format so it can be used in another thread/context
 boolean doesSupportMessageCompression()
          Some wire formats will not be able to understand compressed messages
 boolean doesSupportMessageFragmentation()
          some wire formats will implement their own fragementation
 void enqueuePacket(Packet ack)
           
 Packet fromBytes(byte[] bytes)
          Reads the packet from the given byte[]
 Packet fromBytes(byte[] bytes, int offset, int length)
          Reads the packet from the given byte[]
 List getAckListeners()
           
 int getCurrentWireFormatVersion()
           
 short getSessionId()
           
 org.activemq.transport.stomp.Subscription getSubscriptionFor(ActiveMQDestination destination)
           
 String getTransactionId(String key)
           
 void initiateClientSideProtocol()
          Some wire formats require a handshake at start-up
 void initiateServerSideProtocol()
          Some wire formats require a handshake at start-up
 boolean isCachingEnabled()
           
 Packet readPacket(DataInput in)
          Reads a packet from the given input stream
 Packet readPacket(int firstByte, DataInput in)
          A helper method for working with sockets where the first byte is read first, then the rest of the message is read.
 Packet readPacket(String channelID, DatagramPacket dpacket)
          Read a packet from a Datagram packet from the given channelID.
 void registerTransactionId(String user_tx_id, String tx_id)
           
 void registerTransportStreams(DataOutputStream dataOut, DataInputStream dataIn)
          some transports may register their streams (e.g.
 void setCachingEnabled(boolean enableCaching)
           
 byte[] toBytes(Packet packet)
          A helper method which converts a packet into a byte array
 Packet writePacket(Packet packet, DataOutput out)
          Writes the packet to the given output stream
 DatagramPacket writePacket(String channelID, Packet packet)
          Writes the given package to a new datagram
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StompWireFormat

public StompWireFormat()
Method Detail

readPacket

public Packet readPacket(DataInput in)
                  throws IOException
Description copied from interface: WireFormat
Reads a packet from the given input stream

Specified by:
readPacket in interface WireFormat
Returns:
Throws:
IOException

writePacket

public Packet writePacket(Packet packet,
                          DataOutput out)
                   throws IOException,
                          JMSException
Description copied from interface: WireFormat
Writes the packet to the given output stream

Specified by:
writePacket in interface WireFormat
Returns:
a response packet - or null
Throws:
IOException
JMSException

registerTransportStreams

public void registerTransportStreams(DataOutputStream dataOut,
                                     DataInputStream dataIn)
some transports may register their streams (e.g. Tcp)

Specified by:
registerTransportStreams in interface WireFormat
Parameters:
dataOut -
dataIn -

initiateServerSideProtocol

public void initiateServerSideProtocol()
                                throws IOException
Some wire formats require a handshake at start-up

Specified by:
initiateServerSideProtocol in interface WireFormat
Throws:
IOException

copy

public WireFormat copy()
Creates a new copy of this wire format so it can be used in another thread/context

Specified by:
copy in interface WireFormat
Returns:

initiateClientSideProtocol

public void initiateClientSideProtocol()
                                throws IOException
Some wire formats require a handshake at start-up

Specified by:
initiateClientSideProtocol in interface WireFormat
Throws:
IOException

canProcessWireFormatVersion

public boolean canProcessWireFormatVersion(int version)
Can this wireformat process packets of this version

Specified by:
canProcessWireFormatVersion in interface WireFormat
Parameters:
version - the version number to test
Returns:
true if can accept the version

getCurrentWireFormatVersion

public int getCurrentWireFormatVersion()
Specified by:
getCurrentWireFormatVersion in interface WireFormat
Returns:
the current version of this wire format

isCachingEnabled

public boolean isCachingEnabled()
Specified by:
isCachingEnabled in interface WireFormat
Returns:
Returns the enableCaching.

setCachingEnabled

public void setCachingEnabled(boolean enableCaching)
Specified by:
setCachingEnabled in interface WireFormat
Parameters:
enableCaching - The enableCaching to set.

doesSupportMessageFragmentation

public boolean doesSupportMessageFragmentation()
some wire formats will implement their own fragementation

Specified by:
doesSupportMessageFragmentation in interface WireFormat
Returns:
true unless a wire format supports it's own fragmentation

doesSupportMessageCompression

public boolean doesSupportMessageCompression()
Some wire formats will not be able to understand compressed messages

Specified by:
doesSupportMessageCompression in interface WireFormat
Returns:
true unless a wire format cannot understand compression

writePacket

public DatagramPacket writePacket(String channelID,
                                  Packet packet)
                           throws IOException,
                                  JMSException
Writes the given package to a new datagram

Specified by:
writePacket in interface WireFormat
Parameters:
channelID - is the unique channel ID
packet - is the packet to write
Returns:
Throws:
IOException
JMSException

fromBytes

public Packet fromBytes(byte[] bytes,
                        int offset,
                        int length)
                 throws IOException
Reads the packet from the given byte[]

Specified by:
fromBytes in interface WireFormat
Parameters:
bytes -
offset -
length -
Returns:
Throws:
IOException

fromBytes

public Packet fromBytes(byte[] bytes)
                 throws IOException
Reads the packet from the given byte[]

Specified by:
fromBytes in interface WireFormat
Parameters:
bytes -
Returns:
Throws:
IOException

toBytes

public byte[] toBytes(Packet packet)
               throws IOException,
                      JMSException
A helper method which converts a packet into a byte array

Specified by:
toBytes in interface WireFormat
Parameters:
packet -
Returns:
a byte array representing the packet using some wire protocol
Throws:
IOException
JMSException

readPacket

public Packet readPacket(int firstByte,
                         DataInput in)
                  throws IOException
A helper method for working with sockets where the first byte is read first, then the rest of the message is read.

Its common when dealing with sockets to have different timeout semantics until the first non-zero byte is read of a message, after which time a zero timeout is used.

Specified by:
readPacket in interface WireFormat
Parameters:
firstByte - the first byte of the packet
in - the rest of the packet
Returns:
Throws:
IOException

readPacket

public Packet readPacket(String channelID,
                         DatagramPacket dpacket)
                  throws IOException
Read a packet from a Datagram packet from the given channelID. If the packet is from the same channel ID as it was sent then we have a loop-back so discard the packet

Specified by:
readPacket in interface WireFormat
Parameters:
channelID - is the unique channel ID
dpacket -
Returns:
the packet read from the datagram or null if it should be discarded
Throws:
IOException

getSessionId

public short getSessionId()

addSubscription

public void addSubscription(org.activemq.transport.stomp.Subscription s)

enqueuePacket

public void enqueuePacket(Packet ack)

getSubscriptionFor

public org.activemq.transport.stomp.Subscription getSubscriptionFor(ActiveMQDestination destination)

addAckListener

public void addAckListener(org.activemq.transport.stomp.AckListener listener)

getAckListeners

public List getAckListeners()

getTransactionId

public String getTransactionId(String key)

registerTransactionId

public void registerTransactionId(String user_tx_id,
                                  String tx_id)


Copyright © 2004-2009 Protique, Ltd.. All Rights Reserved.