You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Oracle OCCAS平台下SIPServlet的TimerListener使用问题

Implementing Timer Trigger for SIP Servlet on Oracle OCCAS

Hey, let's walk through getting that timer properly set up in your SIP Servlet running on Oracle OCCAS. Since you already have the foundational pieces in place (implemented TimerListener, added @SipListener, overridden the timeout() method), here's how to tie it all together when handling INVITE messages:

First, a quick recap of what you've already nailed (great start!):

  • Your servlet implements the TimerListener interface
  • You've annotated the class with @SipListener
  • You've overridden the timeout() method to define your trigger action

Now let's connect the dots for scheduling the timer during INVITE processing:

  1. Retrieve the TimerService instance
    When handling an INVITE (in your doInvite() method, for example), grab the TimerService from the servlet context:

    TimerService timerService = (TimerService) getServletContext().getAttribute(TimerService.class.getName());
    
  2. Schedule the timer
    Use the createTimer() method to set when your timer should fire. For a one-time timeout after 30 seconds (adjust the delay as needed), use this:

    // Schedule timer to trigger after 30000ms (30 seconds)
    Timer timer = timerService.createTimer(30000, false, "INVITE_TIMEOUT");
    
    • The second parameter (false) marks this as a one-time timer (not recurring).
    • The third parameter is a context object (here a string) to help you identify which timer fired in the timeout() method.
  3. Execute your action on timeout
    In your overridden timeout() method, use the timer's context to run your specific logic tied to the INVITE:

    @Override
    public void timeout(Timer timer) {
        String timerContext = (String) timer.getInfo();
        if ("INVITE_TIMEOUT".equals(timerContext)) {
            // Add your custom action here: send a CANCEL, log the timeout, update state, etc.
            System.out.println("INVITE timer triggered - running specified action");
            // Insert your business logic here
        }
    }
    
  4. Clean up timers when needed
    If the INVITE gets answered before the timer fires, cancel the timer to avoid unnecessary actions:

    // Store the timer reference when creating it, then call cancel() later
    timer.cancel();
    

Quick Notes for Oracle OCCAS

  • Double-check that the @SipListener annotation is properly recognized by the OCCAS container during deployment.
  • OCCAS has specific timer service configurations—ensure the timer service is enabled in your deployment descriptor or OCCAS admin console if you hit issues.
  • Make sure any resources used in the timeout() method are thread-safe, since timer events run in a separate thread pool.

内容的提问来源于stack exchange,提问作者ACoutu

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.26 09:08:43