Class ProtonAbstractReceiver
- java.lang.Object
-
- org.apache.activemq.artemis.protocol.amqp.proton.ProtonInitializable
-
- org.apache.activemq.artemis.protocol.amqp.proton.ProtonAbstractReceiver
-
- All Implemented Interfaces:
ProtonDeliveryHandler
- Direct Known Subclasses:
AMQPFederationCommandProcessor,AMQPMirrorControllerTarget,ProtonServerReceiverContext
public abstract class ProtonAbstractReceiver extends ProtonInitializable implements ProtonDeliveryHandler
-
-
Field Summary
Fields Modifier and Type Field Description protected AMQPConnectionContextconnectionprotected RunnablecreditRunnableprotected AMQPLargeMessagecurrentLargeMessageprotected intminLargeMessageSizeprotected intpendingSettlesprotected AMQPSessionContextprotonSessionprotected org.apache.qpid.proton.engine.Receiverreceiverprotected org.apache.activemq.artemis.core.server.RoutingContextroutingContextprotected AMQPSessionCallbacksessionSPIprotected booleanuseModified-
Fields inherited from class org.apache.activemq.artemis.protocol.amqp.proton.ProtonInitializable
initialized
-
-
Constructor Summary
Constructors Constructor Description ProtonAbstractReceiver(AMQPSessionCallback sessionSPI, AMQPConnectionContext connection, AMQPSessionContext protonSession, org.apache.qpid.proton.engine.Receiver receiver)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract voidactualDelivery(AMQPMessage message, org.apache.qpid.proton.engine.Delivery delivery, org.apache.qpid.proton.engine.Receiver receiver, org.apache.activemq.artemis.core.transaction.Transaction tx)static intcalculatedUpdateRefill(int refill, int credits, int pending)protected voidclearLargeMessage()voidclose(boolean remoteLinkClose)voidclose(org.apache.qpid.proton.amqp.transport.ErrorCondition condition)static RunnablecreateCreditRunnable(int refill, int threshold, org.apache.qpid.proton.engine.Receiver receiver, AMQPConnectionContext connection)This Credit Runnable can be used to manage the credit replenishment of a target AMQP receiver.static RunnablecreateCreditRunnable(int refill, int threshold, org.apache.qpid.proton.engine.Receiver receiver, AMQPConnectionContext connection, ProtonAbstractReceiver context)This Credit Runnable can be used to manage the credit replenishment of a target AMQP receiver.protected RunnablecreateCreditRunnable(AMQPConnectionContext connection)Subclass can override this to provide a custom credit runnable that performs other checks or applies credit in a manner more fitting that implementation.abstract voidflow()protected intgetConfiguredMinLargeMessageSize(AMQPConnectionContext connection)Subclass can override this to provide the minimum large message size that should be used when creating receiver instances.AMQPConnectionContextgetConnection()voidincrementSettle()protected voidinitializeCurrentLargeMessage(org.apache.qpid.proton.engine.Delivery delivery, org.apache.qpid.proton.engine.Receiver receiver)static booleanisBellowThreshold(int credit, int pending, int threshold)voidonFlow(int credits, boolean drain)voidonMessage(org.apache.qpid.proton.engine.Delivery delivery)protected voidrecoverContext()voidsettle(org.apache.qpid.proton.engine.Delivery settlement)-
Methods inherited from class org.apache.activemq.artemis.protocol.amqp.proton.ProtonInitializable
initialize, isInitialized
-
-
-
-
Field Detail
-
connection
protected final AMQPConnectionContext connection
-
protonSession
protected final AMQPSessionContext protonSession
-
receiver
protected final org.apache.qpid.proton.engine.Receiver receiver
-
minLargeMessageSize
protected final int minLargeMessageSize
-
routingContext
protected final org.apache.activemq.artemis.core.server.RoutingContext routingContext
-
sessionSPI
protected final AMQPSessionCallback sessionSPI
-
currentLargeMessage
protected volatile AMQPLargeMessage currentLargeMessage
-
creditRunnable
protected final Runnable creditRunnable
-
useModified
protected final boolean useModified
-
pendingSettles
protected int pendingSettles
-
-
Constructor Detail
-
ProtonAbstractReceiver
public ProtonAbstractReceiver(AMQPSessionCallback sessionSPI, AMQPConnectionContext connection, AMQPSessionContext protonSession, org.apache.qpid.proton.engine.Receiver receiver)
-
-
Method Detail
-
isBellowThreshold
public static boolean isBellowThreshold(int credit, int pending, int threshold)
-
calculatedUpdateRefill
public static int calculatedUpdateRefill(int refill, int credits, int pending)
-
recoverContext
protected void recoverContext()
-
clearLargeMessage
protected void clearLargeMessage()
-
createCreditRunnable
protected Runnable createCreditRunnable(AMQPConnectionContext connection)
Subclass can override this to provide a custom credit runnable that performs other checks or applies credit in a manner more fitting that implementation.- Parameters:
connection- TheAMQPConnectionContextthat this resource falls under.- Returns:
- a
Runnablethat will perform the actual credit granting operation.
-
getConfiguredMinLargeMessageSize
protected int getConfiguredMinLargeMessageSize(AMQPConnectionContext connection)
Subclass can override this to provide the minimum large message size that should be used when creating receiver instances.- Parameters:
connection- TheAMQPConnectionContextthat this resource falls under.- Returns:
- the minimum large message size configuration value for this receiver.
-
createCreditRunnable
public static Runnable createCreditRunnable(int refill, int threshold, org.apache.qpid.proton.engine.Receiver receiver, AMQPConnectionContext connection, ProtonAbstractReceiver context)
This Credit Runnable can be used to manage the credit replenishment of a target AMQP receiver.- Parameters:
refill- The number of credit to top off the receiver tothreshold- The low water mark for credit before refill is donereceiver- The proton receiver that will have its credit refilledconnection- The connection that own the receivercontext- The context that will be associated with the receiver- Returns:
- A new Runnable that can be used to keep receiver credit replenished.
-
createCreditRunnable
public static Runnable createCreditRunnable(int refill, int threshold, org.apache.qpid.proton.engine.Receiver receiver, AMQPConnectionContext connection)
This Credit Runnable can be used to manage the credit replenishment of a target AMQP receiver.This method is generally used for tests as it does not account for the receiver context that is assigned to the given receiver instance which does not allow for tracking pending settles.
- Parameters:
refill- The number of credit to top off the receiver tothreshold- The low water mark for credit before refill is donereceiver- The proton receiver that will have its credit refilledconnection- The connection that own the receiver- Returns:
- A new Runnable that can be used to keep receiver credit replenished.
-
incrementSettle
public void incrementSettle()
-
settle
public void settle(org.apache.qpid.proton.engine.Delivery settlement)
-
onFlow
public void onFlow(int credits, boolean drain)- Specified by:
onFlowin interfaceProtonDeliveryHandler
-
onMessage
public void onMessage(org.apache.qpid.proton.engine.Delivery delivery) throws ActiveMQAMQPException- Specified by:
onMessagein interfaceProtonDeliveryHandler- Throws:
ActiveMQAMQPException
-
initializeCurrentLargeMessage
protected void initializeCurrentLargeMessage(org.apache.qpid.proton.engine.Delivery delivery, org.apache.qpid.proton.engine.Receiver receiver) throws Exception- Throws:
Exception
-
close
public void close(boolean remoteLinkClose) throws ActiveMQAMQPException- Specified by:
closein interfaceProtonDeliveryHandler- Throws:
ActiveMQAMQPException
-
close
public void close(org.apache.qpid.proton.amqp.transport.ErrorCondition condition) throws ActiveMQAMQPException- Specified by:
closein interfaceProtonDeliveryHandler- Throws:
ActiveMQAMQPException
-
getConnection
public AMQPConnectionContext getConnection()
-
actualDelivery
protected abstract void actualDelivery(AMQPMessage message, org.apache.qpid.proton.engine.Delivery delivery, org.apache.qpid.proton.engine.Receiver receiver, org.apache.activemq.artemis.core.transaction.Transaction tx)
-
flow
public abstract void flow()
-
-