Class HonoProtonHelper


  • public final class HonoProtonHelper
    extends Object
    Utility methods for working with Proton objects.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static long DEFAULT_FREE_LINK_AFTER_CLOSE_INTERVAL_MILLIS
      The default number of milliseconds to wait for a remote peer to send a detach frame after client closed a link.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void closeAndFree​(io.vertx.core.Context context, io.vertx.proton.ProtonLink<?> link, long detachTimeOut, io.vertx.core.Handler<Void> closeHandler)
      Closes an AMQP link and frees up its allocated resources.
      static void closeAndFree​(io.vertx.core.Context context, io.vertx.proton.ProtonLink<?> link, io.vertx.core.Handler<Void> closeHandler)
      Closes an AMQP link and frees up its allocated resources.
      static <T> io.vertx.core.Future<T> executeOnContext​(io.vertx.core.Context requiredContext, io.vertx.core.Handler<io.vertx.core.Promise<T>> codeToRun)
      Executes some code on a given context.
      static boolean isLinkEstablished​(io.vertx.proton.ProtonLink<?> link)
      Checks if a link is established.
      static <T extends io.vertx.proton.ProtonLink<T>>
      io.vertx.core.Handler<io.vertx.core.AsyncResult<T>>
      setCloseHandler​(io.vertx.proton.ProtonLink<T> link, io.vertx.core.Handler<io.vertx.core.AsyncResult<T>> handler)
      Sets a handler on a link that is invoked when an AMQP detach frame with its close property set to true is received from the peer.
      static <T extends io.vertx.proton.ProtonLink<T>>
      void
      setDefaultCloseHandler​(io.vertx.proton.ProtonLink<T> link)
      Sets a default handler on a link that is invoked when an AMQP detach frame with its close property set to true is received from the peer.
      static void setDefaultCloseHandler​(io.vertx.proton.ProtonSession session)
      Sets a default handler on a session that is invoked when an AMQP end frame is received from the peer.
      static <T extends io.vertx.proton.ProtonLink<T>>
      io.vertx.core.Handler<io.vertx.core.AsyncResult<T>>
      setDetachHandler​(io.vertx.proton.ProtonLink<T> link, io.vertx.core.Handler<io.vertx.core.AsyncResult<T>> handler)
      Sets a handler on a link that is invoked when an AMQP detach frame with its close property set to false is received from the peer.
    • Field Detail

      • DEFAULT_FREE_LINK_AFTER_CLOSE_INTERVAL_MILLIS

        public static final long DEFAULT_FREE_LINK_AFTER_CLOSE_INTERVAL_MILLIS
        The default number of milliseconds to wait for a remote peer to send a detach frame after client closed a link.
        See Also:
        Constant Field Values
    • Method Detail

      • setDetachHandler

        public static <T extends io.vertx.proton.ProtonLink<T>> io.vertx.core.Handler<io.vertx.core.AsyncResult<T>> setDetachHandler​(io.vertx.proton.ProtonLink<T> link,
                                                                                                                                     io.vertx.core.Handler<io.vertx.core.AsyncResult<T>> handler)
        Sets a handler on a link that is invoked when an AMQP detach frame with its close property set to false is received from the peer.

        The resources maintained for the link will be freed up after the given handler has been invoked.

        Type Parameters:
        T - The type of link.
        Parameters:
        link - The link to set the handler on.
        handler - The handler to invoke.
        Returns:
        The wrapper that has been created around the given handler.
        Throws:
        NullPointerException - if link or handler are null.
      • setCloseHandler

        public static <T extends io.vertx.proton.ProtonLink<T>> io.vertx.core.Handler<io.vertx.core.AsyncResult<T>> setCloseHandler​(io.vertx.proton.ProtonLink<T> link,
                                                                                                                                    io.vertx.core.Handler<io.vertx.core.AsyncResult<T>> handler)
        Sets a handler on a link that is invoked when an AMQP detach frame with its close property set to true is received from the peer.

        The resources maintained for the link will be freed up after the given handler has been invoked.

        Type Parameters:
        T - The type of link.
        Parameters:
        link - The link to set the handler on.
        handler - The handler to invoke.
        Returns:
        The wrapper that has been created around the given handler.
        Throws:
        NullPointerException - if link or handler are null.
      • setDefaultCloseHandler

        public static <T extends io.vertx.proton.ProtonLink<T>> void setDefaultCloseHandler​(io.vertx.proton.ProtonLink<T> link)
        Sets a default handler on a link that is invoked when an AMQP detach frame with its close property set to true is received from the peer.

        The default handler sends a detach frame if the link has not been closed locally already and then frees up the resources maintained for the link by invoking its free method.

        Type Parameters:
        T - The type of link.
        Parameters:
        link - The link to set the handler on.
        Throws:
        NullPointerException - if link is null.
      • setDefaultCloseHandler

        public static void setDefaultCloseHandler​(io.vertx.proton.ProtonSession session)
        Sets a default handler on a session that is invoked when an AMQP end frame is received from the peer.

        The default handler sends an end frame and then frees up the resources maintained for the session by invoking its free method.

        Parameters:
        session - The session to set the handler on.
        Throws:
        NullPointerException - if session is null.
      • isLinkEstablished

        public static boolean isLinkEstablished​(io.vertx.proton.ProtonLink<?> link)
        Checks if a link is established.
        Parameters:
        link - The link to check.
        Returns:
        true if the link has been established.
      • executeOnContext

        public static <T> io.vertx.core.Future<T> executeOnContext​(io.vertx.core.Context requiredContext,
                                                                   io.vertx.core.Handler<io.vertx.core.Promise<T>> codeToRun)
        Executes some code on a given context.
        Type Parameters:
        T - The type of the result that the code produces.
        Parameters:
        requiredContext - The context to run the code on.
        codeToRun - The code to execute. The code is required to either complete or fail the promise that is passed into the handler.
        Returns:
        The future containing the result of the promise passed in to the handler for executing the code. The future thus indicates the outcome of executing the code. The future will always be failed if the required context is null.
      • closeAndFree

        public static void closeAndFree​(io.vertx.core.Context context,
                                        io.vertx.proton.ProtonLink<?> link,
                                        io.vertx.core.Handler<Void> closeHandler)
        Closes an AMQP link and frees up its allocated resources.

        This method simply invokes closeAndFree(Context, ProtonLink, long, Handler) with the default time-out value.

        Parameters:
        context - The vert.x context to run on.
        link - The link to close. If null, the given handler is invoked immediately.
        closeHandler - The handler to notify once the link has been closed.
        Throws:
        NullPointerException - if context or close handler are null.
      • closeAndFree

        public static void closeAndFree​(io.vertx.core.Context context,
                                        io.vertx.proton.ProtonLink<?> link,
                                        long detachTimeOut,
                                        io.vertx.core.Handler<Void> closeHandler)
        Closes an AMQP link and frees up its allocated resources.

        This method will invoke the given handler as soon as

        • the peer's detach frame has been received or
        • the given number of milliseconds have passed
        After that the link's resources are freed up.

        Parameters:
        context - The vert.x context to run on.
        link - The link to close. If null, the given handler is invoked immediately.
        detachTimeOut - The maximum number of milliseconds to wait for the peer's detach frame or 0, if this method should wait indefinitely for the peer's detach frame.
        closeHandler - The handler to notify once the link has been closed.
        Throws:
        NullPointerException - if context or close handler are null.
        IllegalArgumentException - if detach time-out is < 0.