Class ServerConsumerImpl
java.lang.Object
org.apache.activemq.artemis.core.server.impl.ServerConsumerImpl
- All Implemented Interfaces:
PriorityAware,Consumer,ConsumerInfo,ServerConsumer,ReadyListener
Concrete implementation of a ClientConsumer.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ServerConsumerImpl.BrowserDelivererprotected final Objectprotected final Queue -
Constructor Summary
ConstructorsConstructorDescriptionServerConsumerImpl(long id, ServerSession session, QueueBinding binding, Filter filter, boolean started, boolean browseOnly, StorageManager storageManager, SessionCallback callback, boolean preAcknowledge, boolean strictUpdateDeliveryCount, ManagementService managementService, boolean supportLargeMessage, Integer credits, ActiveMQServer server) ServerConsumerImpl(long id, ServerSession session, QueueBinding binding, Filter filter, boolean started, boolean browseOnly, StorageManager storageManager, SessionCallback callback, boolean preAcknowledge, boolean strictUpdateDeliveryCount, ManagementService managementService, ActiveMQServer server) ServerConsumerImpl(long id, ServerSession session, QueueBinding binding, Filter filter, int priority, boolean started, boolean browseOnly, StorageManager storageManager, SessionCallback callback, boolean preAcknowledge, boolean strictUpdateDeliveryCount, ManagementService managementService, boolean supportLargeMessage, Integer credits, ActiveMQServer server) -
Method Summary
Modifier and TypeMethodDescriptionacknowledge(Transaction tx, long messageID) voidaddAttachment(String key, Object attachment) Adds the given attachment to theServerConsumerwhich will overwrite any previously assigned value with the same key.booleanThe current queue settings will allow use of the Reference Execution and callback.voidbackToDelivering(MessageReference reference) Some protocols may choose to send the message back to delivering instead of redeliver.cancelRefs(boolean failed, boolean lastConsumedAsDelivered, Transaction tx) voidclose(boolean failed) debug()voiddisconnect the consumervoiderrorProcessing(Throwable e, MessageReference deliveryObject) voidvoidvoidforceDelivery(long sequence) Prompt delivery and send a "forced delivery" message to the consumer.voidforceDelivery(long sequence, Runnable r) getAttachment(String key) Gets any attachment that has been assigned to thisServerConsumerusing the provided key.To be used on tests onlyReturns a string representation of the local IP address this connection is connected to; useful when the server is configured at0.0.0.0(or multiple IPs).Returns the name of the protocol for this Remoting Connection.Returns a string representation of the remote address this connection is connected to.longlonggetID()longReturns the time in milliseconds that the last message was acknowledged by a consumer.longReturns the time in milliseconds that the last message was delivered to a consumer.longReturns the number of messages acknowledged by this consumer since it was created.intReturns the number of acknowledged messages that are awaiting commit an a transaction.longReturns the total number of messages sent to a consumer including redeliveries that have been acknowledged.longReturns the total size of all the messages delivered to the consumer including redelivered messages.intReturns how many messages are out for delivery but not yet acknowledged.longReturns the combined size of all the messages out for delivery but not yet acknowledged.intAn object set by the Protocol implementation. it could be anything pre-determined by the implementationthis is to be used with anything specific on a protocol head.getQueue()Returns address of the queue that is being consumed.Returns name of the queue that is being consumed.Returns routing type of the queue that is being consumed.floatgetRate()longan unique sequential ID for this consumerhandle(MessageReference ref) There was a change on semantic during 2.3 here.voidindividualAcknowledge(Transaction tx, long messageID) voidindividualCancel(long messageID, boolean failed) booleanbooleanisClosed()voidmetricsAcknowledge(MessageReference ref, Transaction transaction) This is needed when some protocols (OW) handle the acks themselves and need to update the metricsvoidproceedDeliver(MessageReference reference) This will proceed with the actual delivery.voidwakes up internal threads to deliver more messagesvoidvoidreceiveCredits(int credits) voidreject(long messageID) voidremoveAttachment(String key) Remove the any attachment entry from theServerConsumerclearing any previously assigned valuevoidThis method is just to remove itself from Queues.removeReferenceByID(long messageID) scanDeliveringReferences(boolean remove, Function<MessageReference, Boolean> startFunction, Function<MessageReference, Boolean> endFunction) Remove references based on the protocolData.longan unique sequential ID for this consumervoidvoidsetPreAcknowledge(boolean preAcknowledge) voidsetProtocolContext(Object protocolContext) voidsetProtocolData(Object protocolData) this is to be used with anything specific on a protocol head.voidsetStarted(boolean started) voidsetTransferring(boolean transferring) booleanWhether thisConsumersupports direct delivery.This method will create a string representation meant for management operations.toString()protected voidupdateDeliveryCountForCanceledRef(MessageReference ref, boolean failed)
-
Field Details
-
messageQueue
-
lock
-
browserDeliverer
-
-
Constructor Details
-
ServerConsumerImpl
public ServerConsumerImpl(long id, ServerSession session, QueueBinding binding, Filter filter, boolean started, boolean browseOnly, StorageManager storageManager, SessionCallback callback, boolean preAcknowledge, boolean strictUpdateDeliveryCount, ManagementService managementService, ActiveMQServer server) throws Exception - Throws:
Exception
-
ServerConsumerImpl
public ServerConsumerImpl(long id, ServerSession session, QueueBinding binding, Filter filter, boolean started, boolean browseOnly, StorageManager storageManager, SessionCallback callback, boolean preAcknowledge, boolean strictUpdateDeliveryCount, ManagementService managementService, boolean supportLargeMessage, Integer credits, ActiveMQServer server) throws Exception - Throws:
Exception
-
ServerConsumerImpl
public ServerConsumerImpl(long id, ServerSession session, QueueBinding binding, Filter filter, int priority, boolean started, boolean browseOnly, StorageManager storageManager, SessionCallback callback, boolean preAcknowledge, boolean strictUpdateDeliveryCount, ManagementService managementService, boolean supportLargeMessage, Integer credits, ActiveMQServer server) throws Exception - Throws:
Exception
-
-
Method Details
-
debug
-
isClosed
public boolean isClosed() -
readyForWriting
public void readyForWriting()- Specified by:
readyForWritingin interfaceReadyListener
-
allowReferenceCallback
public boolean allowReferenceCallback()Description copied from interface:ServerConsumerThe current queue settings will allow use of the Reference Execution and callback.- Specified by:
allowReferenceCallbackin interfaceServerConsumer
-
sequentialID
public long sequentialID()Description copied from interface:Consumeran unique sequential ID for this consumer- Specified by:
sequentialIDin interfaceConsumer
-
getProtocolData
Description copied from interface:ServerConsumerthis is to be used with anything specific on a protocol head.- Specified by:
getProtocolDatain interfaceServerConsumer
-
setProtocolData
Description copied from interface:ServerConsumerthis is to be used with anything specific on a protocol head.- Specified by:
setProtocolDatain interfaceServerConsumer
-
setlowConsumerDetection
- Specified by:
setlowConsumerDetectionin interfaceServerConsumer
-
getSlowConsumerDetecion
- Specified by:
getSlowConsumerDetecionin interfaceServerConsumer
-
fireSlowConsumer
public void fireSlowConsumer()- Specified by:
fireSlowConsumerin interfaceServerConsumer
-
getProtocolContext
Description copied from interface:ServerConsumerAn object set by the Protocol implementation. it could be anything pre-determined by the implementation- Specified by:
getProtocolContextin interfaceServerConsumer
-
setProtocolContext
- Specified by:
setProtocolContextin interfaceServerConsumer
-
getID
public long getID()- Specified by:
getIDin interfaceServerConsumer
-
isBrowseOnly
public boolean isBrowseOnly()- Specified by:
isBrowseOnlyin interfaceServerConsumer
-
getCreationTime
public long getCreationTime()- Specified by:
getCreationTimein interfaceServerConsumer
-
getConnectionID
- Specified by:
getConnectionIDin interfaceServerConsumer
-
getSessionID
- Specified by:
getSessionIDin interfaceServerConsumer
-
metricsAcknowledge
Description copied from interface:ServerConsumerThis is needed when some protocols (OW) handle the acks themselves and need to update the metrics- Specified by:
metricsAcknowledgein interfaceServerConsumer- Parameters:
ref- the message referencetransaction- the tx
-
getDeliveringMessages
- Specified by:
getDeliveringMessagesin interfaceConsumer
-
supportsDirectDelivery
public boolean supportsDirectDelivery()Description copied from interface:ConsumerWhether thisConsumersupports direct delivery.- Specified by:
supportsDirectDeliveryin interfaceConsumer- See Also:
-
errorProcessing
- Specified by:
errorProcessingin interfaceConsumer
-
handle
Description copied from interface:ConsumerThere was a change on semantic during 2.3 here.We now first accept the message, and the actual deliver is done as part of
Consumer.proceedDeliver(MessageReference). This is to avoid holding a lock on the queues while the delivery is being accomplished To avoid a lock on the queue in case of misbehaving consumers.This should return busy if handle is called before proceed deliver is called
-
proceedDeliver
Description copied from interface:ConsumerThis will proceed with the actual delivery. Notice that handle should hold a readLock and proceedDelivery should release the readLock any lock operation on Consumer should also get a writeLock on the readWriteLock to guarantee there are no pending deliveries- Specified by:
proceedDeliverin interfaceConsumer- Throws:
Exception
-
getBinding
- Specified by:
getBindingin interfaceConsumer
-
getFilter
-
getPriority
public int getPriority()- Specified by:
getPriorityin interfaceConsumer- Specified by:
getPriorityin interfacePriorityAware
-
getFilterString
- Specified by:
getFilterStringin interfaceConsumerInfo
-
close
- Specified by:
closein interfaceServerConsumer- Throws:
Exception
-
removeItself
Description copied from interface:ServerConsumerThis method is just to remove itself from Queues. If for any reason during a close an exception occurred, the exception treatment will call removeItself what should take the consumer out of any queues.- Specified by:
removeItselfin interfaceServerConsumer- Throws:
Exception
-
forceDelivery
public void forceDelivery(long sequence) Prompt delivery and send a "forced delivery" message to the consumer.When the consumer receives such a "forced delivery" message, it discards it and knows that there are no other messages to be delivered.
- Specified by:
forceDeliveryin interfaceServerConsumer
-
forceDelivery
-
cancelRefs
public List<MessageReference> cancelRefs(boolean failed, boolean lastConsumedAsDelivered, Transaction tx) throws Exception - Specified by:
cancelRefsin interfaceServerConsumer- Throws:
Exception
-
updateDeliveryCountForCanceledRef
-
setStarted
public void setStarted(boolean started) - Specified by:
setStartedin interfaceServerConsumer
-
setTransferring
public void setTransferring(boolean transferring) - Specified by:
setTransferringin interfaceServerConsumer
-
receiveCredits
public void receiveCredits(int credits) - Specified by:
receiveCreditsin interfaceServerConsumer
-
getQueue
- Specified by:
getQueuein interfaceServerConsumer
-
scanDeliveringReferences
public List<MessageReference> scanDeliveringReferences(boolean remove, Function<MessageReference, Boolean> startFunction, Function<MessageReference, Boolean> endFunction) Remove references based on the protocolData. There will be an interval defined between protocolDataStart and protocolDataEnd. This method will fetch the delivering references, remove them from the delivering list and return a list.This will be useful for other protocols that will need this such as OpenWire or MQTT.
- Specified by:
scanDeliveringReferencesin interfaceServerConsumer
-
acknowledge
- Specified by:
acknowledgein interfaceServerConsumer- Throws:
Exception
-
individualAcknowledge
- Specified by:
individualAcknowledgein interfaceServerConsumer- Throws:
Exception
-
individualCancel
- Specified by:
individualCancelin interfaceServerConsumer- Throws:
Exception
-
reject
- Specified by:
rejectin interfaceServerConsumer- Throws:
Exception
-
backToDelivering
Description copied from interface:ServerConsumerSome protocols may choose to send the message back to delivering instead of redeliver. For example openwire will redeliver through the client, so messages will go back to delivering list after rollback.- Specified by:
backToDeliveringin interfaceServerConsumer
-
removeReferenceByID
- Specified by:
removeReferenceByIDin interfaceServerConsumer- Throws:
Exception
-
getAvailableCredits
To be used on tests only -
toString
-
toManagementString
Description copied from interface:ConsumerThis method will create a string representation meant for management operations. This is different from the toString method that's meant for debugging and will contain information that regular users won't understand well- Specified by:
toManagementStringin interfaceConsumer
-
disconnect
public void disconnect()Description copied from interface:Consumerdisconnect the consumer- Specified by:
disconnectin interfaceConsumer
-
failed
-
getRate
public float getRate() -
promptDelivery
public void promptDelivery()Description copied from interface:Consumerwakes up internal threads to deliver more messages- Specified by:
promptDeliveryin interfaceConsumer
-
setPreAcknowledge
public void setPreAcknowledge(boolean preAcknowledge) -
getSequentialID
public long getSequentialID()Description copied from interface:ConsumerInfoan unique sequential ID for this consumer- Specified by:
getSequentialIDin interfaceConsumerInfo
-
getQueueName
Description copied from interface:ConsumerInfoReturns name of the queue that is being consumed.- Specified by:
getQueueNamein interfaceConsumerInfo- Returns:
- name of the queue that is being consumed
-
getQueueType
Description copied from interface:ConsumerInfoReturns routing type of the queue that is being consumed.- Specified by:
getQueueTypein interfaceConsumerInfo- Returns:
- routing type of the queue that is being consumed
-
getQueueAddress
Description copied from interface:ConsumerInfoReturns address of the queue that is being consumed.- Specified by:
getQueueAddressin interfaceConsumerInfo- Returns:
- address of the queue that is being consumed
-
getSessionName
- Specified by:
getSessionNamein interfaceConsumerInfo
-
getConnectionClientID
- Specified by:
getConnectionClientIDin interfaceConsumerInfo
-
getConnectionProtocolName
Description copied from interface:ConsumerInfoReturns the name of the protocol for this Remoting Connection.- Specified by:
getConnectionProtocolNamein interfaceConsumerInfo- Returns:
- the name of the protocol for this Remoting Connection
-
getConnectionLocalAddress
Description copied from interface:ConsumerInfoReturns a string representation of the local IP address this connection is connected to; useful when the server is configured at0.0.0.0(or multiple IPs).- Specified by:
getConnectionLocalAddressin interfaceConsumerInfo- Returns:
- a string representation of the local IP address this connection is connected to; useful when the server
is configured at
0.0.0.0(or multiple IPs)
-
getConnectionRemoteAddress
Description copied from interface:ConsumerInfoReturns a string representation of the remote address this connection is connected to.- Specified by:
getConnectionRemoteAddressin interfaceConsumerInfo- Returns:
- a string representation of the remote address this connection is connected to
-
getMessagesInTransitSize
public long getMessagesInTransitSize()Description copied from interface:ConsumerInfoReturns the combined size of all the messages out for delivery but not yet acknowledged.- Specified by:
getMessagesInTransitSizein interfaceConsumerInfo- Returns:
- the combined size of all the messages out for delivery but not yet acknowledged
-
getMessagesInTransit
public int getMessagesInTransit()Description copied from interface:ConsumerInfoReturns how many messages are out for delivery but not yet acknowledged.- Specified by:
getMessagesInTransitin interfaceConsumerInfo- Returns:
- how many messages are out for delivery but not yet acknowledged
-
getLastDeliveredTime
public long getLastDeliveredTime()Description copied from interface:ConsumerInfoReturns the time in milliseconds that the last message was delivered to a consumer.- Specified by:
getLastDeliveredTimein interfaceConsumerInfo- Returns:
- the time in milliseconds that the last message was delivered to a consumer
-
getLastAcknowledgedTime
public long getLastAcknowledgedTime()Description copied from interface:ConsumerInfoReturns the time in milliseconds that the last message was acknowledged by a consumer.- Specified by:
getLastAcknowledgedTimein interfaceConsumerInfo- Returns:
- the time in milliseconds that the last message was acknowledged by a consumer
-
getMessagesAcknowledged
public long getMessagesAcknowledged()Description copied from interface:ConsumerInfoReturns the number of messages acknowledged by this consumer since it was created.- Specified by:
getMessagesAcknowledgedin interfaceConsumerInfo- Returns:
- the number of messages acknowledged by this consumer since it was created
-
getMessagesDeliveredSize
public long getMessagesDeliveredSize()Description copied from interface:ConsumerInfoReturns the total size of all the messages delivered to the consumer including redelivered messages.- Specified by:
getMessagesDeliveredSizein interfaceConsumerInfo- Returns:
- the total size of all the messages delivered to the consumer including redelivered messages
-
getMessagesDelivered
public long getMessagesDelivered()Description copied from interface:ConsumerInfoReturns the total number of messages sent to a consumer including redeliveries that have been acknowledged.- Specified by:
getMessagesDeliveredin interfaceConsumerInfo- Returns:
- the total number of messages sent to a consumer including redeliveries that have been acknowledged
-
getMessagesAcknowledgedAwaitingCommit
public int getMessagesAcknowledgedAwaitingCommit()Description copied from interface:ConsumerInfoReturns the number of acknowledged messages that are awaiting commit an a transaction.- Specified by:
getMessagesAcknowledgedAwaitingCommitin interfaceConsumerInfo- Returns:
- the number of acknowledged messages that are awaiting commit an a transaction
-
getCallback
-
addAttachment
Description copied from interface:ServerConsumerAdds the given attachment to theServerConsumerwhich will overwrite any previously assigned value with the same key.- Specified by:
addAttachmentin interfaceServerConsumer- Parameters:
key- The key used to identify the attachment.attachment- The actual value to store for the assigned key.
-
removeAttachment
Description copied from interface:ServerConsumerRemove the any attachment entry from theServerConsumerclearing any previously assigned value- Specified by:
removeAttachmentin interfaceServerConsumer- Parameters:
key- The key used to identify the attachment.
-
getAttachment
Description copied from interface:ServerConsumerGets any attachment that has been assigned to thisServerConsumerusing the provided key. If no value was assigned a null is returned.- Specified by:
getAttachmentin interfaceServerConsumer- Parameters:
key- The key identifying the target attachment.- Returns:
- the assigned value associated with the given key or null if nothing assigned.
-
getAttachments
Description copied from interface:ServerConsumerProvides access to the fullMapof consumer attachments in an unmodifiableMapinstance. If no attachments are assigned to the consumer an emptyMapinstance is returned, never null.- Specified by:
getAttachmentsin interfaceServerConsumer- Returns:
- an unmodifiable
Mapthat carries all consumer attachments.
-