If your agent should run for a specified time only, you could also use Thread.sleep only.
Frank pradip de wrote: > Ok. Sorry if I wasnt able to point to the right place. I was using the > TestAgent.java from > (http://kickjava.com/src/org/snmp4j/agent/test/TestAgent.java.htm) and > noticed the while(true) with a sleep(1000) loop in its line 338 in the > main function which seems like a busy wait. My question was regarding > the motivation for this infinite loop to prevent the main agent thread > from exiting. Is this specifically because the listen() was deliberately > not made blocking? Is there a better way than using this infinite loop? > thanks, > Pradip > > On Fri, Aug 28, 2009 at 2:34 PM, Frank Fock <[email protected] > <mailto:[email protected]>> wrote: > > > Hi Pradip, > > Session.listen() does not block. > The rest of you assumptions do not match > with SNMP4J either and I am a bit confused > about them. Please read RFC 3410 to 3418 > to get a better understanding of the > SNMP architecture. > > Best regards, > Frank > > pradip de wrote: > > Hi, > I am trying to understand the threading structure of > TestAgent.java for my > own implementation of an SNMP agent. My question is basically > regarding the > busy wait that is there with a periodic Thread.sleep(). Why > doesnt the > BaseAgent have a while(true) loop around the session.listen() ( > which I > believe is a blocking function on incoming requests ) instead of > the busy > wait in TestAgent? Or am I missing something here? There must be > a listening > mechanims in a loop somewhere that allows the agent to respond > to multiple > SNMP requests. > As an associated question, I am trying to have my TestAgent > implement a > listener to a messagequeue to send traps out. However, it maybe > getting > blocked by the busy wait in the main thread. > I would really appreciate if someone could clarify these points > for me and > give me suggestions on how to make the agent also be a > subscriber to some > published queueing mechanism to pick up messages for sending > traps out. > > thanks, > Pradip > _______________________________________________ > SNMP4J mailing list > [email protected] <mailto:[email protected]> > http://lists.agentpp.org/mailman/listinfo/snmp4j > > > -- > AGENT++ > http://www.agentpp.com > http://www.snmp4j.com > http://www.mibexplorer.com > http://www.mibdesigner.com > > -- AGENT++ http://www.agentpp.com http://www.snmp4j.com http://www.mibexplorer.com http://www.mibdesigner.com _______________________________________________ SNMP4J mailing list [email protected] http://lists.agentpp.org/mailman/listinfo/snmp4j
