org.apache.activemq.transport.udp
Class CommandDatagramSocket

java.lang.Object
  extended by org.apache.activemq.transport.udp.CommandChannelSupport
      extended by org.apache.activemq.transport.udp.CommandDatagramSocket
All Implemented Interfaces:
Service, Replayer, CommandChannel

public class CommandDatagramSocket
extends CommandChannelSupport

A strategy for reading datagrams and de-fragmenting them together.


Field Summary
 
Fields inherited from class org.apache.activemq.transport.udp.CommandChannelSupport
datagramSize, headerMarshaller, name, replayAddress, sequenceGenerator, targetAddress, wireFormat
 
Constructor Summary
CommandDatagramSocket(UdpTransport transport, OpenWireFormat wireFormat, int datagramSize, SocketAddress targetAddress, DatagramHeaderMarshaller headerMarshaller, DatagramSocket channel)
           
 
Method Summary
protected  ByteArrayOutputStream createByteArrayOutputStream()
           
protected  DatagramPacket createDatagramPacket()
           
 int getDatagramSize()
           
 int getReceiveCounter()
           
 Command read()
           
protected  int remaining(ByteArrayOutputStream buffer)
           
 void sendBuffer(int commandId, Object buffer)
          Sends the given buffer back to the transport if the buffer could be found - otherwise maybe send some kind of exception
protected  void sendWriteBuffer(int commandId, SocketAddress address, byte[] data, boolean redelivery)
           
protected  void sendWriteBuffer(SocketAddress address, ByteArrayOutputStream writeBuffer, int commandId)
           
 void setDatagramSize(int datagramSize)
          Sets the default size of a datagram on the network.
 void start()
           
 void stop()
           
 void write(Command command, SocketAddress address)
           
 
Methods inherited from class org.apache.activemq.transport.udp.CommandChannelSupport
getHeaderMarshaller, getReplayAddress, getReplayBuffer, getTargetAddress, setHeaderMarshaller, setReplayAddress, setReplayBuffer, setTargetAddress, toString, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CommandDatagramSocket

public CommandDatagramSocket(UdpTransport transport,
                             OpenWireFormat wireFormat,
                             int datagramSize,
                             SocketAddress targetAddress,
                             DatagramHeaderMarshaller headerMarshaller,
                             DatagramSocket channel)
Method Detail

start

public void start()
           throws Exception
Throws:
Exception

stop

public void stop()
          throws Exception
Throws:
Exception

read

public Command read()
             throws IOException
Throws:
IOException

write

public void write(Command command,
                  SocketAddress address)
           throws IOException
Throws:
IOException

getDatagramSize

public int getDatagramSize()
Specified by:
getDatagramSize in interface CommandChannel
Overrides:
getDatagramSize in class CommandChannelSupport

setDatagramSize

public void setDatagramSize(int datagramSize)
Description copied from class: CommandChannelSupport
Sets the default size of a datagram on the network.

Specified by:
setDatagramSize in interface CommandChannel
Overrides:
setDatagramSize in class CommandChannelSupport

sendWriteBuffer

protected void sendWriteBuffer(SocketAddress address,
                               ByteArrayOutputStream writeBuffer,
                               int commandId)
                        throws IOException
Throws:
IOException

sendWriteBuffer

protected void sendWriteBuffer(int commandId,
                               SocketAddress address,
                               byte[] data,
                               boolean redelivery)
                        throws IOException
Throws:
IOException

sendBuffer

public void sendBuffer(int commandId,
                       Object buffer)
                throws IOException
Description copied from interface: Replayer
Sends the given buffer back to the transport if the buffer could be found - otherwise maybe send some kind of exception

Parameters:
commandId - the command ID
buffer - the buffer to be sent - or null if the buffer no longer exists in the buffer
Throws:
IOException

createDatagramPacket

protected DatagramPacket createDatagramPacket()

remaining

protected int remaining(ByteArrayOutputStream buffer)

createByteArrayOutputStream

protected ByteArrayOutputStream createByteArrayOutputStream()

getReceiveCounter

public int getReceiveCounter()


Copyright © 2005-2012 The Apache Software Foundation. All Rights Reserved.