Fixed transport

This commit is contained in:
Andrii Shvaika 2020-04-24 19:16:25 +03:00
parent b5bedbfdf6
commit a779839081
5 changed files with 15 additions and 0 deletions

View File

@ -32,6 +32,7 @@ import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@ -233,6 +234,7 @@ public class ActorSystemContext {
/**
* The following Service will be null if we operate in tb-core mode
*/
@Lazy
@Autowired(required = false)
@Getter
private TbRuleEngineDeviceRpcService tbRuleEngineDeviceRpcService;
@ -240,6 +242,7 @@ public class ActorSystemContext {
/**
* The following Service will be null if we operate in tb-rule-engine mode
*/
@Lazy
@Autowired(required = false)
@Getter
private TbCoreDeviceRpcService tbCoreDeviceRpcService;

View File

@ -544,6 +544,9 @@ public class DefaultTransportService implements TransportService {
protected void sendToDeviceActor(TransportProtos.SessionInfoProto sessionInfo, TransportToDeviceActorMsg toDeviceActorMsg, TransportServiceCallback<Void> callback) {
TopicPartitionInfo tpi = partitionService.resolve(ServiceType.TB_CORE, getTenantId(sessionInfo), getDeviceId(sessionInfo));
if (log.isTraceEnabled()) {
log.trace("[{}][{}] Pushing to topic {} message {}", getTenantId(sessionInfo), getDeviceId(sessionInfo), tpi.getFullTopicName(), toDeviceActorMsg);
}
tbCoreMsgProducer.send(tpi,
new TbProtoQueueMsg<>(getRoutingKey(sessionInfo),
ToCoreMsg.newBuilder().setToDeviceActorMsg(toDeviceActorMsg).build()), callback != null ?
@ -552,6 +555,9 @@ public class DefaultTransportService implements TransportService {
protected void sendToRuleEngine(TenantId tenantId, TbMsg tbMsg, TbQueueCallback callback) {
TopicPartitionInfo tpi = partitionService.resolve(ServiceType.TB_RULE_ENGINE, tenantId, tbMsg.getOriginator());
if (log.isTraceEnabled()) {
log.trace("[{}][{}] Pushing to topic {} message {}", tenantId, tbMsg.getOriginator(), tpi.getFullTopicName(), tbMsg);
}
ToRuleEngineMsg msg = ToRuleEngineMsg.newBuilder().setTbMsg(TbMsg.toByteString(tbMsg))
.setTenantIdMSB(tenantId.getId().getMostSignificantBits())
.setTenantIdLSB(tenantId.getId().getLeastSignificantBits()).build();

View File

@ -1,3 +1,5 @@
ZOOKEEPER_ENABLED=true
ZOOKEEPER_URL=zookeeper:2181
COAP_BIND_ADDRESS=0.0.0.0
COAP_BIND_PORT=5683

View File

@ -1,3 +1,5 @@
ZOOKEEPER_ENABLED=true
ZOOKEEPER_URL=zookeeper:2181
HTTP_BIND_ADDRESS=0.0.0.0
HTTP_BIND_PORT=8081

View File

@ -1,3 +1,5 @@
ZOOKEEPER_ENABLED=true
ZOOKEEPER_URL=zookeeper:2181
MQTT_BIND_ADDRESS=0.0.0.0
MQTT_BIND_PORT=1883