[SNMP4J] SNMP4J multiple threads
Francis LIMOUSY
francis.limousy at bsaconseil.com
Fri Jun 29 15:40:33 CEST 2007
Hello,
I'm using snmp4j in a threaded application, fetching synchronously data.
I have this problem: threads don't seem to be de-allocated.
I have plenty of UdpDefaultTransportMapping stacking into memory until
the application crash (out of system resources).
My question is: is this a Thread issue or a snmp4j issue ?
My code is quite simple for the moment, the created threads run the
following code:
try{
TransportMapping transport = new DefaultUdpTransportMapping();
Snmp snmp = new Snmp(transport);
PDU pdu = new PDU();
for(String oid : oids){
pdu.add(new VariableBinding(new OID(oid)));
}
pdu.setType(PDU.GETNEXT);
CommunityTarget target = new CommunityTarget();
target.setCommunity(new OctetString(community));
target.setAddress(targetAddress);
target.setVersion(Integer.parseInt(version));
transport.listen();
ResponseEvent response = snmp.send(pdu, target);
if (response.getResponse() == null) {
System.out.println("Timeout");
}
else {
//handle response
(...)
}
}
I guess the problem occur here :
ResponseEvent response = snmp.send(pdu, target);
which is synchronous if I get the examples well.
So I guess some of my threads are blocking here, aren't they ?
If so, how can I specify a timeout ? Is there another way of doing this ?
Thanks for any help on this problem.
I'm using SNMP protocol v1, Java 1.5 on a windows environment
More information about the SNMP4J
mailing list