1 Star 1 Fork 0

孙海洋 / study-nsq-java

Create your Gitee Account
Explore and code with more than 6 million developers,Free private repositories !:)
Sign up
This repository doesn't specify license. Without author's permission, this code is only for learning and cannot be used for other purposes.
Clone or download
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
README.md

study-nsq-java

项目介绍

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());
		}
	}

Comments ( 0 )

Sign in for post a comment

About

Cancel

Releases

No release

Contributors

All

Activities

load more
can not load any more
Java
1
https://gitee.com/haiyang.sun/study-nsq-java.git
git@gitee.com:haiyang.sun/study-nsq-java.git
haiyang.sun
study-nsq-java
study-nsq-java
master

Search