Search in sources :

Example 6 with ToCoreNotificationMsg

use of org.thingsboard.server.gen.transport.TransportProtos.ToCoreNotificationMsg in project thingsboard by thingsboard.

the class DefaultTbClusterService method pushNotificationToCore.

@Override
public void pushNotificationToCore(String serviceId, FromDeviceRpcResponse response, TbQueueCallback callback) {
    TopicPartitionInfo tpi = partitionService.getNotificationsTopic(ServiceType.TB_CORE, serviceId);
    log.trace("PUSHING msg: {} to:{}", response, tpi);
    FromDeviceRPCResponseProto.Builder builder = FromDeviceRPCResponseProto.newBuilder().setRequestIdMSB(response.getId().getMostSignificantBits()).setRequestIdLSB(response.getId().getLeastSignificantBits()).setError(response.getError().isPresent() ? response.getError().get().ordinal() : -1);
    response.getResponse().ifPresent(builder::setResponse);
    ToCoreNotificationMsg msg = ToCoreNotificationMsg.newBuilder().setFromDeviceRpcResponse(builder).build();
    producerProvider.getTbCoreNotificationsMsgProducer().send(tpi, new TbProtoQueueMsg<>(response.getId(), msg), callback);
    toCoreNfs.incrementAndGet();
}
Also used : ToCoreNotificationMsg(org.thingsboard.server.gen.transport.TransportProtos.ToCoreNotificationMsg) TopicPartitionInfo(org.thingsboard.server.common.msg.queue.TopicPartitionInfo) FromDeviceRPCResponseProto(org.thingsboard.server.gen.transport.TransportProtos.FromDeviceRPCResponseProto)

Aggregations

ToCoreNotificationMsg (org.thingsboard.server.gen.transport.TransportProtos.ToCoreNotificationMsg)6 TbProtoQueueMsg (org.thingsboard.server.queue.common.TbProtoQueueMsg)4 TopicPartitionInfo (org.thingsboard.server.common.msg.queue.TopicPartitionInfo)3 ByteString (com.google.protobuf.ByteString)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Optional (java.util.Optional)1 TreeMap (java.util.TreeMap)1 EntityType (org.thingsboard.server.common.data.EntityType)1 BasicTsKvEntry (org.thingsboard.server.common.data.kv.BasicTsKvEntry)1 TsKvEntry (org.thingsboard.server.common.data.kv.TsKvEntry)1 EdgeEventUpdateMsg (org.thingsboard.server.common.msg.edge.EdgeEventUpdateMsg)1 FromDeviceRPCResponseProto (org.thingsboard.server.gen.transport.TransportProtos.FromDeviceRPCResponseProto)1 TbAlarmSubscriptionUpdateProto (org.thingsboard.server.gen.transport.TransportProtos.TbAlarmSubscriptionUpdateProto)1 TbSubscriptionUpdateProto (org.thingsboard.server.gen.transport.TransportProtos.TbSubscriptionUpdateProto)1 TbSubscriptionUpdateTsValue (org.thingsboard.server.gen.transport.TransportProtos.TbSubscriptionUpdateTsValue)1 TbSubscriptionUpdateValueListProto (org.thingsboard.server.gen.transport.TransportProtos.TbSubscriptionUpdateValueListProto)1 ToRuleEngineNotificationMsg (org.thingsboard.server.gen.transport.TransportProtos.ToRuleEngineNotificationMsg)1