You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@activemq.apache.org by "Justin Bertram (Jira)" <ji...@apache.org> on 2020/12/16 17:47:00 UTC

[jira] [Commented] (ARTEMIS-3031) Add SERVER_STOP_CALLED Notification

    [ https://issues.apache.org/jira/browse/ARTEMIS-3031?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17250494#comment-17250494 ] 

Justin Bertram commented on ARTEMIS-3031:
-----------------------------------------

Can you clarify your use-case a bit? It seems like you've got a Camel web application deployed within the same JVM as the broker. Is that correct?

Typically for embedded use-cases (where the application and the broker are in the same JVM) you can register a {{org.apache.activemq.artemis.core.server.ActivateCallback}} and implement {{deActivate()}} to know when the broker is shutting down.

For non-embedded use-cases there's no way to know when the broker is shutting down and remote clients shouldn't really care since there are all kinds of ways to lose connectivity to the broker. The client should be able to handle connectivity loss for whatever reason (e.g. network issues, graceful broker shutdown, JVM crash, hardware failure, etc.). It's not clear what kind of issues your client(s) are having during shutdown so I can't comment further on this point although I can say that if you're using durable (i.e. persistent) messages and the proper acknowledgement strategy there should be no issues with lost messages regardless of what's happening on the client.

I'm not sure that a notification sent while stopping the broker would be a robust solution. It would almost certainly result in a race condition between dispatching the notification to the consumer and stopping the internal resources which allow message to be dispatched in the first place.

> Add SERVER_STOP_CALLED Notification
> -----------------------------------
>
>                 Key: ARTEMIS-3031
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-3031
>             Project: ActiveMQ Artemis
>          Issue Type: New Feature
>          Components: Broker
>            Reporter: Aaron Steigerwald
>            Priority: Minor
>
> There doesn't appear to be a way to tell when the Artemis server is starting to stop. This is needed to communicate with some web applications running inside the server's JVM. For example, it is needed to suspend or stop Camel before much of the Artemis server shuts down. Currently, most of the Artemis server's components shutdown before the WebServerComponent does, which contains web applications like Camel. A SERVER_STOP_CALLED Notification can be used to suspend or stop Camel via JMX before the Artemis server's acceptors shutdown.
> One way to accomplish this is to:
> 1) Add a new SERVER_STOP_CALLED enum to org.apache.activemq.artemis.api.core.management.CoreNotificationType.
> 2) Send a SERVER_STOP_CALLED Notification in org.apache.activemq.artemis.cli.commands.Run.stop() like the following:
> {noformat}
>          if (server != null) {
>             // Start new code
>             TypedProperties props = new TypedProperties();
>             props.putSimpleStringProperty(new SimpleString("callingClass"), new SimpleString(this.getClass().getName()));
>             props.putSimpleStringProperty(new SimpleString("callingMethod"), new SimpleString("stop"));
>             server.getServer().getManagementService().sendNotification(new Notification(null, SyndeoNotificationType.SERVER_STOP_CALLED, props));
>             // End new code
>             server.stop(true);
>          }{noformat}
> Without this feature, web applications like Camel can take a long time to shutdown depending on the configuration. Also, the shutdown can appear ungraceful and it's unclear what impact it has on inflight messages.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)