我正在尝试实施WebLogic作业调度示例,以测试我的计划任务中的故障转移群集功能(以确保在故障转移方案中执行这些任务)。
考虑到这一点,我一直关注this example并尝试相应地配置所有内容。以下是我到目前为止所做的步骤:
ACTIVE
和WEBLOGIC_TIMERS
; TimerListener
)
和 servlet 来初始化作业
安排,如下:
package timedexecution;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import commonj.timers.Timer;
import commonj.timers.TimerListener;
import commonj.timers.TimerManager;
public class TimerServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
protected static void logMessage(String message, PrintWriter out){
out.write("<p>"+ message +"</p>");
System.out.println(message);
}
@Override
public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
PrintWriter out = response.getWriter();
//
out.println("<html>");
out.println("<head><title>TimerServlet</title></head>");
//
try {
//
logMessage("service() entering try block to intialize the timer from JNDI", out);
//
InitialContext ic = new InitialContext();
TimerManager jobScheduler = (TimerManager)ic.lookup("weblogic.JobScheduler");
//
logMessage("jobScheduler reference " + jobScheduler, out);
//
jobScheduler.schedule(new ExampleTimerListener(), 0, 30*1000);
//
logMessage("Timer scheduled!", out);
//
//execute this job every 30 seconds
logMessage("service() started the timer", out);
//
logMessage("Started the timer - status:", out);
//
}
catch (NamingException ne) {
String msg = ne.getMessage();
logMessage("Timer schedule failed!", out);
logMessage(msg, out);
}
catch (Throwable t) {
logMessage("service() error initializing timer manager with JNDI name weblogic.JobScheduler " + t,out);
}
//
out.println("</body></html>");
out.close();
}
private static class ExampleTimerListener implements Serializable, TimerListener {
private static final long serialVersionUID = 8313912206357147939L;
public void timerExpired(Timer timer) {
SimpleDateFormat sdf = new SimpleDateFormat();
System.out.println( "timerExpired() called at " + sdf.format( new Date() ) );
}
}
}
然后我执行servlet以在第一个托管实例( Noddy 服务器)上启动调度,该实例按预期返回:
(Servlet 执行输出)
service()输入try block to 从JNDI初始化计时器
jobScheduler参考 weblogic.scheduler.TimerServiceImpl@43b4c7
预定定时器!
service()启动了计时器
启动计时器 - 状态:
这导致在我的数据库表中创建了2行:
WEBLOGIC_TIMERS
表状态:
“EDIT”; “TIMER_ID”; “监听器”; “开始时间”; “间隔”; “TIMER_MANAGER_NAME”; “DOMAIN_NAME”; “CLUSTER_NAME”;
“”; “Noddy_1268653040156”; “[数据类型]”; “1268653040156”; “30000”; “weblogic.JobScheduler”; “myCluster中”; “群集”
ACTIVE
表状态:
“EDIT”; “服务器”; “INSTANCE”; “DOMAINNAME”; “CLUSTERNAME”; “超时”;
“”; “service.SINGLETON_MASTER”; “6382071947583985002 /诺迪”; “QRENcluster”; “簇”; “15年3月10日”
虽然,作业没有按计划执行。它应该在服务器的日志输出(Noddy.out
文件)上打印一条带有时间戳的消息,说明计时器已过期。它没有。我的日志文件如下:
管理服务器日志(myCluster.log
文件):
####<15/Mar/2010 10H45m GMT> <Warning> <Cluster> <test-ad> <Noddy> <[STANDBY] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1268649925727> <BEA-000192> <No currently living server was found that could host TimerMaster. The server will retry in a few seconds.>
Noddy服务器日志
(Noddy.out
档案):
service() entering try block to intialize the timer from JNDI
jobScheduler reference weblogic.scheduler.TimerServiceImpl@43b4c7
Timer scheduled!
service() started the timer
Started the timer - status:
<15/Mar/2010 10H45m GMT> <Warning> <Cluster> <BEA-000192> <No currently living server was found that could host TimerMaster. The server will retry in a few seconds.>
(Noddy.log
档案):
####<15/Mar/2010 11H24m GMT> <Info> <Common> <test-ad> <Noddy> <[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1268652270128> <BEA-000628> <Created "1" resources for pool "TxDataSourceOracle", out of which "1" are available and "0" are unavailable.>
####<15/Mar/2010 11H37m GMT> <Info> <Cluster> <test-ad> <Noddy> <[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'> <<anonymous>> <> <> <1268653040226> <BEA-000182> <Job Scheduler created a job with ID Noddy_1268653040156 for TimerListener with description timedexecution.TimerServlet$ExampleTimerListener@2ce79a>
####<15/Mar/2010 11H39m GMT> <Info> <JDBC> <test-ad> <Noddy> <[ACTIVE] ExecuteThread: '3' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1268653166307> <BEA-001128> <Connection for pool "TxDataSourceOracle" closed.>
任何人都可以帮我发现我的配置有什么问题吗?在此先感谢您的帮助!
答案 0 :(得分:1)
我最终通过重新启动整个系统然后从命令行启动WebLogic实例来解决此问题。从这个角度来看,我设法让它工作,输出被发送到命令行。
我要感谢所有试图帮助我解决这个问题的人。
答案 1 :(得分:1)
还尝试添加调试(JAVA_OPTIONS:-Dweblogic.debug.DebugSingletonServices = true -Dweblogic.JobScheduler = true)
对我来说,仅通过Console将它放在服务器启动参数中是不够的。我不得不放入setDomainEnv.sh。