Commit b8b27ec3f2a036e1db965468d1b96ace8c23d92f

Authored by Andrew Shvayka
1 parent ae4148d7

Extra logging and gateway fix

@@ -91,4 +91,13 @@ public class DeviceAttributes { @@ -91,4 +91,13 @@ public class DeviceAttributes {
91 } 91 }
92 return map; 92 return map;
93 } 93 }
  94 +
  95 + @Override
  96 + public String toString() {
  97 + return "DeviceAttributes{" +
  98 + "clientSideAttributesMap=" + clientSideAttributesMap +
  99 + ", serverPrivateAttributesMap=" + serverPrivateAttributesMap +
  100 + ", serverPublicAttributesMap=" + serverPublicAttributesMap +
  101 + '}';
  102 + }
94 } 103 }
@@ -15,6 +15,7 @@ @@ -15,6 +15,7 @@
15 */ 15 */
16 package org.thingsboard.server.extensions.core.action.template; 16 package org.thingsboard.server.extensions.core.action.template;
17 17
  18 +import lombok.extern.slf4j.Slf4j;
18 import org.apache.velocity.Template; 19 import org.apache.velocity.Template;
19 import org.apache.velocity.VelocityContext; 20 import org.apache.velocity.VelocityContext;
20 import org.apache.velocity.runtime.parser.ParseException; 21 import org.apache.velocity.runtime.parser.ParseException;
@@ -35,6 +36,7 @@ import java.util.Optional; @@ -35,6 +36,7 @@ import java.util.Optional;
35 /** 36 /**
36 * @author Andrew Shvayka 37 * @author Andrew Shvayka
37 */ 38 */
  39 +@Slf4j
38 public abstract class AbstractTemplatePluginAction<T extends TemplateActionConfiguration> extends SimpleRuleLifecycleComponent implements PluginAction<T> { 40 public abstract class AbstractTemplatePluginAction<T extends TemplateActionConfiguration> extends SimpleRuleLifecycleComponent implements PluginAction<T> {
39 protected T configuration; 41 protected T configuration;
40 protected Template template; 42 protected Template template;
@@ -69,6 +71,7 @@ public abstract class AbstractTemplatePluginAction<T extends TemplateActionConfi @@ -69,6 +71,7 @@ public abstract class AbstractTemplatePluginAction<T extends TemplateActionConfi
69 } 71 }
70 72
71 protected String getMsgBody(RuleContext ctx, ToDeviceActorMsg msg) { 73 protected String getMsgBody(RuleContext ctx, ToDeviceActorMsg msg) {
  74 + log.trace("Creating context for: {} and payload {}", ctx.getDeviceAttributes(), msg.getPayload());
72 VelocityContext context = VelocityUtils.createContext(ctx.getDeviceAttributes(), msg.getPayload()); 75 VelocityContext context = VelocityUtils.createContext(ctx.getDeviceAttributes(), msg.getPayload());
73 return VelocityUtils.merge(template, context); 76 return VelocityUtils.merge(template, context);
74 } 77 }
@@ -16,6 +16,7 @@ @@ -16,6 +16,7 @@
16 package org.thingsboard.server.extensions.kafka.plugin; 16 package org.thingsboard.server.extensions.kafka.plugin;
17 17
18 import lombok.RequiredArgsConstructor; 18 import lombok.RequiredArgsConstructor;
  19 +import lombok.extern.slf4j.Slf4j;
19 import org.apache.kafka.clients.producer.Producer; 20 import org.apache.kafka.clients.producer.Producer;
20 import org.apache.kafka.clients.producer.ProducerRecord; 21 import org.apache.kafka.clients.producer.ProducerRecord;
21 import org.thingsboard.server.common.data.id.RuleId; 22 import org.thingsboard.server.common.data.id.RuleId;
@@ -30,6 +31,7 @@ import org.thingsboard.server.extensions.kafka.action.KafkaActionMsg; @@ -30,6 +31,7 @@ import org.thingsboard.server.extensions.kafka.action.KafkaActionMsg;
30 import org.thingsboard.server.extensions.kafka.action.KafkaActionPayload; 31 import org.thingsboard.server.extensions.kafka.action.KafkaActionPayload;
31 32
32 @RequiredArgsConstructor 33 @RequiredArgsConstructor
  34 +@Slf4j
33 public class KafkaMsgHandler implements RuleMsgHandler { 35 public class KafkaMsgHandler implements RuleMsgHandler {
34 36
35 private final Producer<?, String> producer; 37 private final Producer<?, String> producer;
@@ -40,7 +42,7 @@ public class KafkaMsgHandler implements RuleMsgHandler { @@ -40,7 +42,7 @@ public class KafkaMsgHandler implements RuleMsgHandler {
40 throw new RuleException("Unsupported message type " + msg.getClass().getName() + "!"); 42 throw new RuleException("Unsupported message type " + msg.getClass().getName() + "!");
41 } 43 }
42 KafkaActionPayload payload = ((KafkaActionMsg) msg).getPayload(); 44 KafkaActionPayload payload = ((KafkaActionMsg) msg).getPayload();
43 - 45 + log.debug("Processing kafka payload: {}", payload);
44 try { 46 try {
45 producer.send(new ProducerRecord<>(payload.getTopic(), payload.getMsgBody()), 47 producer.send(new ProducerRecord<>(payload.getTopic(), payload.getMsgBody()),
46 (metadata, e) -> { 48 (metadata, e) -> {
@@ -78,6 +78,7 @@ public class GatewaySessionCtx { @@ -78,6 +78,7 @@ public class GatewaySessionCtx {
78 Device newDevice = new Device(); 78 Device newDevice = new Device();
79 newDevice.setTenantId(gateway.getTenantId()); 79 newDevice.setTenantId(gateway.getTenantId());
80 newDevice.setName(deviceName); 80 newDevice.setName(deviceName);
  81 + newDevice.setType("default");
81 return deviceService.saveDevice(newDevice); 82 return deviceService.saveDevice(newDevice);
82 }); 83 });
83 GatewayDeviceSessionCtx ctx = new GatewayDeviceSessionCtx(this, device); 84 GatewayDeviceSessionCtx ctx = new GatewayDeviceSessionCtx(this, device);