execute processMsgQueue on connected callback in separate thread because producer.send() will execute in Producer worker thread and can block messages producing
This commit is contained in:
parent
607fd7a74f
commit
cbe51cee57
@ -825,7 +825,7 @@ public class MqttTransportHandler extends ChannelInboundHandlerAdapter implement
|
||||
ctx.writeAndFlush(createMqttConnAckMsg(CONNECTION_ACCEPTED, connectMessage));
|
||||
deviceSessionCtx.setConnected(true);
|
||||
log.info("[{}] Client connected!", sessionId);
|
||||
processMsgQueue(ctx);
|
||||
transportService.getCallbackExecutor().execute(() -> processMsgQueue(ctx)); //this callback will execute in Producer worker thread and hard or blocking work have to be submitted to the separate thread.
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -56,6 +56,8 @@ import org.thingsboard.server.gen.transport.TransportProtos.ValidateDeviceLwM2MC
|
||||
import org.thingsboard.server.gen.transport.TransportProtos.ValidateDeviceTokenRequestMsg;
|
||||
import org.thingsboard.server.gen.transport.TransportProtos.ValidateDeviceX509CertRequestMsg;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
|
||||
/**
|
||||
* Created by ashvayka on 04.10.18.
|
||||
*/
|
||||
@ -131,4 +133,6 @@ public interface TransportService {
|
||||
void log(SessionInfoProto sessionInfo, String msg);
|
||||
|
||||
void notifyAboutUplink(SessionInfoProto sessionInfo, TransportProtos.UplinkNotificationMsg build, TransportServiceCallback<Void> empty);
|
||||
|
||||
ExecutorService getCallbackExecutor();
|
||||
}
|
||||
|
||||
@ -1141,4 +1141,9 @@ public class DefaultTransportService implements TransportService {
|
||||
callback.onError(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExecutorService getCallbackExecutor() {
|
||||
return transportCallbackExecutor;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user