-
Notifications
You must be signed in to change notification settings - Fork 959
ARTEMIS-6217 mitigate shutdown stacktraces for MQTT #6653
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,14 +16,21 @@ | |
| */ | ||
| package org.apache.activemq.artemis.core.protocol.mqtt; | ||
|
|
||
| import java.lang.invoke.MethodHandles; | ||
|
|
||
| import org.apache.activemq.artemis.api.core.SimpleString; | ||
| import org.apache.activemq.artemis.core.persistence.impl.journal.ActiveMQIDGeneratorStoppedException; | ||
| import org.apache.activemq.artemis.core.server.MessageReference; | ||
| import org.apache.activemq.artemis.core.server.ServerConsumer; | ||
| import org.apache.activemq.artemis.spi.core.protocol.SessionCallback; | ||
| import org.apache.activemq.artemis.spi.core.remoting.ReadyListener; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
| public class MQTTSessionCallback implements SessionCallback { | ||
|
|
||
| private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); | ||
|
|
||
| private final MQTTSession session; | ||
| private final MQTTConnection connection; | ||
| private final int defaultMaximumInFlightPublishMessages; | ||
|
|
@@ -50,6 +57,8 @@ public int sendMessage(MessageReference ref, | |
| int deliveryCount) { | ||
| try { | ||
| session.getMqttPublishManager().publishToClient(ref.getMessage().toCore(), consumer); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the right thing would be to make sure these are flushed before. the stop on the MQTPPProtocolManager flushing everything would be a better fix. (the stop is one place it could / should block until things are done).
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm exploring this idea... 🤔
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I looked into what you suggested here and I have a few thoughts:
I'd love your thoughts. |
||
| } catch (ActiveMQIDGeneratorStoppedException ignored) { | ||
| logger.debug("Unable to send message to MQTT client because the storage manager is stopping; consumer: {}; message: {}", consumer, ref, ignored); | ||
| } catch (Exception e) { | ||
| MQTTLogger.LOGGER.unableToSendMessage(session.getState().getClientId(), ref, e); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.apache.activemq.artemis.core.persistence.impl.journal; | ||
|
|
||
| /** | ||
| * Thrown by an {@link org.apache.activemq.artemis.utils.IDGenerator} when an ID is requested after the generator has | ||
| * been stopped. | ||
| */ | ||
| public class ActiveMQIDGeneratorStoppedException extends RuntimeException { | ||
|
|
||
| private static final long serialVersionUID = 8328635365036357836L; | ||
|
|
||
| public ActiveMQIDGeneratorStoppedException(String message) { | ||
| super(message); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you remove the ID, probably a good idea to retire it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's been retired. 👍