mattrpav commented on code in PR #2071:
URL: https://github.com/apache/activemq/pull/2071#discussion_r3350871419
##########
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:
Must we throw an Exception at all for Advisories?
Thinking of call chain.. if a message or other activity results in an
advisory firing and the advisory fails, I don't think we'd want to propagate an
exception back to caller -- specifically it being sent back to client.
Feels like we should log, and add a failed advisory counter so this could be
monitored (should never error) instead of throwing an exception.
--
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