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
FieldsModifier and TypeFieldDescriptionprotected final intprotected booleanprotected intprotected intprotected longprotected AsyncResultprotected final AmqpSessionprotected AsyncResultFields inherited from class org.apache.qpid.jms.provider.amqp.AmqpAbstractResource
closeRequest, closeTimeoutTask -
Constructor Summary
ConstructorsConstructorDescriptionAmqpConsumer(AmqpSession session, JmsConsumerInfo info, org.apache.qpid.proton.engine.Receiver receiver) -
Method Summary
Modifier and TypeMethodDescriptionvoidacknowledge(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 voidPerform the close operation on the managed endpoint.protected voiddeliver(JmsInboundMessageDispatch envelope) intprotected longvoidhandleResourceClosure(AmqpProvider provider, ProviderException cause) booleanvoidvoidvoidvoidvoidprocessDeliveryUpdates(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.toString()Methods inherited from class org.apache.qpid.jms.provider.amqp.AmqpAbstractResource
closeResource, getEndpoint, getLocalState, getParent, getRemoteState, getResourceInfo, isAwaitingClose, isClosed, isOpen, processRemoteClose, processRemoteDetach, processRemoteOpen
-
Field Details
-
session
-
acknowledgementMode
protected final int acknowledgementMode -
stopRequest
-
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
- Overrides:
closein classAmqpAbstractResource<JmsConsumerInfo,org.apache.qpid.proton.engine.Receiver>
-
start
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
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
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
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
Called to acknowledge a given delivery.- Parameters:
envelope- the delivery that is to be acknowledged.ackType- the type of acknowledgement to perform.
-
recover
Recovers all previously delivered but not acknowledged messages.- Throws:
Exception- if an error occurs while performing the recover.
-
pull
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
-
getSession
-
getConsumerId
-
getDestination
-
isStopping
public boolean isStopping() -
getDrainTimeout
public int getDrainTimeout() -
toString
-
deliver
- Throws:
Exception
-
preCommit
public void preCommit() -
preRollback
public void preRollback() -
postCommit
public void postCommit() -
postRollback
public void postRollback() -
handleResourceClosure
- Overrides:
handleResourceClosurein classAmqpAbstractResource<JmsConsumerInfo,org.apache.qpid.proton.engine.Receiver>
-