Class BridgeImpl
- java.lang.Object
-
- org.apache.activemq.artemis.core.server.cluster.impl.BridgeImpl
-
- All Implemented Interfaces:
SendAcknowledgementHandler,SessionFailureListener,ClientProducerFlowCallback,PriorityAware,FailureListener,ActiveMQComponent,Bridge,Consumer,ReadyListener
- Direct Known Subclasses:
ClusterConnectionBridge
public class BridgeImpl extends Object implements Bridge, SessionFailureListener, SendAcknowledgementHandler, ReadyListener, ClientProducerFlowCallback
A Core BridgeImpl
-
-
Field Summary
Fields Modifier and Type Field Description protected booleandisconnectedAndDownprotected Executorexecutorprotected ScheduledFuture<?>futureScheduledReconnectionUsed when there's a scheduled reconnectionprotected Queuequeueprotected ScheduledExecutorServicescheduledExecutorprotected ServerLocatorInternalserverLocatorprotected ClientSessionInternalsessionprotected ClientSessionInternalsessionConsumerprotected TopologyMembertargetNodeprotected StringtargetNodeID
-
Constructor Summary
Constructors Constructor Description BridgeImpl(ServerLocatorInternal serverLocator, BridgeConfiguration configuration, UUID nodeUUID, Queue queue, Executor executor, ScheduledExecutorService scheduledExecutor, ActiveMQServer server)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidactivate()protected voidafterConnect()protected MessagebeforeForward(Message message, SimpleString forwardingAddress)protected MessagebeforeForwardingNoCopy(Message message, SimpleString forwardingAddress)ClusterConnectionBridge already makes a copy of the message.voidbeforeReconnect(ActiveMQException exception)protected voidconnect()voidconnectionFailed(ActiveMQException me, boolean failedOver)voidconnectionFailed(ActiveMQException me, boolean failedOver, String scaleDownTargetNodeID)protected ClientSessionFactoryInternalcreateSessionFactory()Stringdebug()voiddisconnect()To be called when the server sent a disconnect to the client.protected voidfail(boolean permanently, boolean scaleDown)voidfailed(Throwable t)voidflushExecutor()BridgeConfigurationgetConfiguration()ClientSessionFactoryImplgetCSF()List<MessageReference>getDeliveringMessages()static byte[]getDuplicateBytes(UUID nodeUUID, long messageID)ExecutorgetExecutor()The cluster manager needs to use the same executor to close the serverLocator, otherwise the stop will break.FiltergetFilter()SimpleStringgetForwardingAddress()RemotingConnectiongetForwardingConnection()BridgeMetricsgetMetrics()SimpleStringgetName()QueuegetQueue()ClientSessionFactorygetSessionFactory()TopologyMembergetTargetNodeFromTopology()for use in tests mainlyTransformergetTransformer()HandleStatushandle(MessageReference ref)There was a change on semantic during 2.3 here.
We now first accept the message, and the actual deliver is done as part ofConsumer.proceedDeliver(MessageReference).booleanisBlockedOnFlowControl()For tests mainlybooleanisConnected()booleanisStarted()protected voidnodeUP(TopologyMember member, boolean last)voidonCreditsFail(ClientProducerCredits producerCredits)voidonCreditsFlow(boolean blocked, ClientProducerCredits producerCredits)voidpause()voidproceedDeliver(MessageReference ref)This will proceed with the actual delivery.voidreadyForWriting()protected ClientSessionFactoryInternalreconnectOnOriginalNode()voidresume()protected voidscaleDown(String scaleDownTargetNodeID)protected voidscheduleRetryConnect()protected voidscheduleRetryConnectFixedTimeout(long milliseconds)voidsendAcknowledged(Message message)voidsendFailed(Message message, Exception e)longsequentialID()an unique sequential ID for this consumervoidsetNotificationService(NotificationService notificationService)protected voidsetSessionFactory(ClientSessionFactoryInternal sfi)voidstart()voidstop()StringtoManagementString()This method will create a string representation meant for management operations.StringtoString()protected voidtryScheduleRetryReconnect(ActiveMQExceptionType type)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.activemq.artemis.core.server.ActiveMQComponent
asyncStop
-
Methods inherited from interface org.apache.activemq.artemis.core.server.Consumer
errorProcessing, getBinding, getPriority, isClosed, promptDelivery, supportsDirectDelivery
-
-
-
-
Field Detail
-
serverLocator
protected final ServerLocatorInternal serverLocator
-
executor
protected final Executor executor
-
scheduledExecutor
protected final ScheduledExecutorService scheduledExecutor
-
queue
protected final Queue queue
-
futureScheduledReconnection
protected ScheduledFuture<?> futureScheduledReconnection
Used when there's a scheduled reconnection
-
session
protected volatile ClientSessionInternal session
-
sessionConsumer
protected volatile ClientSessionInternal sessionConsumer
-
disconnectedAndDown
protected volatile boolean disconnectedAndDown
-
targetNodeID
protected String targetNodeID
-
targetNode
protected TopologyMember targetNode
-
-
Constructor Detail
-
BridgeImpl
public BridgeImpl(ServerLocatorInternal serverLocator, BridgeConfiguration configuration, UUID nodeUUID, Queue queue, Executor executor, ScheduledExecutorService scheduledExecutor, ActiveMQServer server) throws ActiveMQException
- Throws:
ActiveMQException
-
-
Method Detail
-
isBlockedOnFlowControl
public boolean isBlockedOnFlowControl()
For tests mainly
-
getDuplicateBytes
public static final byte[] getDuplicateBytes(UUID nodeUUID, long messageID)
-
getSessionFactory
public ClientSessionFactory getSessionFactory()
-
getDeliveringMessages
public List<MessageReference> getDeliveringMessages()
- Specified by:
getDeliveringMessagesin interfaceConsumer- Returns:
- the list of messages being delivered
-
setNotificationService
public void setNotificationService(NotificationService notificationService)
- Specified by:
setNotificationServicein interfaceBridge
-
onCreditsFlow
public void onCreditsFlow(boolean blocked, ClientProducerCredits producerCredits)- Specified by:
onCreditsFlowin interfaceClientProducerFlowCallback
-
onCreditsFail
public void onCreditsFail(ClientProducerCredits producerCredits)
- Specified by:
onCreditsFailin interfaceClientProducerFlowCallback
-
sequentialID
public long sequentialID()
Description copied from interface:Consumeran unique sequential ID for this consumer- Specified by:
sequentialIDin interfaceConsumer
-
start
public void start() throws Exception- Specified by:
startin interfaceActiveMQComponent- Throws:
Exception
-
flushExecutor
public void flushExecutor()
- Specified by:
flushExecutorin interfaceBridge
-
disconnect
public void disconnect()
Description copied from interface:BridgeTo be called when the server sent a disconnect to the client. Basically this is for cluster bridges being disconnected- Specified by:
disconnectin interfaceBridge- Specified by:
disconnectin interfaceConsumer
-
isConnected
public boolean isConnected()
- Specified by:
isConnectedin interfaceBridge
-
getExecutor
public Executor getExecutor()
The cluster manager needs to use the same executor to close the serverLocator, otherwise the stop will break. This method is intended to expose this executor to the ClusterManager
-
stop
public void stop() throws Exception- Specified by:
stopin interfaceActiveMQComponent- Throws:
Exception
-
pause
public void pause() throws Exception
-
resume
public void resume() throws Exception
-
isStarted
public boolean isStarted()
- Specified by:
isStartedin interfaceActiveMQComponent
-
activate
public void activate()
-
getName
public SimpleString getName()
-
getForwardingAddress
public SimpleString getForwardingAddress()
- Specified by:
getForwardingAddressin interfaceBridge
-
getForwardingConnection
public RemotingConnection getForwardingConnection()
- Specified by:
getForwardingConnectionin interfaceBridge
-
sendFailed
public void sendFailed(Message message, Exception e)
- Specified by:
sendFailedin interfaceSendAcknowledgementHandler
-
sendAcknowledged
public void sendAcknowledged(Message message)
- Specified by:
sendAcknowledgedin interfaceSendAcknowledgementHandler
-
beforeForward
protected Message beforeForward(Message message, SimpleString forwardingAddress)
-
beforeForwardingNoCopy
protected Message beforeForwardingNoCopy(Message message, SimpleString forwardingAddress)
ClusterConnectionBridge already makes a copy of the message. So I needed I hook where the message is not copied.
-
readyForWriting
public void readyForWriting()
- Specified by:
readyForWritingin interfaceReadyListener
-
handle
public HandleStatus handle(MessageReference ref) throws Exception
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 ofConsumer.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
public void proceedDeliver(MessageReference ref)
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
-
connectionFailed
public void connectionFailed(ActiveMQException me, boolean failedOver)
- Specified by:
connectionFailedin interfaceFailureListener
-
connectionFailed
public void connectionFailed(ActiveMQException me, boolean failedOver, String scaleDownTargetNodeID)
- Specified by:
connectionFailedin interfaceFailureListener
-
scaleDown
protected void scaleDown(String scaleDownTargetNodeID)
-
tryScheduleRetryReconnect
protected void tryScheduleRetryReconnect(ActiveMQExceptionType type)
-
beforeReconnect
public void beforeReconnect(ActiveMQException exception)
- Specified by:
beforeReconnectin interfaceSessionFailureListener
-
getTargetNodeFromTopology
public TopologyMember getTargetNodeFromTopology()
for use in tests mainly- Returns:
-
getMetrics
public BridgeMetrics getMetrics()
- Specified by:
getMetricsin interfaceBridge
-
toManagementString
public String 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- Returns:
-
getCSF
public ClientSessionFactoryImpl getCSF()
-
getTransformer
public Transformer getTransformer()
-
getConfiguration
public BridgeConfiguration getConfiguration()
- Specified by:
getConfigurationin interfaceBridge
-
fail
protected void fail(boolean permanently, boolean scaleDown)
-
createSessionFactory
protected ClientSessionFactoryInternal createSessionFactory() throws Exception
- Throws:
Exception
-
reconnectOnOriginalNode
protected ClientSessionFactoryInternal reconnectOnOriginalNode() throws Exception
- Throws:
Exception
-
setSessionFactory
protected void setSessionFactory(ClientSessionFactoryInternal sfi)
-
connect
protected void connect()
-
scheduleRetryConnect
protected void scheduleRetryConnect()
-
nodeUP
protected void nodeUP(TopologyMember member, boolean last)
-
scheduleRetryConnectFixedTimeout
protected void scheduleRetryConnectFixedTimeout(long milliseconds)
-
-