cshannon commented on code in PR #2071:
URL: https://github.com/apache/activemq/pull/2071#discussion_r3352630081
##########
activemq-broker/src/main/java/org/apache/activemq/advisory/AdvisoryBroker.java:
##########
@@ -1030,4 +1031,50 @@ private AdvisoryBroker getOuterType() {
return AdvisoryBroker.this;
}
}
+
+ protected ProducerBrokerExchange newAdvisoryProducerExchange() {
+ final ProducerBrokerExchange producerExchange = new
ProducerBrokerExchange();
+
producerExchange.setConnectionContext(Objects.requireNonNull(advisoryConnectionContext.get(),
+ "Advisory ConnectionContext must not be null"));
+ producerExchange.setMutable(true);
+ producerExchange.setProducerState(new ProducerState(new
ProducerInfo()));
+ return producerExchange;
+ }
+
+ // Lazy load becuase we need to call
getBrokerService().getAdminConnectionContext()
+ // after the constructor finishes to allow the Broker chain to finish
initializing
+ // to prevent a stack overflow. Uses double-checked locking abstracted away
+ // to share the advisory admin context to load on demand.
+ protected class AdvisoryConnContextSupplier implements
Supplier<ConnectionContext> {
+
+ private volatile ConnectionContext advisoryContext;
+
+ @Override
+ public ConnectionContext get() {
+ ConnectionContext result = advisoryContext;
+
+ if (result == null) {
+ synchronized (this) {
+ result = advisoryContext;
+ if (result == null) {
+ try {
+ // Copy so we can set flow control false
+ advisoryContext = result =
+
getBrokerService().getAdminConnectionContext().copy();
+ // We never want to use flow control for advisories
+ result.setProducerFlowControl(false);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
Review Comment:
> However I don't really like this design. This object should really be
initialized on start and re-used for the lifecycle. If we can't load it it
should fail fast as that's a fatal error. I'm going to look more into it
because I realized that while the broker may be trying to send advisories
during destination loading before start() is called, is that really doing
anything? At that point there would be no consumers for the advisories anyways
so I need to investigate this more.
Yep it is indeed important that the advisory broker has its callback called
during destination add even without consumers because it captures all the
information for replay when the advisory consumers do connect. So we can't get
rid of this and i'm looking now how to handle it. I am looking into if we need
to keep the lazy loading or not.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact