[SNMP4J] Multithreaded Agent problem ?
JD Bertron
jbertron at sfa.com
Fri Jul 21 01:24:17 CEST 2006
Hey Frank,
I've been testing with the BaseAgent. I wanted to handle multiple requests
concurrently so I could see the effect of some queries taking longer than
others on an different application I wrote.
I added a thread pool to my agent (command processor) and it properly
handles the requests if they come in one at a time. But when one request
takes longer to handle than others, if another request arrives before it is
done processing, the first query's response is never sent.
I tracked it down to the MPv3.Cache.popEntry which returns null and causes
MPv3.prepareResponseMessage() to return with SNMP_MP_UNKNOWN_MSGID.
First, I though my entries were getting GC'd because of the WeakHashMap but
in fact, it's because the new request gets assigned a 'NONE' PduHandle in
MPv3.prepareDataElements(). There is even a comment about it in the code:
"RFC3412 ?7.2.10 - Received PDU is NOT a response or internal class
message -> PduHandle := NONE");
sendPduHandle.setTransactionID(PduHandle.NONE);
Because both requests end up with the same key in the cache, only the last
request that comes in gets a response, since the popEntry will remove the
state reference and the 'long' request that arrived first ends up failing
the statereference lookup.
Is this problem already documented, or am I approaching things the wrong way
?
And of course your favorite: what do you suggest ?
J.D. Bertron.
SFA Charleston.
843-202-2593.
More information about the SNMP4J
mailing list