Package org.apache.pekko.io
Class UdpMessage
- java.lang.Object
-
- org.apache.pekko.io.UdpMessage
-
public class UdpMessage extends java.lang.ObjectJava API: factory methods for the message types used when communicating with the Udp service.
-
-
Constructor Summary
Constructors Constructor Description UdpMessage()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Udp.Commandbind(ActorRef handler, java.net.InetSocketAddress endpoint)Bind without specifying options.static Udp.Commandbind(ActorRef handler, java.net.InetSocketAddress endpoint, java.lang.Iterable<Inet.SocketOption> options)Send this message to theUdpExt.manager()in order to bind to the given local port (or an automatically assigned one if the port number is zero).static Udp.NoAcknoAck()DefaultUdp.NoAckinstance which is used when no acknowledgment information is explicitly provided.static Udp.NoAcknoAck(java.lang.Object token)EachUdp.Sendcan optionally request a positive acknowledgment to be sent to the commanding actor.static Udp.CommandresumeReading()This message must be sent to the listener actor to re-enable reading from the socket after aUdp.SuspendReadingcommand.static Udp.Commandsend(ByteString payload, java.net.InetSocketAddress target)The same assend(payload, target, noAck()).static Udp.Commandsend(ByteString payload, java.net.InetSocketAddress target, Udp.Event ack)This message is understood by the “simple sender” which can be obtained by sending theUdp.SimpleSenderquery to theUdpExt.manager()as well as by the listener actors which are created in response toUdp.Bind.static Udp.CommandsimpleSender()Retrieve a simple sender without specifying options.static Udp.CommandsimpleSender(java.lang.Iterable<Inet.SocketOption> options)Retrieve a reference to a “simple sender” actor of the UDP extension.static Udp.CommandsuspendReading()Send this message to a listener actor (which sent aUdp.Boundmessage) to have it stop reading datagrams from the network.static Udp.Commandunbind()Send this message to the listener actor that previously sent aUdp.Boundmessage in order to close the listening socket.
-
-
-
Method Detail
-
noAck
public static Udp.NoAck noAck(java.lang.Object token)
EachUdp.Sendcan optionally request a positive acknowledgment to be sent to the commanding actor. If such notification is not desired theUdp.Send.ack()must be set to an instance of this class. The token contained within can be used to recognize which write failed when receiving aUdp.CommandFailedmessage.
-
noAck
public static Udp.NoAck noAck()
DefaultUdp.NoAckinstance which is used when no acknowledgment information is explicitly provided. Its “token” isnull.
-
send
public static Udp.Command send(ByteString payload, java.net.InetSocketAddress target, Udp.Event ack)
This message is understood by the “simple sender” which can be obtained by sending theUdp.SimpleSenderquery to theUdpExt.manager()as well as by the listener actors which are created in response toUdp.Bind. It will send the given payload data as one UDP datagram to the given target address. The UDP actor will respond withUdp.CommandFailedif the send could not be enqueued to the O/S kernel because the send buffer was full. If the givenackis not of typeUdp.NoAckthe UDP actor will reply with the given object as soon as the datagram has been successfully enqueued to the O/S kernel.The sending UDP socket’s address belongs to the “simple sender” which does not handle inbound datagrams and sends from an ephemeral port; therefore sending using this mechanism is not suitable if replies are expected, use
Udp.Bindin that case.
-
send
public static Udp.Command send(ByteString payload, java.net.InetSocketAddress target)
The same assend(payload, target, noAck()).
-
bind
public static Udp.Command bind(ActorRef handler, java.net.InetSocketAddress endpoint, java.lang.Iterable<Inet.SocketOption> options)
Send this message to theUdpExt.manager()in order to bind to the given local port (or an automatically assigned one if the port number is zero). The listener actor for the newly bound port will reply with aUdp.Boundmessage, or the manager will reply with aUdp.CommandFailedmessage.
-
bind
public static Udp.Command bind(ActorRef handler, java.net.InetSocketAddress endpoint)
Bind without specifying options.
-
unbind
public static Udp.Command unbind()
Send this message to the listener actor that previously sent aUdp.Boundmessage in order to close the listening socket. The recipient will reply with anUdp.Unboundmessage.
-
simpleSender
public static Udp.Command simpleSender(java.lang.Iterable<Inet.SocketOption> options)
Retrieve a reference to a “simple sender” actor of the UDP extension. The newly created “simple sender” will reply with theUdp.SimpleSenderReadynotification.The “simple sender” is a convenient service for being able to send datagrams when the originating address is meaningless, i.e. when no reply is expected.
The “simple sender” will not stop itself, you will have to send it a
pekko.actor.PoisonPillwhen you want to close the socket.
-
simpleSender
public static Udp.Command simpleSender()
Retrieve a simple sender without specifying options.
-
suspendReading
public static Udp.Command suspendReading()
Send this message to a listener actor (which sent aUdp.Boundmessage) to have it stop reading datagrams from the network. If the O/S kernel’s receive buffer runs full then subsequent datagrams will be silently discarded. Re-enable reading from the socket using theUdp.ResumeReadingcommand.
-
resumeReading
public static Udp.Command resumeReading()
This message must be sent to the listener actor to re-enable reading from the socket after aUdp.SuspendReadingcommand.
-
-