|
Spring Integration | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.integration.context.IntegrationObjectSupport org.springframework.integration.handler.AbstractMessageHandler org.springframework.integration.ip.AbstractInternetProtocolSendingMessageHandler org.springframework.integration.ip.udp.UnicastSendingMessageHandler
public class UnicastSendingMessageHandler
A 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.
Field Summary | |
---|---|
protected Map<String,CountDownLatch> |
ackControl
|
protected int |
ackCounter
|
protected boolean |
acknowledge
|
protected int |
ackPort
|
protected int |
ackTimeout
|
protected Exception |
fatalException
|
protected String |
localAddress
|
protected DatagramPacketMessageMapper |
mapper
|
protected DatagramSocket |
socket
|
protected int |
soReceiveBufferSize
|
protected Executor |
taskExecutor
|
protected boolean |
waitForAck
If true adds headers to instruct receiving adapter to return an ack. |
Fields inherited from class org.springframework.integration.ip.AbstractInternetProtocolSendingMessageHandler |
---|
destinationAddress, host, logger, port, soSendBufferSize, soTimeout |
Fields inherited from interface org.springframework.core.Ordered |
---|
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE |
Constructor Summary | |
---|---|
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. |
Method Summary | |
---|---|
protected DatagramSocket |
getSocket()
|
void |
handleMessageInternal(Message<?> message)
|
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 |
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 |
setSocketAttributes(DatagramSocket socket)
|
void |
setSoReceiveBufferSize(int size)
|
void |
setTaskExecutor(Executor taskExecutor)
|
void |
shutDown()
|
Methods inherited from class org.springframework.integration.ip.AbstractInternetProtocolSendingMessageHandler |
---|
getPort, setSoSendBufferSize, setSoTimeout |
Methods inherited from class org.springframework.integration.handler.AbstractMessageHandler |
---|
getComponentType, getOrder, handleMessage, setOrder, setShouldTrack |
Methods inherited from class org.springframework.integration.context.IntegrationObjectSupport |
---|
afterPropertiesSet, getBeanFactory, getComponentName, getConversionService, getRequiredMetadataPersister, getTaskScheduler, setBeanFactory, setBeanName, setComponentName, setConversionService, setTaskScheduler, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.springframework.integration.context.NamedComponent |
---|
getComponentName |
Field Detail |
---|
protected final DatagramPacketMessageMapper mapper
protected volatile DatagramSocket socket
protected volatile boolean waitForAck
protected volatile boolean acknowledge
protected volatile int ackPort
protected volatile int ackTimeout
protected volatile int ackCounter
protected volatile Map<String,CountDownLatch> ackControl
protected volatile Exception fatalException
protected int soReceiveBufferSize
protected String localAddress
protected volatile Executor taskExecutor
Constructor Detail |
---|
public 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.Method Detail |
---|
protected void setReliabilityAttributes(boolean lengthCheck, boolean acknowledge, String ackHost, int ackPort, int ackTimeout)
public void onInit()
IntegrationObjectSupport
onInit
in class IntegrationObjectSupport
public void handleMessageInternal(Message<?> message) throws MessageRejectedException, MessageHandlingException, MessageDeliveryException
handleMessageInternal
in class AbstractMessageHandler
MessageRejectedException
MessageHandlingException
MessageDeliveryException
protected void send(DatagramPacket packet) throws Exception
Exception
protected DatagramSocket getSocket() throws IOException
IOException
protected void setSocketAttributes(DatagramSocket socket) throws SocketException
SocketException
public void run()
run
in interface Runnable
public void restartAckThread()
public void shutDown()
public void setSoReceiveBufferSize(int size)
setSoReceiveBufferSize
in interface CommonSocketOptions
setSoReceiveBufferSize
in class AbstractInternetProtocolSendingMessageHandler
Socket.setReceiveBufferSize(int)
,
DatagramSocket.setReceiveBufferSize(int)
public void setLocalAddress(String localAddress)
CommonSocketOptions
setLocalAddress
in interface CommonSocketOptions
public void setTaskExecutor(Executor taskExecutor)
|
Spring Integration | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |