When discarding invalid messages we should consume them. When starting up wait for node bridge registration before activating the float, otherwise we have a race condition.

Reduce excessive logging

Address PR comments

Address PR comments
This commit is contained in:
Matthew Nesbit
2018-04-09 12:04:29 +01:00
parent a4a6eedbf0
commit e51de2739c
8 changed files with 84 additions and 32 deletions

View File

@ -27,6 +27,8 @@ import org.apache.activemq.artemis.api.core.RoutingType
import org.apache.activemq.artemis.api.core.SimpleString
import org.apache.activemq.artemis.api.core.client.ClientConsumer
import org.apache.activemq.artemis.api.core.client.ClientMessage
import rx.Observable
import rx.subjects.PublishSubject
import java.util.*
class BridgeControlListener(val config: NodeSSLConfiguration,
@ -47,6 +49,13 @@ class BridgeControlListener(val config: NodeSSLConfiguration,
private val log = contextLogger()
}
val active: Boolean
get() = validInboundQueues.isNotEmpty()
private val _activeChange = PublishSubject.create<Boolean>().toSerialized()
val activeChange: Observable<Boolean>
get() = _activeChange
fun start() {
stop()
bridgeManager.start()
@ -73,6 +82,9 @@ class BridgeControlListener(val config: NodeSSLConfiguration,
}
fun stop() {
if (active) {
_activeChange.onNext(false)
}
validInboundQueues.clear()
controlConsumer?.close()
controlConsumer = null
@ -112,7 +124,11 @@ class BridgeControlListener(val config: NodeSSLConfiguration,
for (outQueue in controlMessage.sendQueues) {
bridgeManager.deployBridge(outQueue.queueName, outQueue.targets.first(), outQueue.legalNames.toSet())
}
val wasActive = active
validInboundQueues.addAll(controlMessage.inboxQueues)
if (!wasActive && active) {
_activeChange.onNext(true)
}
}
is BridgeControl.BridgeToNodeSnapshotRequest -> {
log.error("Message from Bridge $controlMessage detected on wrong topic!")