I have a server
in java which receive a json
file and send it to a C program by jeromq
. Until last week I just tested it with a few json. I haven't sent a lot of json until now I have another component to send them.
Glassfish
hanged with an error I have never seen before. Something like:
[2014-08-19T09:24:32.446+0000] [glassfish 4.0] [WARNING] [] [java.util.prefs] [tid: _ThreadID=141 _ThreadName=Timer-1] [timeMillis: 1408440272446] [levelValue: 900] [[
Could not lock User prefs. Unix error code 24.]]
[2014-08-19T09:24:32.446+0000] [glassfish 4.0] [WARNING] [] [java.util.prefs] [tid: _ThreadID=141 _ThreadName=Timer-1] [timeMillis: 1408440272446] [levelValue: 900] [[
Couldn't flush user prefs: java.util.prefs.BackingStoreException: Couldn't get file lock.]]
And something related to ZMQ:
[2014-08-15T08:23:30.637+0000] [glassfish 4.0] [SEVERE] [] [] [tid: _ThreadID=2432 _ThreadName=Thread-4] [timeMillis: 140809101063$
zmq.ZError$IOException: java.io.IOException: Too many open files
at zmq.Signaler.make_fdpair(Signaler.java:87)
at zmq.Signaler.<init>(Signaler.java:48)
at zmq.Mailbox.<init>(Mailbox.java:55)
at zmq.Ctx.<init>(Ctx.java:127)
at zmq.ZMQ.zmq_ctx_new(ZMQ.java:225)
at zmq.ZMQ.zmq_init(ZMQ.java:258)
at org.jeromq.ZMQ$Context.<init>(ZMQ.java:173)
at org.jeromq.ZMQ.context(ZMQ.java:155)
...
at java.lang.Thread.run(Thread.java:744)
Caused by: java.io.IOException: Too many open files
at sun.nio.ch.IOUtil.makePipe(Native Method)
at sun.nio.ch.PipeImpl.<init>(PipeImpl.java:42)
at sun.nio.ch.SelectorProviderImpl.openPipe(SelectorProviderImpl.java:50)
at java.nio.channels.Pipe.open(Pipe.java:150)
at zmq.Signaler.make_fdpair(Signaler.java:85)
... 11 more]]
I think it could be related to something worng with zmq. If server just receive a few json it never hangs.
I paste my java code, maybe I am doing something wrong or I am not closing something:
First I create a thread to make the zmq sent:
new Thread(new SubmitJSONOnBackground(json, this.context)).start();
My class to run in background:
public class SubmitJSONOnBackground implements Runnable {
private Collection<JSON> jsons;
private ServletContext context;
public SubmitObservationOnBackground(Collection<JSON> json, ServletContext context) {
this.jsons = json;
this.context = context;
}
public void run() {
SubmitJSONHandler submit = new SubmitJSONHandler(jsons, this.context);
submit.buildAndSubmitJSON();
}
}
And the method which sends zmq:
private boolean submitJSON(String message) {
ZMQ.Context context = ZMQ.context(1);
ZMQ.Socket sender = context.socket(ZMQ.PUSH);
sender.connect("tcp://127.0.0.1:9999");
sender.send(device, ZMQ.SNDMORE);
sender.send("json", ZMQ.SNDMORE);
sender.send("["+message+"]", 0);
sender.close();
context.term();
return true;
}
I think it is ok, but since it is failing something related to ZMQ
I am not sure it is ok or not.