Class AmqpConsumer

java.lang.Object
org.apache.qpid.jms.provider.amqp.AmqpAbstractResource<JmsConsumerInfo,org.apache.qpid.proton.engine.Receiver>
org.apache.qpid.jms.provider.amqp.AmqpConsumer
All Implemented Interfaces:
AmqpEventSink, AmqpResource

public class AmqpConsumer extends AmqpAbstractResource<JmsConsumerInfo,org.apache.qpid.proton.engine.Receiver>
AMQP Consumer object that is used to manage JMS MessageConsumer semantics.
  • Field Details

    • session

      protected final AmqpSession session
    • acknowledgementMode

      protected final int acknowledgementMode
    • stopRequest

      protected AsyncResult stopRequest
    • pullRequest

      protected AsyncResult pullRequest
    • incomingSequence

      protected long incomingSequence
    • deliveredCount

      protected int deliveredCount
    • dispatchedCount

      protected int dispatchedCount
    • deferredClose

      protected boolean deferredClose
  • Constructor Details

    • AmqpConsumer

      public AmqpConsumer(AmqpSession session, JmsConsumerInfo info, org.apache.qpid.proton.engine.Receiver receiver)
  • Method Details

    • close

      public void close(AsyncResult request)
      Overrides:
      close in class AmqpAbstractResource<JmsConsumerInfo,org.apache.qpid.proton.engine.Receiver>
    • start

      public void start(AsyncResult request)
      Starts the consumer by setting the link credit to the given prefetch value.
      Parameters:
      request - The request that awaits completion of the consumer start.
    • stop

      public void stop(AsyncResult request)
      Stops the consumer, using all link credit and waiting for in-flight messages to arrive.
      Parameters:
      request - The request that awaits completion of the consumer stop.
    • processFlowUpdates

      public void processFlowUpdates(AmqpProvider provider) throws ProviderException
      Description copied from interface: AmqpEventSink
      Called when the Proton Engine signals an Flow related event has been triggered for the given endpoint.
      Specified by:
      processFlowUpdates in interface AmqpEventSink
      Overrides:
      processFlowUpdates in class AmqpAbstractResource<JmsConsumerInfo,org.apache.qpid.proton.engine.Receiver>
      Parameters:
      provider - the AmqpProvider instance for easier access to fire events.
      Throws:
      ProviderException - if an error occurs while processing the update.
    • acknowledge

      public void acknowledge(ProviderConstants.ACK_TYPE ackType)
      Called to acknowledge all messages that have been marked as delivered but have not yet been marked consumed. Usually this is called as part of an client acknowledge session operation. Only messages that have already been acknowledged as delivered by the JMS framework will be in the delivered Map. This means that the link credit would already have been given for these so we just need to settle them.
      Parameters:
      ackType - the type of acknowledgement to perform
    • acknowledge

      public void acknowledge(JmsInboundMessageDispatch envelope, ProviderConstants.ACK_TYPE ackType)
      Called to acknowledge a given delivery.
      Parameters:
      envelope - the delivery that is to be acknowledged.
      ackType - the type of acknowledgement to perform.
    • recover

      public void recover() throws Exception
      Recovers all previously delivered but not acknowledged messages.
      Throws:
      Exception - if an error occurs while performing the recover.
    • pull

      public void pull(long timeout, AsyncResult request)
      Request a remote peer send a Message to this client. timeout < 0 then it should remain open until a message is received. timeout = 0 then it returns a message or null if none available timeout > 0 then it should remain open for timeout amount of time. The timeout value when positive is given in milliseconds.
      Parameters:
      timeout - the amount of time to tell the remote peer to keep this pull request valid.
      request - the asynchronous request object waiting to be notified of the pull having completed.
    • processDeliveryUpdates

      public void processDeliveryUpdates(AmqpProvider provider, org.apache.qpid.proton.engine.Delivery delivery) throws ProviderException
      Description copied from interface: AmqpEventSink
      Called when the Proton Engine signals an Delivery related event has been triggered for the given endpoint.
      Specified by:
      processDeliveryUpdates in interface AmqpEventSink
      Overrides:
      processDeliveryUpdates in class AmqpAbstractResource<JmsConsumerInfo,org.apache.qpid.proton.engine.Receiver>
      Parameters:
      provider - the AmqpProvider instance for easier access to fire events.
      delivery - the Delivery that has an update to its state which needs handled.
      Throws:
      ProviderException - if an error occurs while processing the update.
    • getNextIncomingSequenceNumber

      protected long getNextIncomingSequenceNumber()
    • closeOrDetachEndpoint

      protected void closeOrDetachEndpoint()
      Description copied from class: AmqpAbstractResource
      Perform the close operation on the managed endpoint. A subclass may override this method to alter the standard close path such as endpoint detach etc.
      Overrides:
      closeOrDetachEndpoint in class AmqpAbstractResource<JmsConsumerInfo,org.apache.qpid.proton.engine.Receiver>
    • getConnection

      public AmqpConnection getConnection()
    • getSession

      public AmqpSession getSession()
    • getConsumerId

      public JmsConsumerId getConsumerId()
    • getDestination

      public JmsDestination getDestination()
    • isStopping

      public boolean isStopping()
    • getDrainTimeout

      public int getDrainTimeout()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • deliver

      protected void deliver(JmsInboundMessageDispatch envelope) throws Exception
      Throws:
      Exception
    • preCommit

      public void preCommit()
    • preRollback

      public void preRollback()
    • postCommit

      public void postCommit()
    • postRollback

      public void postRollback()
    • handleResourceClosure

      public void handleResourceClosure(AmqpProvider provider, ProviderException cause)
      Overrides:
      handleResourceClosure in class AmqpAbstractResource<JmsConsumerInfo,org.apache.qpid.proton.engine.Receiver>