public class UnicastSendingMessageHandler extends AbstractInternetProtocolSendingMessageHandler implements Runnable
MessageHandler implementation that maps a Message into
a UDP datagram packet and sends that to the specified host and port.
Messages can be basic, with no support for reliability, can be prefixed
by a length so the receiving end can detect truncation, and can require
a UDP acknowledgment to confirm delivery.loggerHIGHEST_PRECEDENCE, LOWEST_PRECEDENCE| Constructor and Description |
|---|
UnicastSendingMessageHandler(String host,
int port)
Basic constructor; no reliability; no acknowledgment.
|
UnicastSendingMessageHandler(String host,
int port,
boolean lengthCheck)
Can used to add a length to each packet which can be checked at the destination.
|
UnicastSendingMessageHandler(String host,
int port,
boolean lengthCheck,
boolean acknowledge,
String ackHost,
int ackPort,
int ackTimeout)
Add a length and/or acknowledgment request to packets.
|
UnicastSendingMessageHandler(String host,
int port,
boolean acknowledge,
String ackHost,
int ackPort,
int ackTimeout)
Add an acknowledgment request to packets.
|
| Modifier and Type | Method and Description |
|---|---|
void |
doStart() |
protected void |
doStop() |
int |
getAckPort() |
String |
getComponentType()
Subclasses may implement this method to provide component type information.
|
protected DatagramSocket |
getSocket() |
int |
getSoReceiveBufferSize() |
protected DatagramSocket |
getTheSocket() |
void |
handleMessageInternal(Message<?> message) |
boolean |
isAcknowledge() |
protected void |
onInit()
Subclasses may implement this for initialization logic.
|
void |
restartAckThread()
If exposed as an MBean, can be used to restart the ack thread if a fatal
(bind) error occurred, without bouncing the JVM.
|
void |
run()
Process acknowledgments, if requested.
|
protected void |
send(DatagramPacket packet) |
void |
setAckCounter(int ackCounter) |
void |
setLocalAddress(String localAddress)
On a multi-homed system, specifies the ip address of the network interface used to communicate.
|
protected void |
setReliabilityAttributes(boolean lengthCheck,
boolean acknowledge,
String ackHost,
int ackPort,
int ackTimeout) |
protected void |
setSocket(DatagramSocket socket) |
protected void |
setSocketAttributes(DatagramSocket socket) |
void |
setSoReceiveBufferSize(int size) |
void |
setTaskExecutor(Executor taskExecutor) |
void |
shutDown()
Deprecated.
Use stop() instead.
|
getDestinationAddress, getHost, getPort, getSoSendBufferSize, getSoTimeout, isRunning, setSoSendBufferSize, setSoTimeout, start, stopconfigureMetrics, getActiveCount, getActiveCountLong, getDuration, getErrorCount, getErrorCountLong, getHandleCount, getHandleCountLong, getManagedName, getManagedType, getMaxDuration, getMeanDuration, getMinDuration, getOrder, getStandardDeviationDuration, handleMessage, isCountsEnabled, isLoggingEnabled, isStatsEnabled, reset, setCountsEnabled, setLoggingEnabled, setManagedName, setManagedType, setOrder, setShouldTrack, setStatsEnabledafterPropertiesSet, extractTypeIfPossible, getApplicationContext, getApplicationContextId, getBeanFactory, getChannelResolver, getComponentName, getConversionService, getIntegrationProperties, getIntegrationProperty, getMessageBuilderFactory, getTaskScheduler, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentName, setConversionService, setMessageBuilderFactory, setTaskScheduler, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetComponentNamepublic UnicastSendingMessageHandler(String host, int port)
host - Destination host.port - Destination port.public UnicastSendingMessageHandler(String host, int port, boolean lengthCheck)
host - Destination Host.port - Destination Port.lengthCheck - If true, packets will contain a length.public UnicastSendingMessageHandler(String host, int port, boolean acknowledge, String ackHost, int ackPort, int ackTimeout)
host - Destination Host.port - Destination Port.acknowledge - If true, packets will request acknowledgment.ackHost - The host to which acks should be sent. Required if ack true.ackPort - The port to which acks should be sent.ackTimeout - How long we will wait (milliseconds) for the ack.public UnicastSendingMessageHandler(String host, int port, boolean lengthCheck, boolean acknowledge, String ackHost, int ackPort, int ackTimeout)
host - Destination Host.port - Destination Port.lengthCheck - If true, packets will contain a length.acknowledge - If true, packets will request acknowledgment.ackHost - The host to which acks should be sent. Required if ack true.ackPort - The port to which acks should be sent.ackTimeout - How long we will wait (milliseconds) for the ack.protected final void setReliabilityAttributes(boolean lengthCheck,
boolean acknowledge,
String ackHost,
int ackPort,
int ackTimeout)
public void doStart()
doStart in class AbstractInternetProtocolSendingMessageHandlerprotected void doStop()
doStop in class AbstractInternetProtocolSendingMessageHandlerpublic void handleMessageInternal(Message<?> message) throws MessageRejectedException, MessageHandlingException, MessageDeliveryException
handleMessageInternal in class AbstractMessageHandlerMessageRejectedExceptionMessageHandlingExceptionMessageDeliveryExceptionprotected void send(DatagramPacket packet) throws Exception
Exceptionprotected void setSocket(DatagramSocket socket)
protected DatagramSocket getTheSocket()
protected DatagramSocket getSocket() throws IOException
IOExceptionpublic void setSoReceiveBufferSize(int size)
setSoReceiveBufferSize in interface CommonSocketOptionssetSoReceiveBufferSize in class AbstractInternetProtocolSendingMessageHandlersize - The receive buffer size.Socket.setReceiveBufferSize(int),
DatagramSocket.setReceiveBufferSize(int)public void setLocalAddress(String localAddress)
CommonSocketOptionssetLocalAddress in interface CommonSocketOptionslocalAddress - The local address.public void setTaskExecutor(Executor taskExecutor)
public void setAckCounter(int ackCounter)
ackCounter - the ackCounter to setpublic String getComponentType()
IntegrationObjectSupportgetComponentType in interface NamedComponentgetComponentType in class AbstractMessageHandlerpublic boolean isAcknowledge()
public int getAckPort()
public int getSoReceiveBufferSize()
protected void onInit()
throws Exception
IntegrationObjectSupportonInit in class AbstractMessageHandlerException - Any exception.protected void setSocketAttributes(DatagramSocket socket) throws SocketException
SocketExceptionpublic void run()
public void restartAckThread()
@Deprecated public void shutDown()