Class AMQPFederationConsumer
- All Implemented Interfaces:
FederationConsumer
- Direct Known Subclasses:
AMQPFederationAddressConsumer, AMQPFederationQueueConsumer
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final AtomicBooleanprotected final AMQPFederationConsumerConfigurationprotected final AMQPConnectionContextprotected final FederationConsumerInfoprotected static final org.apache.qpid.proton.amqp.messaging.Modifiedprotected final AMQPFederationprotected booleanprotected static final AtomicLongprotected final AMQPFederationLocalPolicyManagerprotected final AMQPFederationMetrics.ConsumerMetricsprotected static final org.apache.qpid.proton.amqp.Symbol[]protected org.apache.qpid.proton.engine.Receiverprotected ProtonAbstractReceiverprotected Consumer<AMQPFederationConsumer> protected final Predicate<org.apache.qpid.proton.engine.Link> protected Consumer<AMQPFederationConsumer> protected final AMQPSessionContextprotected final org.apache.activemq.artemis.core.server.transformer.Transformer -
Constructor Summary
ConstructorsConstructorDescriptionAMQPFederationConsumer(AMQPFederationLocalPolicyManager manager, AMQPFederationConsumerConfiguration configuration, AMQPSessionContext session, FederationConsumerInfo consumerInfo, FederationReceiveFromResourcePolicy policy, AMQPFederationMetrics.ConsumerMetrics metrics) -
Method Summary
Modifier and TypeMethodDescriptionfinal voidclose()Close the federation consumer instance and cleans up its resources.protected abstract voidCalled during the initialization of the consumer to trigger an asynchronous link attach of the underlying AMQP receiver that backs this federation consumer.Returns the consumer configuration that was assigned to this federation consumer.final FederationConsumerInfoReturns an information object that defines the characteristics of theFederationConsumer.final AMQPFederationReturns theFederationthat this consumer operates under.final longReturns the number of messages this consumer has received from the remote during its lifetime.Returns the federation policy manager that created this consumer instance.abstract intReturns the idle timeout value that is used applied to quiesced receivers.getRole()Returns the type of federation consumer being represented.voidCalled to initialize the AMQP federation consumer which will trigger an asynchronous task to attach the link and handle all setup receiver and eventually start the flow of credit to the remote.booleanisClosed()Returnstrueif the receiver has already been closed.final booleanReturnstrueif the consumer has previously been initialized.protected final voidrecordFederatedMessageReceived(Message message) Called from a subclass upon handling an incoming federated message from the remote.protected final booleanremoteLinkClosedInterceptor(org.apache.qpid.proton.engine.Link link) final AMQPFederationConsumerProvides and event point for notification of the consumer having been closed by the remote.final AMQPFederationConsumerProvides and event point for notification of the receiver having been opened successfully by the remote.protected final voidCalled after the message is dispatched to the broker for processing.protected final voidCalled before the message is dispatched to the broker for processing.final voidAsynchronously starts a previously stopped federation consumer which should trigger a grant of credit to the remote thereby allowing new incoming messages to be federated.final voidstopAsync(AMQPFederationAsyncCompletion<AMQPFederationConsumer> completion) Stops message consumption on this consumer instance but leaves the consumer in a state where it could be restarted by a call tostartAsync(AMQPFederationAsyncCompletion)once the consumer enters the stopped state.
-
Field Details
-
OUTCOMES
protected static final org.apache.qpid.proton.amqp.Symbol[] OUTCOMES -
DEFAULT_OUTCOME
protected static final org.apache.qpid.proton.amqp.messaging.Modified DEFAULT_OUTCOME -
LINK_SEQUENCE_ID
-
manager
-
federation
-
configuration
-
consumerInfo
-
connection
-
session
-
remoteCloseInterceptor
-
transformer
protected final org.apache.activemq.artemis.core.server.transformer.Transformer transformer -
closed
-
metrics
-
initialized
protected volatile boolean initialized -
receiver
-
protonReceiver
protected org.apache.qpid.proton.engine.Receiver protonReceiver -
remoteOpenHandler
-
remoteCloseHandler
-
-
Constructor Details
-
AMQPFederationConsumer
public AMQPFederationConsumer(AMQPFederationLocalPolicyManager manager, AMQPFederationConsumerConfiguration configuration, AMQPSessionContext session, FederationConsumerInfo consumerInfo, FederationReceiveFromResourcePolicy policy, AMQPFederationMetrics.ConsumerMetrics metrics)
-
-
Method Details
-
getRole
Returns the type of federation consumer being represented.- Returns:
- the type of federation consumer being represented
-
getMessagesReceived
public final long getMessagesReceived()Returns the number of messages this consumer has received from the remote during its lifetime.- Returns:
- the number of messages this consumer has received from the remote during its lifetime
-
getPolicyManager
Returns the federation policy manager that created this consumer instance.- Returns:
- the federation policy manager that created this consumer instance
-
getConfiguration
Returns the consumer configuration that was assigned to this federation consumer.- Returns:
- the consumer configuration that was assigned to this federation consumer
-
getReceiverIdleTimeout
public abstract int getReceiverIdleTimeout()Returns the idle timeout value that is used applied to quiesced receivers.- Returns:
- the idle timeout value that is used applied to quiesced receivers
-
getFederation
Description copied from interface:FederationConsumerReturns theFederationthat this consumer operates under.- Specified by:
getFederationin interfaceFederationConsumer- Returns:
- the
Federationthat this consumer operates under
-
getConsumerInfo
Description copied from interface:FederationConsumerReturns an information object that defines the characteristics of theFederationConsumer.- Specified by:
getConsumerInfoin interfaceFederationConsumer- Returns:
- an information object that defines the characteristics of the
FederationConsumer
-
isInitialized
public final boolean isInitialized()Returnstrueif the consumer has previously been initialized.- Returns:
trueif the consumer has previously been initialized
-
initialize
public void initialize()Called to initialize the AMQP federation consumer which will trigger an asynchronous task to attach the link and handle all setup receiver and eventually start the flow of credit to the remote. This method should be called once after the basic configuration of the consumer is complete and should not be called again after that. -
doCreateReceiver
protected abstract void doCreateReceiver()Called during the initialization of the consumer to trigger an asynchronous link attach of the underlying AMQP receiver that backs this federation consumer. The new receiver should be initialized in a started state. This method executes on the connection thread and should not block. This method will be called from the thread of the connection this consumer operates on. -
startAsync
Asynchronously starts a previously stopped federation consumer which should trigger a grant of credit to the remote thereby allowing new incoming messages to be federated. In general the start should only happen when the receiver is know to be stopped but given the asynchronous nature of the receiver handling this won't always be the case, below the outcomes of various cases that could result from calls to this method. The completion methods are always called from a different thread than this method is called in which means the caller should ensure that the handling accounts for thread safety of those methods.Calling start on an already closed consumer should immediately throw an
IllegalStateExceptionimmediately. Calling start on an non-initialized consumer should immediately throw anIllegalStateExceptionimmediately.Calling start on a stopped consumer should start the consumer and signal success to the completion. Calling start on an already started consumer should simply signal success to the completion. Calling start on a stopping consumer should fail the completion with an
IllegalStateException. Calling start on a consumer that closes while the start is in-flight should fail the completion with anIllegalStateException- Parameters:
completion- AAMQPFederationAsyncCompletionthat will be notified when the stop request succeeds or fails.
-
stopAsync
Stops message consumption on this consumer instance but leaves the consumer in a state where it could be restarted by a call tostartAsync(AMQPFederationAsyncCompletion)once the consumer enters the stopped state.Since the request to stop can take time to complete and this method cannot block a completion must be provided by the caller that will respond when the consumer has fully come to rest and all pending work is complete. Before the stopped completion is signaled the state of the underlying consumer will be stopping and attempt to restart it should fail until the stopped state has been reached.
The supplied
AMQPFederationAsyncCompletionwill be completed successfully once the underling AMQP receiver has drained and pending work is completed. If the stop does not complete by the supplied timeout the completion will be signaled that a failure has occurred with aTimeoutException. The completion methods are always called from a different thread than this method is called in which means the caller should ensure that the handling accounts for thread safety of those methods.- Parameters:
completion- AAMQPFederationAsyncCompletionthat will be notified when the stop request succeeds or fails.
-
close
public final void close()Close the federation consumer instance and cleans up its resources. This method should not block and the actual resource shutdown work should occur asynchronously however the closed state should be indicated immediately and any further attempts start the consumer should result in an exception being thrown. -
isClosed
public boolean isClosed()Returnstrueif the receiver has already been closed.- Returns:
trueif the receiver has already been closed
-
setRemoteOpenHandler
Provides and event point for notification of the receiver having been opened successfully by the remote. This handler will not be called if the remote rejects the link attach and aDetachis expected to follow.- Parameters:
handler- The handler that will be invoked when the remote opens this receiver.- Returns:
- this receiver instance
-
setRemoteClosedHandler
public final AMQPFederationConsumer setRemoteClosedHandler(Consumer<AMQPFederationConsumer> handler) Provides and event point for notification of the consumer having been closed by the remote.- Parameters:
handler- The handler that will be invoked when the remote closes this consumer.- Returns:
- this consumer instance
-
remoteLinkClosedInterceptor
protected final boolean remoteLinkClosedInterceptor(org.apache.qpid.proton.engine.Link link) -
recordFederatedMessageReceived
Called from a subclass upon handling an incoming federated message from the remote.- Parameters:
message- The original message that arrived from the remote.
-
signalPluginBeforeFederationConsumerMessageHandled
protected final void signalPluginBeforeFederationConsumerMessageHandled(Message message) throws ActiveMQException Called before the message is dispatched to the broker for processing.- Parameters:
message- The message after any processing which is about to be dispatched.- Throws:
ActiveMQException- if any broker plugin throws an exception during its processing.
-
signalPluginAfterFederationConsumerMessageHandled
protected final void signalPluginAfterFederationConsumerMessageHandled(Message message) throws ActiveMQException Called after the message is dispatched to the broker for processing.- Parameters:
message- The message after any processing which has been dispatched to the broker.- Throws:
ActiveMQException- if any broker plugin throws an exception during its processing.
-