Thread and Listener

Discussion in 'Java' started by Bob Rivers, Dec 7, 2004.

  1. Bob Rivers

    Bob Rivers Guest

    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
    Bob Rivers, Dec 7, 2004
    #1
    1. Advertising

  2. Bob Rivers

    Sudsy Guest

    Bob Rivers wrote:
    <snip>
    > 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.

    --
    Java/J2EE/JSP/Struts/Tiles/C/UNIX consulting and remote development.
    Sudsy, Dec 7, 2004
    #2
    1. Advertising

  3. Bob Rivers

    Chris Smith Guest

    Bob Rivers <> wrote:
    > 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
    Chris Smith, Dec 7, 2004
    #3
  4. 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?!

    --
    Message posted via http://www.javakb.com
    celeste zhu via JavaKB.com, Dec 23, 2004
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Danish Ahmed

    .net remoting and tcp listener socket

    Danish Ahmed, Apr 20, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    3,742
    Danish Ahmed
    Apr 21, 2005
  2. Shrish
    Replies:
    1
    Views:
    417
    Thomas Smith
    Oct 16, 2004
  3. Bob Rivers

    Thread and Listener

    Bob Rivers, Dec 7, 2004, in forum: Java
    Replies:
    0
    Views:
    348
    Bob Rivers
    Dec 7, 2004
  4. Replies:
    4
    Views:
    584
  5. gregarican

    Tkinter listener thread?

    gregarican, Jan 26, 2006, in forum: Python
    Replies:
    6
    Views:
    872
    gregarican
    Jan 27, 2006
Loading...

Share This Page