JMS(Java Message Service) 메시지를 보내는 태스크 개발

대기열 또는 토픽에 JMS(Java™ Message Service) 메시지를 전송하는 태스크를 작성합니다. 스케줄러 API 및 WASScheduler MBean API는 TaskInfo 인터페이스의 서로 다른 구현을 지원합니다. 각 구현은 특정 작업 유형을 스케줄하는 데 사용할 수 있습니다.

이 태스크 정보

JMS(Java Message Service) 메시지를 큐나 토픽으로 보내는 태스크를 작성하려면 다음 단계를 사용하십시오.

프로시저

  1. Scheduler.createTaskInfo() 팩토리 메소드를 사용하여 MessageTaskInfo 인터페이스 인스턴스를 작성하십시오. JSP(JavaServer Pages) 파일, 서블릿 또는 EJB 컨테이너를 사용하여 다음 코드 예제에 표시된 인스턴스를 작성하십시오.
    //lookup the scheduler to be used
    Scheduler scheduler = (Scheduler)new InitialContext.lookup("java:comp/env/Scheduler");
    
    MessageTaskInfo taskInfo = (MessageTaskInfo) scheduler.createTaskInfo(MessageTaskInfo.class);
    또한 wsadmin 도구를 사용하고 다음 JACL 스크립팅 예에 표시된 대로 인스턴스를 작성할 수 있습니다.
     # Sample create a task using MessageTaskInfo task type
    # Call this mbean with the following parameters:
    #    <scheduler jndiName>     = JNDI name of the scheduler resource, 
    #                               for example scheduler/myScheduler
    #    <JNDI name of the QCF>   = The global JNDI name of the Queue Connection Factory.
    #    <JNDI name of the Queue> = The global JNDI name of the Queue destination
    
    set jndiName [lindex $argv 0]
    set jndiName_QCF [lindex $argv 1]
    set jndiName_Q [lindex $argv 2]
    
    # Map the JNDI name to the mbean name.  The mbean name is formed by replacing the / in the jndi name
    # with . and prepending Scheduler_
    regsub -all {/} $jndiName "." jndiNameset mbeanName Scheduler_$jndiName
    
    puts "Looking-up Scheduler MBean $mbeanName"
    set sched [$AdminControl queryNames WebSphere:*,type=WASScheduler,name=$mbeanName]
    puts $sched
    
    # Get the ObjectName format of the Scheduler MBean
    set schedO [$AdminControl makeObjectName $sched]
    
    # Create a MessageTaskInfo object using invoke_jmx
    puts "Creating MessageTaskInfo"
    set params [java::new {java.lang.Object[]} 1]
    $params set 0 [java::field com.ibm.websphere.scheduler.MessageTaskInfo class]
    
    set sigs [java::new {java.lang.String[]} 1]
    $sigs set 0 java.lang.Class
    
    set ti [$AdminControl invoke_jmx $schedO createTaskInfo $params $sigs]
    set mti [java::cast com.ibm.websphere.scheduler.MessageTaskInfo  $ti]
    puts "Created the MessageTaskInfo object: $mti"
    주의: MessageTaskInfo 오브젝트를 작성해도 태스크가 지속적인 저장소에 추가되지는 않습니다. 오히려, 필요한 데이터를 위한 플레이스홀더를 작성합니다. 스케줄러 주제의 태스크 제출에서 설명한 대로, 스케줄러에서 create() 메소드를 호출할 때까지 태스크는 지속적 저장소에 추가되지 않습니다.
  2. MessageTaskInfo 오브젝트에서 매개변수를 설정하십시오. TaskInfo 인터페이스에는 태스크의 실행 시기 및 태스크 실행 시 수행하는 작업을 포함하여 태스크 실행을 제어하는 데 사용할 수 있는 여러 set() 메소드가 들어 있습니다.

    TaskInfo 인터페이스는 API 문서에 설명된 대로 추가 동작 설정을 지정합니다. JSP(JavaServer Pages) 파일, 서블릿 또는 EJB 컨테이너를 사용하여 다음 코드 예제에 표시된 인스턴스를 작성하십시오.

    //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);
    wsadmin 도구를 사용하여 다음 JACL 스크립트 예제에서 표시된 대로, 인스턴스를 작성할 수도 있습니다.
    # Setup the task 
    puts "Setting up the task..."
    # Set the startTime if you want the task to run at a specific time, for example:
    $mti setStartTime [java::new {java.util.Date long} [java::call System currentTimeMillis]]
    
    # Set the StartTimeInterval so the task runs in 30 seconds from now
    $mti setStartTimeInterval 30seconds
    
    # Set the global JNDI name of the QCF & Queue to send the message to.
    $mti setConnectionFactoryJndiName $jndiName_QCF
    $mti setDestinationJndiName $jndiName_Q
    
    # Set the message
    $mti setMessageData "Test Message"
    
    # Do not purge the task when it's complete
    $mti setAutoPurge false
    
    # Set the name of the task.  이는 문자열 값일 수 있습니다. $mti setName Created_by_MBean
    
    # If the task needs to run with specific authorization you can set the tasks Authentication Alias
    # Authentication aliases are created using the Admin Console.
    # $mti setAuthenticationAlias {myRealm/myAlias}
    
    puts "Task setup completed."

결과

JMS 메시지를 전송하는 태스크와 관련된 모든 데이터를 포함하는 MessageTaskInfo 오브젝트가 작성되었습니다.

다음에 수행할 작업

스케줄러 주제의 태스크 제출에서 설명한 대로, 작성을 위해 스케줄러에 태스크를 제출합니다.

주제 유형을 표시하는 아이콘 태스크 주제



시간소인 아이콘 마지막 업데이트 날짜: last_date
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-nd-mp&topic=tsch_schedulemtask
파일 이름:tsch_schedulemtask.html