代码拉取完成,页面将自动刷新
spring boot used nsq
软件架构说明
<dependency>
<groupId>com.github.brainlag</groupId>
<artifactId>nsq-client</artifactId>
<version>1.0.0.RC4</version>
@Test
public void sub(){
NSQLookup lookup = new DefaultNSQLookup();
lookup.addLookupAddress("localhost", 4161);
NSQConsumer consumer = new NSQConsumer(lookup, "test", "dustin", (message) -> {
System.out.println("received: " + new String(message.getMessage() ));
System.out.println("received-id: " + new String(message.getId()));
//now mark the message as finished.
message.finished();
//or you could requeue it, which indicates a failure and puts it back on the queue.
//message.requeue();
});
consumer.start();
//线程睡眠,让程序执行完
while (true){
}
}
@Test
public void pub(){
try {
NSQProducer producer = new NSQProducer().addAddress("localhost", 4150).start();
producer.produce("test", ("this is a message").getBytes());
}
catch (NSQException e){
System.out.println(e.getMessage());
}
catch (TimeoutException e){
System.out.println(e.getMessage());
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。