Browse Source

last commit

shjung 11 months ago
parent
commit
06c42106bd

+ 1 - 0
pom.xml

@@ -115,6 +115,7 @@
                 </configuration>
             </plugin>
         </plugins>
+        <finalName>${artifactId}</finalName>
     </build>
 
 </project>

+ 1 - 1
src/main/java/com/tsi/comm/consumer/TsiCommConsumerApplication.java

@@ -79,7 +79,7 @@ public class TsiCommConsumerApplication implements ApplicationRunner, Applicatio
             }
         }
 
-        List<String> keyValues = new ArrayList<String>();
+        List<String> keyValues = new ArrayList<>();
         String[] nodeIds = nodeId.split(",");
         for (int ii = 0; ii < nodeIds.length; ii++) {
             String node = nodeIds[ii].trim();

+ 8 - 6
src/main/java/com/tsi/comm/consumer/kafka/KafkaConsumerService.java

@@ -25,23 +25,25 @@ public class KafkaConsumerService {
     private ConcurrentMessageListenerContainer<String, byte[]> kafkaListenerContainer;
 
     public void start() {
-        log.info("Starting Kafka: {}, {}, {}, {}", this.bootstrapServers, this.topic, this.groupId, this.keyValues);
+        log.info("Starting Kafka Consumer: bootstrapServers: {}, topic: {}, group: {}, keys: {}", this.bootstrapServers, this.topic, this.groupId, this.keyValues);
 
+        HashSet<String> keys = new HashSet<>(this.keyValues);
+
+        HashSet<String> topics = new HashSet<>();
         String consumerTopic = "node";
-        HashSet<String> keys = new HashSet<String>();
         if ("test".equals(this.topic)) {
             consumerTopic = "topic-for-ssd-test";
-            keys.add(consumerTopic);
+            topics.add(consumerTopic);
         }
         else if ("cvim".equals(topic)) {
             consumerTopic = "cvim-raw";
-            keys.add(consumerTopic);
+            topics.add(consumerTopic);
         }
         else {
-            keys.addAll(this.keyValues);
+            topics = keys;
         }
 
-        ContainerProperties containerProperties = new ContainerProperties(keys.toArray(new String[0]));
+        ContainerProperties containerProperties = new ContainerProperties(topics.toArray(new String[0]));
         containerProperties.setGroupId(this.groupId);
         containerProperties.setPollTimeout(5000);
         //containerProperties.setAckMode(ContainerProperties.AckMode.MANUAL);

+ 1 - 1
src/main/java/com/tsi/comm/consumer/kafka/TsiKafkaConsumerWorker.java

@@ -31,7 +31,7 @@ public class TsiKafkaConsumerWorker implements MessageListener<String, byte[]> {
         int tail = 0;
         if ("cvim-raw".equals(this.topic)) {
             idx = 27 + 6;
-            //tail = -2;
+            tail = -2;
         }
         else if ("topic-for-ssd-test".equals(this.topic)) {
             int stx1    = buffer[idx++];

+ 8 - 0
src/test/java/com/tsi/comm/consumer/TsiCommConsumerApplicationTests.java

@@ -1,10 +1,12 @@
 package com.tsi.comm.consumer;
 
+import com.tsi.app.common.utils.ByteUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.junit.jupiter.api.Test;
 
 import java.net.InetAddress;
 import java.net.UnknownHostException;
+import java.util.Arrays;
 import java.util.HashSet;
 import java.util.concurrent.Executors;
 import java.util.concurrent.ThreadFactory;
@@ -27,6 +29,12 @@ public class TsiCommConsumerApplicationTests {
         log.info(" toArray: {}", (Object) keys.toArray(new String[0]));
     }
 
+    @Test
+    public void test2() {
+        String data = "02C518081A01061A11571DB1020C00020003010004006C00001900C800400200140050088040000802A0040021001001408100020C10608000010808A0000000000000000000000000000000000000000000000000000000000000000000000000000001FFC234B7EEAFFBEBB2EDEFFF0C123C030A1E020307140203020C1B320203000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003010104006C00008128084441200A0451508882401408A2A0000001001000400102021010808000040820A0000000000000000000000000000000000000000000000000000000000000000000000000000001FF020303030B0C5CEDAFBBFB3BFF0C123C030A1E03071403020C1B32020300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000E803";
+        byte[] inBytes = ByteUtils.hexToByteArray(data);
+        log.info("{}", Arrays.toString(inBytes));
+    }
     @Test
     public void test1() {
         String hostName;