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 Summary
Fields Modifier and Type Field Description protected intacknowledgementModeprotected booleandeferredCloseprotected intdeliveredCountprotected intdispatchedCountprotected longincomingSequenceprotected AsyncResultpullRequestprotected AmqpSessionsessionprotected AsyncResultstopRequest-
Fields inherited from class org.apache.qpid.jms.provider.amqp.AmqpAbstractResource
closeRequest, closeTimeoutTask
-
-
Constructor Summary
Constructors Constructor Description AmqpConsumer(AmqpSession session, JmsConsumerInfo info, org.apache.qpid.proton.engine.Receiver receiver)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidacknowledge(JmsInboundMessageDispatch envelope, ProviderConstants.ACK_TYPE ackType)Called to acknowledge a given delivery.voidacknowledge(ProviderConstants.ACK_TYPE ackType)Called to acknowledge all messages that have been marked as delivered but have not yet been marked consumed.voidclose(AsyncResult request)protected voidcloseOrDetachEndpoint()Perform the close operation on the managed endpoint.protected voiddeliver(JmsInboundMessageDispatch envelope)AmqpConnectiongetConnection()JmsConsumerIdgetConsumerId()JmsDestinationgetDestination()intgetDrainTimeout()protected longgetNextIncomingSequenceNumber()AmqpSessiongetSession()voidhandleResourceClosure(AmqpProvider provider, ProviderException cause)booleanisStopping()voidpostCommit()voidpostRollback()voidpreCommit()voidpreRollback()voidprocessDeliveryUpdates(AmqpProvider provider, org.apache.qpid.proton.engine.Delivery delivery)Called when the Proton Engine signals an Delivery related event has been triggered for the given endpoint.voidprocessFlowUpdates(AmqpProvider provider)Called when the Proton Engine signals an Flow related event has been triggered for the given endpoint.voidpull(long timeout, AsyncResult request)Request a remote peer send a Message to this client.voidrecover()Recovers all previously delivered but not acknowledged messages.voidstart(AsyncResult request)Starts the consumer by setting the link credit to the given prefetch value.voidstop(AsyncResult request)Stops the consumer, using all link credit and waiting for in-flight messages to arrive.java.lang.StringtoString()-
Methods inherited from class org.apache.qpid.jms.provider.amqp.AmqpAbstractResource
closeResource, getEndpoint, getLocalState, getParent, getRemoteState, getResourceInfo, isAwaitingClose, isClosed, isOpen, processRemoteClose, processRemoteDetach, processRemoteOpen
-
-
-
-
Field Detail
-
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 Detail
-
AmqpConsumer
public AmqpConsumer(AmqpSession session, JmsConsumerInfo info, org.apache.qpid.proton.engine.Receiver receiver)
-
-
Method Detail
-
close
public void close(AsyncResult request)
- Overrides:
closein classAmqpAbstractResource<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:AmqpEventSinkCalled when the Proton Engine signals an Flow related event has been triggered for the given endpoint.- Specified by:
processFlowUpdatesin interfaceAmqpEventSink- Overrides:
processFlowUpdatesin classAmqpAbstractResource<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 java.lang.ExceptionRecovers all previously delivered but not acknowledged messages.- Throws:
java.lang.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:AmqpEventSinkCalled when the Proton Engine signals an Delivery related event has been triggered for the given endpoint.- Specified by:
processDeliveryUpdatesin interfaceAmqpEventSink- Overrides:
processDeliveryUpdatesin classAmqpAbstractResource<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:AmqpAbstractResourcePerform 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:
closeOrDetachEndpointin classAmqpAbstractResource<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 java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
deliver
protected void deliver(JmsInboundMessageDispatch envelope) throws java.lang.Exception
- Throws:
java.lang.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:
handleResourceClosurein classAmqpAbstractResource<JmsConsumerInfo,org.apache.qpid.proton.engine.Receiver>
-
-