[Version 5.0.1 and later]Developing a task that sends a JMS message

Why and when to perform this task

The scheduler API supports different implementations of the TaskInfo interface, each of which can be used to schedule a particular type of work. This topic describes how to use the MessageTaskInfo implementation, which sends a JMS message to either a queue or a topic.

Steps for this task

  1. Create an instance of the MessageTaskInfo interface by using the following Scheduler.createMessageTaskInfo() method:
    //lookup the scheduler instance to be used
    Scheduler scheduler = (Scheduler)new InitialContext.lookup("java:comp/env/Scheduler");
    
    MessageTaskInfo taskInfo = (MessageTaskInfo) scheduler.createTaskInfo(MessageTaskInfo.class);
    

    Note: Creating a MessageTaskInfo object does not add the task to the persistent store. Rather, it creates a placeholder for the necessary data. The task is not added to the persistent store until the create() method is called on a Scheduler instance, as described in the topic Submitting a task to a scheduler.

  2. Set parameters on the MessageTaskInfo object.

    The TaskInfo interface contains various set() methods that can be used to control execution of the task, including when the task will fire and what work the task will do when it fires. For example:

    //create a date object which represents 30 seconds from now
    java.util.Date startDate = new java.util.Date(System.currentTimeMillis()+30000);
    
    
    //now set the start time and the JNDI names for the queue connection factory and the queue
    taskInfo.setConnectionFactoryJndiName("jms/MyQueueConnectionFactory");
    taskInfo.setDestination("jms/MyQueue");
    taskInfo.setStartTime(startDate);

    The TaskInfo interface specifies additional control points, as documented in Javadoc.

Results

A TaskInfo object has been created that contains all of the relevant data for a task.

What to do next

Submit the task to a scheduler instance for creation, as described in the topic Submitting a task to a scheduler.

Related tasks
Developing a task that calls a session bean
Receiving scheduler notifications
Developing a task that sends a JMS message
Managing the scheduler service
Related reference
Scheduler interface



Searchable topic ID:   tsch_schedulemtask
Last updated: Jun 21, 2007 8:07:48 PM CDT    WebSphere Business Integration Server Foundation, Version 5.0.2
http://publib.boulder.ibm.com/infocenter/wasinfo/index.jsp?topic=/com.ibm.wasee.doc/info/ee/scheduler/tasks/tsch_schedulemtask.html

Library | Support | Terms of Use | Feedback