# study-nsq-java **Repository Path**: haiyang.sun/study-nsq-java ## Basic Information - **Project Name**: study-nsq-java - **Description**: spring boot used nsq - **Primary Language**: Java - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2018-05-10 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # study-nsq-java #### 项目介绍 spring boot used nsq #### 软件架构 软件架构说明 #### 安装教程 ``` com.github.brainlag nsq-client 1.0.0.RC4 ``` #### 使用说明 ``` @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()); } } ```