Interface GearmanPacket

  • All Known Implementing Classes:
    GearmanPacketImpl

    public interface GearmanPacket
    A GearmanPacket represents an indvidual message that can either be sent to a Gearman Job Server or received from a Gearman Job Server.
     A GearmanPacket consists of three components:
    
     - The Packet Magic: The component that identifies the message as a gearman
                         message and is used to determine if the message is a
                         request message (REQ) or a response message (RES).
    
     - The Packet Type:  The component that indentifies operations specified by
                         the message.
    
     - The Packet Data:  The payload of the message, the exact structure of which
                         depends on the packet type.
     
    • Method Detail

      • getPacketType

        GearmanPacketType getPacketType()
        Retrieves the event type for this packet.
        Returns:
        event type.
      • toBytes

        byte[] toBytes()
        Retrieves the Packet as a series of bytes. Typicall called when about to send the packet over a GearmanJobServerConnection.
        Returns:
        a byte array representing the packet.
      • getData

        byte[] getData()
        Retrieves the payload, if any, associated with this packet.
        Returns:
        payload
      • getDataComponentValue

        byte[] getDataComponentValue​(GearmanPacket.DataComponentName component)
        The data or payload of a packet can contain different set of components depending on the type of packet. Clients of the packet class may want to extract these components from the message payload. This method provides a means for clients to extract the component without requiring knowledge of the format of the payload.
        Parameters:
        component - The name of the component to be extracted.
        Returns:
        the value of the specified component. Should return an empty array if the component is not contained the packet.
      • requiresResponse

        boolean requiresResponse()
        Determine if the packet represents a request message that requires a responses from the server. There are certain request messages that logically require a response, for example the GRAB_JOB message should result in a JOB_ASSIGN or NO_JOB reply from the server. While there are other messages that do not, such as CAN_DO.
        Returns:
        true if this packet represents a request message that requires a response, else returns false.