[
https://issues.apache.org/jira/browse/CAMEL-11628?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16237789#comment-16237789
]
Brad Powell edited comment on CAMEL-11628 at 11/3/17 3:55 PM:
--------------------------------------------------------------
I investigated this bug, found what I believe is the culprit, fixed it, and
tested successfully.
I'll submit a PR with the fix.
But in a nutshell, the fix was to add this at the top of the MQTTEndpoint
createConnection() method:
{code:java}
protected void createConnection() {
if (connection != null) {
// In connect(), in the connection.connect() callback, onFailure()
doesn't seem to ever be called, so forcing the disconnect here.
// Without this, the fusesource MQTT client seems to be holding the
old connection object, and connection contention can ensue.
connection.disconnect(null);
}
{code}
was (Author: bapowell):
I investigated this bug, found what I believe is the culprit, fixed it, and
tested successfully.
I'll submit a PR with the fix.
But in a nutshell, the fix was to add this at the top of the createConnection()
method:
{code:java}
protected void createConnection() {
if (connection != null) {
// In connect(), in the connection.connect() callback, onFailure()
doesn't seem to ever be called, so forcing the disconnect here.
// Without this, the fusesource MQTT client seems to be holding the
old connection object, and connection contention can ensue.
connection.disconnect(null);
}
{code}
> MQTT Connection loop
> --------------------
>
> Key: CAMEL-11628
> URL: https://issues.apache.org/jira/browse/CAMEL-11628
> Project: Camel
> Issue Type: Bug
> Components: camel-mqtt
> Affects Versions: 2.17.0
> Reporter: Fabrizio Spataro
> Priority: Major
>
> Hello everyone, i found an particular bug situation
> I have same mqtt producer with high volume traffic. When my application losts
> tcp connection to mqtt server i have follow connection loop error. This bug
> is sometime verified because it depend by multiple factors (load machine,
> load mqtt server, payload, etc)
> I am reading source code and i suppose that the bug is introduced by volatile
> variable connected (it isn't thread-safe)
> To resolve this bug you must refactoring all MQTTEndpoint connection code.
> [ hawtdispatch-DEFAULT-3] MQTTEndpoint INFO MQTT
> Connection connected to tcp://mqtt:1883
> [ hawtdispatch-DEFAULT-3] MQTTEndpoint INFO MQTT
> Connection connected to tcp://mqtt:1883
> [ hawtdispatch-DEFAULT-3] MQTTEndpoint INFO MQTT
> Connection connected to tcp://mqtt:1883
> [ hawtdispatch-DEFAULT-3] MQTTEndpoint INFO MQTT
> Connection connected to tcp://mqtt:1883
> [ hawtdispatch-DEFAULT-3] MQTTEndpoint INFO MQTT
> Connection connected to tcp://mqtt:1883
> [ hawtdispatch-DEFAULT-3] MQTTEndpoint INFO MQTT
> Connection connected to tcp://mqtt:1883
> [ hawtdispatch-DEFAULT-3] MQTTEndpoint INFO MQTT
> Connection connected to tcp://mqtt:1883
> [ hawtdispatch-DEFAULT-3] MQTTEndpoint INFO MQTT
> Connection connected to tcp://mqtt:1883
> [ hawtdispatch-DEFAULT-3] MQTTEndpoint INFO MQTT
> Connection connected to tcp://mqtt:1883
> [ hawtdispatch-DEFAULT-3] MQTTEndpoint INFO MQTT
> Connection connected to tcp://mqtt:1883
> [ hawtdispatch-DEFAULT-3] MQTTEndpoint INFO MQTT
> Connection connected to tcp://mqtt:1883
> [ hawtdispatch-DEFAULT-3] MQTTEndpoint INFO MQTT
> Connection connected to tcp://mqtt:1883
> [ hawtdispatch-DEFAULT-3] MQTTEndpoint INFO MQTT
> Connection connected to tcp://mqtt:1883
> [ hawtdispatch-DEFAULT-3] MQTTEndpoint INFO MQTT
> Connection connected to tcp://mqtt:1883
> [ hawtdispatch-DEFAULT-3] MQTTEndpoint INFO MQTT
> Connection connected to tcp://mqtt:1883
> [ hawtdispatch-DEFAULT-3] MQTTEndpoint INFO MQTT
> Connection connected to tcp://mqtt:1883
> [ hawtdispatch-DEFAULT-3] MQTTEndpoint INFO MQTT
> Connection connected to tcp://mqtt:1883
> [ hawtdispatch-DEFAULT-3] MQTTEndpoint INFO MQTT
> Connection connected to tcp://mqtt:1883
> [ hawtdispatch-DEFAULT-3] MQTTEndpoint INFO MQTT
> Connection connected to tcp://mqtt:1883
> [ hawtdispatch-DEFAULT-3] MQTTEndpoint INFO MQTT
> Connection connected to tcp://mqtt:1883
> [ hawtdispatch-DEFAULT-3] MQTTEndpoint INFO MQTT
> Connection connected to tcp://mqtt:1883
> [ hawtdispatch-DEFAULT-3] MQTTEndpoint INFO MQTT
> Connection connected to tcp://mqtt:1883
> [ hawtdispatch-DEFAULT-3] MQTTEndpoint INFO MQTT
> Connection connected to tcp://mqtt:1883
> [ hawtdispatch-DEFAULT-3] MQTTEndpoint INFO MQTT
> Connection connected to tcp://mqtt:1883
> [ hawtdispatch-DEFAULT-3] MQTTEndpoint INFO MQTT
> Connection connected to tcp://mqtt:1883
> [ hawtdispatch-DEFAULT-3] MQTTEndpoint INFO MQTT
> Connection connected to tcp://mqtt:1883
> [ hawtdispatch-DEFAULT-3] MQTTEndpoint INFO MQTT
> Connection connected to tcp://mqtt:1883
> [ hawtdispatch-DEFAULT-3] MQTTEndpoint INFO MQTT
> Connection connected to tcp://mqtt:1883
> [ hawtdispatch-DEFAULT-3] MQTTEndpoint INFO MQTT
> Connection connected to tcp://mqtt:1883
> [ hawtdispatch-DEFAULT-3] MQTTEndpoint INFO MQTT
> Connection connected to tcp://mqtt:1883
> [ hawtdispatch-DEFAULT-3] MQTTEndpoint INFO MQTT
> Connection connected to tcp://mqtt:1883
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)