Class AMQPBridgeReceiver
- All Implemented Interfaces:
Closeable, AutoCloseable
- Direct Known Subclasses:
AMQPBridgeFromAddressReceiver, AMQPBridgeFromQueueReceiver
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final AMQPBridgeManagerprotected final AtomicBooleanprotected final AMQPBridgeReceiverConfigurationprotected final AMQPConnectionContextprotected static final org.apache.qpid.proton.amqp.messaging.Modifiedprotected booleanprotected static final AtomicLongprotected final AMQPBridgeMetrics.ReceiverMetricsprotected static final org.apache.qpid.proton.amqp.Symbol[]protected final AMQPBridgePolicyprotected final AMQPBridgeFromPolicyManagerprotected org.apache.qpid.proton.engine.Receiverprotected ProtonAbstractReceiverprotected final AMQPBridgeReceiverInfoprotected Consumer<AMQPBridgeReceiver> protected Consumer<AMQPBridgeReceiver> protected final AMQPSessionContextprotected final org.apache.activemq.artemis.core.server.transformer.Transformer -
Constructor Summary
ConstructorsConstructorDescriptionAMQPBridgeReceiver(AMQPBridgeFromPolicyManager policyManager, AMQPBridgeReceiverConfiguration configuration, AMQPSessionContext session, AMQPBridgeReceiverInfo receiverInfo, AMQPBridgePolicy policy, AMQPBridgeMetrics.ReceiverMetrics metrics) -
Method Summary
Modifier and TypeMethodDescriptionfinal voidclose()Close the bridgeManager receiver instance and cleans up its resources.protected abstract voidCalled during the initialization of the receiver to trigger an asynchronous link attach of the underlying AMQP receiver that backs this bridgeManager receiver.final AMQPBridgeManager(@return theAMQPBridgeManagerthat this receiver operates under)final longReturns the number of messages this consumer has received from the remote during its lifetime.(@return the policy that this sender was configured to use)Returns the bridge from policy manager that owns this bridge receiver.abstract intReturns the idle timeout value that is used applied to quiesced receivers.final AMQPBridgeReceiverInfoReturns an information object that defines the characteristics of theAMQPBridgeReceiver.protected final org.apache.qpid.proton.amqp.Symbol[]final org.apache.activemq.artemis.protocol.amqp.connect.bridge.AMQPBridgeReceiverInfo.ReceiverRolegetRole()Returns the type of bridge receiver being represented.voidCalled to initialize the AMQP bridge receiver 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()}@returntrueif the receiver has already been closed}final booleanReturnstrueif the receiver has previously been initialized.protected final voidrecordMessageReceived(Message message) Called from a subclass upon handling an incoming message from the remote.protected final booleanremoteLinkClosedInterceptor(org.apache.qpid.proton.engine.Link link) final AMQPBridgeReceiversetRemoteClosedHandler(Consumer<AMQPBridgeReceiver> handler) Provides and event point for notification of the receiver having been closed by the remote.final AMQPBridgeReceiversetRemoteOpenHandler(Consumer<AMQPBridgeReceiver> handler) Provides and event point for notification of the receiver having been opened successfully by the remote.final voidstartAsync(AMQPBridgeAsyncCompletion<AMQPBridgeReceiver> completion) Asynchronously starts a previously stopped bridgeManager receiver which should trigger a grant of credit to the remote thereby allowing new incoming messages to be bridged.final voidstopAsync(AMQPBridgeAsyncCompletion<AMQPBridgeReceiver> completion) Stops message consumption on this receiver instance but leaves the receiver in a state where it could be restarted by a call tostartAsync(AMQPBridgeAsyncCompletion)once the receiver 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
-
bridgeManager
-
policyManager
-
configuration
-
receiverInfo
-
policy
-
connection
-
session
-
transformer
protected final org.apache.activemq.artemis.core.server.transformer.Transformer transformer -
closed
-
metrics
-
receiver
-
protonReceiver
protected org.apache.qpid.proton.engine.Receiver protonReceiver -
initialized
protected volatile boolean initialized -
remoteOpenHandler
-
remoteCloseHandler
-
-
Constructor Details
-
AMQPBridgeReceiver
public AMQPBridgeReceiver(AMQPBridgeFromPolicyManager policyManager, AMQPBridgeReceiverConfiguration configuration, AMQPSessionContext session, AMQPBridgeReceiverInfo receiverInfo, AMQPBridgePolicy policy, AMQPBridgeMetrics.ReceiverMetrics metrics)
-
-
Method Details
-
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
-
isClosed
public boolean isClosed()}@returntrueif the receiver has already been closed} -
getRole
public final org.apache.activemq.artemis.protocol.amqp.connect.bridge.AMQPBridgeReceiverInfo.ReceiverRole getRole()Returns the type of bridge receiver being represented.- Returns:
- the type of bridge receiver being represented
-
getPolicyManager
Returns the bridge from policy manager that owns this bridge receiver.- Returns:
- the bridge from policy manager that owns this bridge receiver
-
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
-
isInitialized
public final boolean isInitialized()Returnstrueif the receiver has previously been initialized.- Returns:
trueif the receiver has previously been initialized
-
initialize
public void initialize()Called to initialize the AMQP bridge receiver 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 receiver is complete and should not be called again after that. -
doCreateReceiver
protected abstract void doCreateReceiver()Called during the initialization of the receiver to trigger an asynchronous link attach of the underlying AMQP receiver that backs this bridgeManager receiver. 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 receiver operates on. -
startAsync
Asynchronously starts a previously stopped bridgeManager receiver which should trigger a grant of credit to the remote thereby allowing new incoming messages to be bridged. In general the start should only happen when the receiver is known 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 receiver should immediately throw an
IllegalStateException. Calling start on an non-initialized receiver should immediately throw anIllegalStateException.Calling start on a stopped receiver should start the receiver and signal success to the completion. Calling start on an already started receiver should simply signal success to the completion. Calling start on a stopping receiver should fail the completion with an
IllegalStateException. Calling start on a receiver that closes while the start is in-flight should fail the completion with anIllegalStateException- Parameters:
completion- AAMQPBridgeAsyncCompletionthat will be notified when the stop request succeeds or fails.
-
stopAsync
Stops message consumption on this receiver instance but leaves the receiver in a state where it could be restarted by a call tostartAsync(AMQPBridgeAsyncCompletion)once the receiver 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 receiver has fully come to rest and all pending work is complete. Before the stopped completion is signaled the state of the underlying receiver will be stopping and attempt to restart it should fail until the stopped state has been reached.
The supplied
AMQPBridgeAsyncCompletionwill 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- AAMQPBridgeAsyncCompletionthat will be notified when the stop request succeeds or fails.
-
close
public final void close()Close the bridgeManager receiver 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.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
getPolicy
(@return the policy that this sender was configured to use) -
getBridgeManager
(@return theAMQPBridgeManagerthat this receiver operates under) -
getReceiverInfo
Returns an information object that defines the characteristics of theAMQPBridgeReceiver.- Returns:
- an information object that defines the characteristics of the
AMQPBridgeReceiver
-
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
Provides and event point for notification of the receiver having been closed by the remote.- Parameters:
handler- The handler that will be invoked when the remote closes this receiver.- Returns:
- this receiver instance.
-
recordMessageReceived
Called from a subclass upon handling an incoming message from the remote.- Parameters:
message- The original message that arrived from the remote.
-
getRemoteTerminusCapabilities
protected final org.apache.qpid.proton.amqp.Symbol[] getRemoteTerminusCapabilities() -
remoteLinkClosedInterceptor
protected final boolean remoteLinkClosedInterceptor(org.apache.qpid.proton.engine.Link link)
-