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>
<scope>test</scope>
</dependency>
<!--<dependency>-->
<!--<groupId>com.baidu.aip</groupId>-->
<!--            <artifactId>java-sdk</artifactId>-->
<!--            <version>4.11.3</version>-->
<!--</dependency>-->
<dependency>
<groupId>com.sproutsocial</groupId>
<artifactId>nsq-j</artifactId>
<version>1.4.9</version>
</dependency>
</dependencies>
<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:
context-path: /czg
nsq:
lookup-addresses: 127.0.0.1:4161 # 这里填写你的NSQ lookupd服务地址和端口示例用本地地址
topic: test_topic # 定义要使用的NSQ主题
channel: test_channel # 定义NSQ通道
spring:
main:
allow-circular-references: true