Class UdpTransport
java.lang.Object
org.apache.activemq.util.ServiceSupport
org.apache.activemq.transport.TransportSupport
org.apache.activemq.transport.TransportThreadSupport
org.apache.activemq.transport.udp.UdpTransport
- Direct Known Subclasses:
MulticastTransport
An implementation of the
Transport
interface using raw UDP-
Constructor Summary
ModifierConstructorDescriptionprotected
UdpTransport
(OpenWireFormat wireFormat) UdpTransport
(OpenWireFormat wireFormat, int port) Used by the server transportUdpTransport
(OpenWireFormat wireFormat, SocketAddress socketAddress) UdpTransport
(OpenWireFormat wireFormat, URI remoteLocation) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
bind
(DatagramSocket socket, SocketAddress localAddress) protected DatagramChannel
connect
(DatagramChannel channel, SocketAddress targetAddress2) protected InetSocketAddress
createAddress
(URI remoteLocation) Creates an address from the given URIprotected CommandChannel
protected CommandChannel
protected DatagramHeaderMarshaller
protected SocketAddress
Creates a replayer for working with the reliable transportprotected void
doStart()
protected void
doStop
(ServiceStopper stopper) protected DatagramChannel
int
int
int
getPort()
protected String
protected String
int
Returns a counter which gets incremented as data is read from the transport.protected SocketAddress
Retrieves the WireFormat instance associated with this Transport instance.boolean
boolean
isTrace()
boolean
void
A one way asynchronous sendvoid
oneway
(Object command, SocketAddress address) A one way asynchronous send to a given addressprotected String
resolveHostName
(String host) void
run()
reads packets from a Socketvoid
setBufferPool
(ByteBufferPool bufferPool) protected void
setChannel
(DatagramChannel channel) void
setCommandChannel
(CommandDatagramChannel commandChannel) Sets the implementation of the command channel to use.void
setDatagramSize
(int datagramSize) void
setMinmumWireFormatVersion
(int minmumWireFormatVersion) void
setPeerCertificates
(X509Certificate[] certificates) Sets the certificates provided by the connected peer.void
setPort
(int port) Sets the port to connect onvoid
setReplayBuffer
(ReplayBuffer replayBuffer) void
setReplayEnabled
(boolean replayEnabled) Sets whether or not replay should be enabled when using the reliable transport. i.e. should we maintain a buffer of messages that can be replayed?void
setReplayStrategy
(ReplayStrategy replayStrategy) Sets the strategy used to replay missed datagramsvoid
setSequenceGenerator
(IntSequenceGenerator sequenceGenerator) void
setTargetEndpoint
(Endpoint newTarget) We have received the WireFormatInfo from the server on the actual channel we should use for all future communication with the server, so lets set the target to be the actual channel that the server has chosen for us to talk on.void
setTrace
(boolean trace) void
setUseLocalHost
(boolean useLocalHost) Sets whether 'localhost' or the actual local host name should be used to make local connections.toString()
Methods inherited from class org.apache.activemq.transport.TransportThreadSupport
getStackSize, isDaemon, setDaemon, setStackSize
Methods inherited from class org.apache.activemq.transport.TransportSupport
asyncRequest, checkStarted, doConsume, getTransportListener, isConnected, isDisposed, isFaultTolerant, isReconnectSupported, isUpdateURIsSupported, narrow, onException, reconnect, request, request, setTransportListener, updateURIs
Methods inherited from class org.apache.activemq.util.ServiceSupport
addServiceListener, dispose, isStarted, isStopped, isStopping, postStop, preStart, removeServiceListener, start, stop
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.activemq.transport.Transport
asyncRequest, getTransportListener, isConnected, isDisposed, isFaultTolerant, isReconnectSupported, isUpdateURIsSupported, narrow, reconnect, request, request, setTransportListener, updateURIs
-
Constructor Details
-
UdpTransport
- Throws:
IOException
-
UdpTransport
public UdpTransport(OpenWireFormat wireFormat, URI remoteLocation) throws UnknownHostException, IOException - Throws:
UnknownHostException
IOException
-
UdpTransport
- Throws:
IOException
-
UdpTransport
Used by the server transport- Throws:
UnknownHostException
IOException
-
-
Method Details
-
createReplayer
Creates a replayer for working with the reliable transport- Throws:
IOException
-
oneway
A one way asynchronous send- Specified by:
oneway
in interfaceTransport
- Throws:
IOException
-
oneway
A one way asynchronous send to a given address- Throws:
IOException
-
toString
-
run
public void run()reads packets from a Socket -
setTargetEndpoint
We have received the WireFormatInfo from the server on the actual channel we should use for all future communication with the server, so lets set the target to be the actual channel that the server has chosen for us to talk on. -
isTrace
public boolean isTrace() -
setTrace
public void setTrace(boolean trace) -
getDatagramSize
public int getDatagramSize() -
setDatagramSize
public void setDatagramSize(int datagramSize) -
isUseLocalHost
public boolean isUseLocalHost() -
setUseLocalHost
public void setUseLocalHost(boolean useLocalHost) Sets whether 'localhost' or the actual local host name should be used to make local connections. On some operating systems such as Macs its not possible to connect as the local host name so localhost is better. -
getCommandChannel
- Throws:
IOException
-
setCommandChannel
Sets the implementation of the command channel to use. -
getReplayStrategy
-
setReplayStrategy
Sets the strategy used to replay missed datagrams -
getPort
public int getPort() -
setPort
public void setPort(int port) Sets the port to connect on -
getMinmumWireFormatVersion
public int getMinmumWireFormatVersion() -
setMinmumWireFormatVersion
public void setMinmumWireFormatVersion(int minmumWireFormatVersion) -
getWireFormat
Description copied from interface:Transport
Retrieves the WireFormat instance associated with this Transport instance.- Specified by:
getWireFormat
in interfaceTransport
- Returns:
- the WireFormat in use.
-
getSequenceGenerator
-
setSequenceGenerator
-
isReplayEnabled
public boolean isReplayEnabled() -
setReplayEnabled
public void setReplayEnabled(boolean replayEnabled) Sets whether or not replay should be enabled when using the reliable transport. i.e. should we maintain a buffer of messages that can be replayed? -
getBufferPool
-
setBufferPool
-
getReplayBuffer
-
setReplayBuffer
- Throws:
IOException
-
createAddress
protected InetSocketAddress createAddress(URI remoteLocation) throws UnknownHostException, IOException Creates an address from the given URI- Throws:
UnknownHostException
IOException
-
resolveHostName
- Throws:
UnknownHostException
-
doStart
- Overrides:
doStart
in classTransportThreadSupport
- Throws:
Exception
-
createCommandChannel
- Throws:
IOException
-
createCommandDatagramChannel
-
bind
- Throws:
IOException
-
connect
protected DatagramChannel connect(DatagramChannel channel, SocketAddress targetAddress2) throws IOException - Throws:
IOException
-
createLocalAddress
-
doStop
- Specified by:
doStop
in classServiceSupport
- Throws:
Exception
-
createDatagramHeaderMarshaller
-
getProtocolName
-
getProtocolUriScheme
-
getTargetAddress
-
getChannel
-
setChannel
-
getLocalSocketAddress
-
getRemoteAddress
- Specified by:
getRemoteAddress
in interfaceTransport
- Returns:
- the remote address for this connection
-
getReceiveCounter
public int getReceiveCounter()Description copied from interface:Transport
Returns a counter which gets incremented as data is read from the transport. It should only be used to determine if there is progress being made in reading the next command from the transport. The value may wrap into the negative numbers.- Specified by:
getReceiveCounter
in interfaceTransport
- Returns:
- a counter which gets incremented as data is read from the transport.
-
getPeerCertificates
- Specified by:
getPeerCertificates
in interfaceTransport
- Returns:
- the Certificates provided by the peer, or null if not a secure channel.
-
setPeerCertificates
Description copied from interface:Transport
Sets the certificates provided by the connected peer.- Specified by:
setPeerCertificates
in interfaceTransport
- Parameters:
certificates
- the Certificates provided by the peer.
-