This commit is contained in:
GYJ
2025-01-08 21:50:42 +08:00
parent 24f8934541
commit 239e593c61
3 changed files with 31 additions and 5 deletions

11
pom.xml
View File

@@ -492,11 +492,12 @@
<artifactId>junit</artifactId> <artifactId>junit</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<!--<dependency>-->
<!--<groupId>com.baidu.aip</groupId>--> <dependency>
<!--            <artifactId>java-sdk</artifactId>--> <groupId>com.sproutsocial</groupId>
<!--            <version>4.11.3</version>--> <artifactId>nsq-j</artifactId>
<!--</dependency>--> <version>1.4.9</version>
</dependency>
</dependencies> </dependencies>
<build> <build>

View File

@@ -0,0 +1,20 @@
package com.sqx.nsq;
import com.sproutsocial.nsq.Subscriber;
/**
* @author GYJoker
*/
public class PubExample {
public static void handleData(byte[] data) {
System.out.println("Received:" + new String(data));
}
public static void main(String[] args) {
Subscriber subscriber = new Subscriber("47.122.26.160");
subscriber.subscribe("test", "channel1", PubExample::handleData);
}
}

View File

@@ -9,6 +9,11 @@ server:
servlet: servlet:
context-path: /czg context-path: /czg
nsq:
lookup-addresses: 127.0.0.1:4161 # 这里填写你的NSQ lookupd服务地址和端口示例用本地地址
topic: test_topic # 定义要使用的NSQ主题
channel: test_channel # 定义NSQ通道
spring: spring:
main: main:
allow-circular-references: true allow-circular-references: true