RejectedExecutionException
-
Hi
I found an exception in my application log:java.util.concurrent.RejectedExecutionException
at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.reject(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.execute(Unknown Source)
at com.serotonin.bacnet4j.npdu.ip.IpMessageControl.run(IpMessageControl.java:431)Maybe just need to add catch for that exception, it occured when multiple threads were asking one device.
-
hi,
if you just add that particlar catch block then you loose messages.
you need to 'keep' the message and issue a simple sanity sleep.
a third of the timeout in the ipMessageControl !?!it is hard to reproduce errors ...
a few hours back a segment ack was not send for one reason...maybe you tell us what hw & sw environment you use
robert
-
Robert is correct: you want to know about those errors. The only reason an execution would be rejected is because the thread pool was full. This is curious since the implementation uses a default pool constructor that sets the maximum pool size to Integer.MAX_VALUE, which would be difficult to reach.
-
hi codemonkey,
give the folowing snippet a try:
// For receiving @Override public void run() { boolean bProcessed; int loopCounter; IncomingMessageExecutor messageExecutor; byte[] buffer = new byte[MESSAGE_LENGTH]; DatagramPacket p = new DatagramPacket(buffer, buffer.length); while (!socket.isClosed()) { try { loopCounter = 0; bProcessed = false; socket.receive(p); messageExecutor = new IncomingMessageExecutor(p); while(!bProcessed && loopCounter < 3) { try { loopCounter++; incomingExecutorService.execute(messageExecutor); bProcessed = true; } catch (RejectedExecutionException ex) { ex.printStackTrace(); try { Thread.sleep(timeout / 3); } catch (InterruptedException e) { e.printStackTrace(); } } } p.setData(buffer); } catch (IOException e) { // no op. This happens if the socket gets closed by the destroy method. } } }
it is the the modified procedure run in the ipmessagecontrol.java file.
can you post the results of your tests here?
thanks
robert -
Thank you for replying.
I'm testing latest bacnet4j version from CVS with BACnet Simulator.
I will test this code and post reply when exception appear. -
Did anyone tried this solution from Robert? If yes, please let me know.