Class AMQPBridgeReceiver

java.lang.Object
org.apache.activemq.artemis.protocol.amqp.connect.bridge.AMQPBridgeReceiver
All Implemented Interfaces:
Closeable, AutoCloseable
Direct Known Subclasses:
AMQPBridgeFromAddressReceiver, AMQPBridgeFromQueueReceiver

public abstract class AMQPBridgeReceiver extends Object implements Closeable
Base implementation for AMQP Bridge receiver implementations
  • Field Details

  • Constructor Details

  • Method Details

    • getReceiverIdleTimeout

      public abstract int getReceiverIdleTimeout()
      Returns the idle timeout value that is used applied to quiesced receivers.
      Returns:
      the idle timeout value that is used applied to quiesced receivers
    • isClosed

      public boolean isClosed()
      }@return true if the receiver has already been closed}
    • getRole

      public final org.apache.activemq.artemis.protocol.amqp.connect.bridge.AMQPBridgeReceiverInfo.ReceiverRole getRole()
      Returns the type of bridge receiver being represented.
      Returns:
      the type of bridge receiver being represented
    • getPolicyManager

      public final AMQPBridgeFromPolicyManager getPolicyManager()
      Returns the bridge from policy manager that owns this bridge receiver.
      Returns:
      the bridge from policy manager that owns this bridge receiver
    • getMessagesReceived

      public final long getMessagesReceived()
      Returns the number of messages this consumer has received from the remote during its lifetime.
      Returns:
      the number of messages this consumer has received from the remote during its lifetime
    • isInitialized

      public final boolean isInitialized()
      Returns true if the receiver has previously been initialized.
      Returns:
      true if the receiver has previously been initialized
    • initialize

      public void initialize()
      Called to initialize the AMQP bridge receiver which will trigger an asynchronous task to attach the link and handle all setup receiver and eventually start the flow of credit to the remote. This method should be called once after the basic configuration of the receiver is complete and should not be called again after that.
    • doCreateReceiver

      protected abstract void doCreateReceiver()
      Called during the initialization of the receiver to trigger an asynchronous link attach of the underlying AMQP receiver that backs this bridgeManager receiver. The new receiver should be initialized in a started state. This method executes on the connection thread and should not block. This method will be called from the thread of the connection this receiver operates on.
    • startAsync

      public final void startAsync(AMQPBridgeAsyncCompletion<AMQPBridgeReceiver> completion)
      Asynchronously starts a previously stopped bridgeManager receiver which should trigger a grant of credit to the remote thereby allowing new incoming messages to be bridged. In general the start should only happen when the receiver is known to be stopped but given the asynchronous nature of the receiver handling this won't always be the case, below the outcomes of various cases that could result from calls to this method. The completion methods are always called from a different thread than this method is called in which means the caller should ensure that the handling accounts for thread safety of those methods.

      Calling start on an already closed receiver should immediately throw an IllegalStateException. Calling start on an non-initialized receiver should immediately throw an IllegalStateException.

      Calling start on a stopped receiver should start the receiver and signal success to the completion. Calling start on an already started receiver should simply signal success to the completion. Calling start on a stopping receiver should fail the completion with an IllegalStateException. Calling start on a receiver that closes while the start is in-flight should fail the completion with an IllegalStateException

      Parameters:
      completion - A AMQPBridgeAsyncCompletion that will be notified when the stop request succeeds or fails.
    • stopAsync

      public final void stopAsync(AMQPBridgeAsyncCompletion<AMQPBridgeReceiver> completion)
      Stops message consumption on this receiver instance but leaves the receiver in a state where it could be restarted by a call to startAsync(AMQPBridgeAsyncCompletion) once the receiver enters the stopped state.

      Since the request to stop can take time to complete and this method cannot block a completion must be provided by the caller that will respond when the receiver has fully come to rest and all pending work is complete. Before the stopped completion is signaled the state of the underlying receiver will be stopping and attempt to restart it should fail until the stopped state has been reached.

      The supplied AMQPBridgeAsyncCompletion will be completed successfully once the underling AMQP receiver has drained and pending work is completed. If the stop does not complete by the supplied timeout the completion will be signaled that a failure has occurred with a TimeoutException. The completion methods are always called from a different thread than this method is called in which means the caller should ensure that the handling accounts for thread safety of those methods.

      Parameters:
      completion - A AMQPBridgeAsyncCompletion that will be notified when the stop request succeeds or fails.
    • close

      public final void close()
      Close the bridgeManager receiver instance and cleans up its resources. This method should not block and the actual resource shutdown work should occur asynchronously however the closed state should be indicated immediately and any further attempts start the consumer should result in an exception being thrown.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
    • getPolicy

      public AMQPBridgePolicy getPolicy()
      (@return the policy that this sender was configured to use)
    • getBridgeManager

      public final AMQPBridgeManager getBridgeManager()
      (@return the AMQPBridgeManager that this receiver operates under)
    • getReceiverInfo

      public final AMQPBridgeReceiverInfo getReceiverInfo()
      Returns an information object that defines the characteristics of the AMQPBridgeReceiver.
      Returns:
      an information object that defines the characteristics of the AMQPBridgeReceiver
    • setRemoteOpenHandler

      public final AMQPBridgeReceiver setRemoteOpenHandler(Consumer<AMQPBridgeReceiver> handler)
      Provides and event point for notification of the receiver having been opened successfully by the remote. This handler will not be called if the remote rejects the link attach and a Detach is expected to follow.
      Parameters:
      handler - The handler that will be invoked when the remote opens this receiver.
      Returns:
      this receiver instance.
    • setRemoteClosedHandler

      public final AMQPBridgeReceiver setRemoteClosedHandler(Consumer<AMQPBridgeReceiver> handler)
      Provides and event point for notification of the receiver having been closed by the remote.
      Parameters:
      handler - The handler that will be invoked when the remote closes this receiver.
      Returns:
      this receiver instance.
    • recordMessageReceived

      protected final void recordMessageReceived(Message message)
      Called from a subclass upon handling an incoming message from the remote.
      Parameters:
      message - The original message that arrived from the remote.
    • getRemoteTerminusCapabilities

      protected final org.apache.qpid.proton.amqp.Symbol[] getRemoteTerminusCapabilities()
    • remoteLinkClosedInterceptor

      protected final boolean remoteLinkClosedInterceptor(org.apache.qpid.proton.engine.Link link)