Search in sources :

Example 1 with MultipleTbQueueCallbackWrapper

use of org.thingsboard.server.queue.common.MultipleTbQueueCallbackWrapper in project thingsboard by thingsboard.

the class DefaultTbClusterService method broadcast.

private void broadcast(ToTransportMsg transportMsg, TbQueueCallback callback) {
    TbQueueProducer<TbProtoQueueMsg<ToTransportMsg>> toTransportNfProducer = producerProvider.getTransportNotificationsMsgProducer();
    Set<String> tbTransportServices = partitionService.getAllServiceIds(ServiceType.TB_TRANSPORT);
    TbQueueCallback proxyCallback = callback != null ? new MultipleTbQueueCallbackWrapper(tbTransportServices.size(), callback) : null;
    for (String transportServiceId : tbTransportServices) {
        TopicPartitionInfo tpi = partitionService.getNotificationsTopic(ServiceType.TB_TRANSPORT, transportServiceId);
        toTransportNfProducer.send(tpi, new TbProtoQueueMsg<>(UUID.randomUUID(), transportMsg), proxyCallback);
        toTransportNfs.incrementAndGet();
    }
}
Also used : TopicPartitionInfo(org.thingsboard.server.common.msg.queue.TopicPartitionInfo) TbQueueCallback(org.thingsboard.server.queue.TbQueueCallback) TbProtoQueueMsg(org.thingsboard.server.queue.common.TbProtoQueueMsg) MultipleTbQueueCallbackWrapper(org.thingsboard.server.queue.common.MultipleTbQueueCallbackWrapper) ByteString(com.google.protobuf.ByteString)

Aggregations

ByteString (com.google.protobuf.ByteString)1 TopicPartitionInfo (org.thingsboard.server.common.msg.queue.TopicPartitionInfo)1 TbQueueCallback (org.thingsboard.server.queue.TbQueueCallback)1 MultipleTbQueueCallbackWrapper (org.thingsboard.server.queue.common.MultipleTbQueueCallbackWrapper)1 TbProtoQueueMsg (org.thingsboard.server.queue.common.TbProtoQueueMsg)1