Commit cbe51cee57b693efba9ec8b80ceca536c204021e
Committed by
Andrew Shvayka
1 parent
607fd7a7
execute processMsgQueue on connected callback in separate thread because produce…
…r.send() will execute in Producer worker thread and can block messages producing
Showing
3 changed files
with
10 additions
and
1 deletions
... | ... | @@ -825,7 +825,7 @@ public class MqttTransportHandler extends ChannelInboundHandlerAdapter implement |
825 | 825 | ctx.writeAndFlush(createMqttConnAckMsg(CONNECTION_ACCEPTED, connectMessage)); |
826 | 826 | deviceSessionCtx.setConnected(true); |
827 | 827 | log.info("[{}] Client connected!", sessionId); |
828 | - processMsgQueue(ctx); | |
828 | + 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. | |
829 | 829 | } |
830 | 830 | |
831 | 831 | @Override | ... | ... |
... | ... | @@ -56,6 +56,8 @@ import org.thingsboard.server.gen.transport.TransportProtos.ValidateDeviceLwM2MC |
56 | 56 | import org.thingsboard.server.gen.transport.TransportProtos.ValidateDeviceTokenRequestMsg; |
57 | 57 | import org.thingsboard.server.gen.transport.TransportProtos.ValidateDeviceX509CertRequestMsg; |
58 | 58 | |
59 | +import java.util.concurrent.ExecutorService; | |
60 | + | |
59 | 61 | /** |
60 | 62 | * Created by ashvayka on 04.10.18. |
61 | 63 | */ |
... | ... | @@ -131,4 +133,6 @@ public interface TransportService { |
131 | 133 | void log(SessionInfoProto sessionInfo, String msg); |
132 | 134 | |
133 | 135 | void notifyAboutUplink(SessionInfoProto sessionInfo, TransportProtos.UplinkNotificationMsg build, TransportServiceCallback<Void> empty); |
136 | + | |
137 | + ExecutorService getCallbackExecutor(); | |
134 | 138 | } | ... | ... |