nsqio / nsq-java Goto Github PK
View Code? Open in Web Editor NEWofficial Java client library for NSQ
official Java client library for NSQ
Currently this library expecting Handler class which will be executed by the library and we dont have much control on this. Can you please expose a dequeue() method which will enable more flexibility for others and also Queue library should have enque(), dequeue(), delete() and delay() in my opinion.
Is there any plan for continuing to develop this project ?
It looks like we call reader.connectToNsqd() for every producer on every poll of lookupd, and we never disconnect from producers that lookupd doesn't respond to.
It seems like we should compare the list that lookupd returns to the list we have open, and open/close connections until we are reconciled.
The library should provide an easy way to post messages to nsqd. Having discussed with @danielhfrank it seems that using sockets and PUB frames isn't really necessary, all of the bit.ly systems post via HTTP.
When I used the following codes, I got connection refused exception
SyncResponseHandler sh = new PrintReader();
SyncResponseReader reader = new SyncResponseReader("lsguts", "lsguts", sh);
try {
reader.connectToNsqd("127.0.0.1", 4150);
} catch (NSQException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
reader.addLookupd(new BasicLookupd("http://127.0.0.1:4161"));
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Exception:
[pool-2-thread-1] ERROR ly.bit.nsq.lookupd.AbstractLookupd - Problem reading lookupd response:
java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at java.net.URL.openStream(Unknown Source)
at ly.bit.nsq.lookupd.BasicLookupd.query(BasicLookupd.java:24)
at ly.bit.nsq.lookupd.BasicLookupdJob.run(BasicLookupdJob.java:25)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.runAndReset(Unknown Source)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(Unknown Source)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Quartz is probably overkill for scheduling lookups. We can use native executors.
Sorry I'm a bit of a java noob - is this library available on maven central? I've looked a bit and haven't been able to find it.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.