I am using the snmp4j:2.8.10 and I am creating one Snmp object that I am reusing. Everything works fine in my implementation with the exception of the retry mechanism for informs.
For the first inform it works, as well as for the case in which my app is sending many informs at short intervals (smaller than the retry timeout) but after the last retry is sent the retry mechanism will start to fail if an inform is sent at a later time.
Decompiling the code of the snmp4j I found out that when we create the Snmp object and send a message, a java.util.Timer is created and that uses a TimerThread which is kept alive only until all the scheduled tasks are completed after which the Thread will no longer accept the scheduling of new tasks to be performed and this is causing the retry mechanism to fail.
If the Timer would be handled a little different by the Snmp object, this wouldn’t be a problem but apparently, the Snmp creates just one timer and it uses it while it accepts new tasks after which it never recreates it.
My question is, what is the recommended/intended way of reusing the Snmp object to avoid this problem ?