When you want to schedule a particular task or job within Red5, you have at least two options available which are built into the server. We use Quartz for our scheduler, but you are not required to use it; I just wanted to get that disclaimer out of the way, this is Java so use whatever you like. Â The first option is the “server-wide” scheduler which is created when the server starts up and requires no configuration from your application. This scheduler is sufficient for most of the jobs you may want to create, but you will run into problems if you attempt to access an application class from within your job. The second option resolves this issue by providing an application level scheduler, one which can access your classes. The only caveat with this scheduler is that you must provide some configuration details, your applications context name.
Accessing the “server-wide” scheduler is done in your application like so (using scope):
schedulingService = (ISchedulingService) scope.getContext().getBean(ISchedulingService.BEAN_NAME);
Accessing the application scheduler is slightly different (using app context):
schedulingService = (ApplicationSchedulingService) ((BeanFactory) applicationContext).getBean("scheduler");
I prefer to make sure the schedulingService member is setup in my “appStart” method, since this is essentially where the application is “started” within Red5.
The following entry must be made in your applications red5-web.xml file if you want to use an application scheduler:
<bean id="scheduler" class="org.red5.server.scheduling.ApplicationSchedulingService"> <property name="applicationName" value="myapp" /> </bean>
Make sure you set the correct application name / context (replace “myapp”).
Once you have the scheduling service, you can add your job amongst many other options which I don’t want to cover here.