[SNMP4J] DefaultUdpTransportMapping and Threads
Frank Fock
fock at agentpp.com
Tue May 2 23:26:52 CEST 2006
Hi Stefan,
The recommended approach is to share the Snmp and
the transport mapping instance for all requests.
UDP is *not* connection oriented. Thus, you can
(and should) use a single transport mapping for
many targets.
I think I will dedicate a chapter in my yet to
write SNMP4J book for this subject ;-). It is
really a FAQ.
Never mind, I hope my tip helps anyway!
Best regards,
Frank
Stefan Majer wrote:
> Hi,
>
> Im currently developing a application based on Java5 and EJB3 deployed
> to jboss4 as application server.
> The application server fires every minute a snmprequest and a executor
> checks if the the request takes longer than a specified timeout.
>
> The snmprequest looks:
>
> transport = new DefaultUdpTransportMapping();
> ((DefaultUdpTransportMapping)transport).setSocketTimeout(0);
> snmp.listen();
>
> ...
> target.setAddress(targetAddress);
> target.setRetries(0);
> target.setTimeout(timeout);
> target.setVersion(SnmpConstants.version2c);
> target.setCommunity(new OctetString(community));
> PDU pdu = new PDU();
> pdu.add(new VariableBinding(new OID(oid)));
> pdu.setType(PDU.GET);
> ResponseEvent response = snmp.send(pdu, target);
>
> ....
> snmp.close();
> transport.close();
>
> If host is unreachable or there is no snmpd listen, snmp.close() never
> returns and i get one more thread of a DefaultUdpTransportMapping every
> request.
>
> When i now set the Timeout for the DefaultUdpTransportMapping to a Value
> other than Zero, it works all fine.
> But i need to have a Zero Timeout because the timeout reduces the amount
> of snmprequest i can send per Intervall.
>
> Any help appreciated
>
>
> Stefan Majer <stefan at x-cellent.com>
> x-cellent technologies GmbH
>
> _______________________________________________
> SNMP4J mailing list
> SNMP4J at agentpp.org
> http://lists.agentpp.org/mailman/listinfo/snmp4j
--
AGENT++
http://www.agentpp.com
http://www.mibexplorer.com
http://www.mibdesigner.com
More information about the SNMP4J
mailing list