Thread and Listener

B

Bob Rivers

Hi,

I'm doing some experiences with JOESNMP. It's very good. Guided by the
examples I was able to build a listener that receives snmp traps. It's
working fine (when running through console).

So I decided to start it automatically, together with my web
application (that is running under tomcat).

I have a servlet that is executed when tomcat starts (using
<load-on-startup>). So I did a call to my new class.

The problem is that this class is actually a listener. When it starts,
it hangs the other procedures, including tomcat initilization.

I tryed to put it under a thread, but it also hangs as soon it starts
to listen for snmp traps.

How do I ran a listner without blocking other processes? I am looking
for a solution that should work both on linux and windows.

I don't know if I made myself understood. Sorry my poor english.
TIA,

Bob
 
S

Sudsy

Bob Rivers wrote:
How do I ran a listner without blocking other processes? I am looking
for a solution that should work both on linux and windows.

Perhaps a change in architecture? How about if your listener just performs
a POST to the webserver each time it receives a trap? That way you can run
it stand-alone, perhaps just modify the Tomcat startup script to also fire
up your daemon.
 
C

Chris Smith

Bob Rivers said:
I have a servlet that is executed when tomcat starts (using
<load-on-startup>). So I did a call to my new class.

The problem is that this class is actually a listener. When it starts,
it hangs the other procedures, including tomcat initilization.

The simple answer is to create a new thread for it. However, pay
attention to Sudsy's response as well. When you are creating separate
threads inside a servlet container to do things that have nothing to do
with answering HTTP requests, you're quite possibly doing something
wrong.

--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
C

celeste zhu via JavaKB.com

could the joesnmp provide the setting function like "snmpset of net-snmp"?
i study the test sample in opennms: snmpwalk.java

i guess if i want to set new value to some OID, the following code is enough:

SnmpVarBind[] vblist = { new SnmpVarBind(walker.m_startOid),1 };
SnmpPduRequest pdu = new SnmpPduRequest(SnmpPduPacket.SET, vblist);

or i should change "1" to some handler of "org.opennms.protocols.snmp.SnmpInt32"

right?!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top