2014-02-18 2 views
1

XML을 사용하여 EJB 스케줄러를 호출 할 수 있습니다 (또는 @Schedule 주석을 사용하여 수행 할 수 있음). [EJB-jar.xml의]올바른 스케줄러 시간을 설정하는 방법

<?xml version="1.0" encoding="UTF-8"?> 
    <ejb-jar xmlns="http://java.sun.com/xml/ns/javaee" version="3.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd"> 
     <enterprise-beans> 
      <session> 
       <ejb-name>[name]</ejb-name> 
       <ejb-class>[path]</ejb-class> 
       <session-type>Stateless</session-type> 
       <timer> 
        <schedule> 
         <minute>*/30</minute> 
         <hour>*</hour> 
         <month>*</month> 
         <year>*</year> 
        </schedule> 
        <timeout-method> 
         <method-name>[method name]</method-name> 
        </timeout-method> 
       </timer> 
      </session> 
     </enterprise-beans> 
    </ejb-jar> 

I 중순 밤에 매일 나는 이런 식으로 뭔가를 작성해야이 스케줄러를 실행해야하는 경우이 같은 인스턴스 뭔가?

<schedule> 
     <minute>*</minute> 
     <hour>0</hour> 
     <month>*</month> 
     <year>*</year> 
    </schedule> 

01:00 AM이 필요하면 정확합니까? 오전 1시

<schedule> 
    <minute>0</minute> 
    <hour>0</hour> 
</schedule> 

매일 : 매일 자정에 들어

답변

9

:

<schedule> 
     <minute>*</minute> 
     <hour>1</hour> 
     <month>*</month> 
     <year>*</year> 
    </schedule> 

덕분에 같은 일 것입니다

<schedule> 
    <minute>0</minute> 
    <hour>1</hour> 
</schedule> 

명심 *은 주어진 속성에 대해 가능한 모든 값 을 의미하는 와일드 카드입니다., 나는 그들의 디폴트 값이 *이기 때문에 달과 해를 생략했으며 실제로 기본값을 0이라고하는 분을 생략 할 수있었습니다. 매일 매 분마다 10 초 동안

<schedule> 
    <minute>*</minute> 
    <hour>*</hour> 
</schedule> 

: 매일 분당

<schedule> 
    <second>*/10</second> 
    <minute>*</minute> 
    <hour>*</hour> 
</schedule> 

x/yx부터 모든 y 수단과 */y마다 y 기동 수단 0에서. 당신의 예에서

, 이와 같은 일이 :

<schedule> 
    <minute>*</minute> 
    <hour>0</hour> 
    <month>*</month> 
    <year>*</year> 
</schedule> 

12:00, 12시 1분 12:02 즉 오전 12시 59분에서 오전 12시까지 사이의 매 순간마다 일을 의미 ..

자세한 내용은 check this link

+0

감사합니다. 그리고 나는 또 다른 질문이 있습니다. 1 분마다 쓸 필요가 있다면 그냥 쓸 것입니다 그렇지 않습니까? 그리고 매 10 초가 필요합니까? */6? 맞습니까? – grep

+0

나에게도이 예제를 줄 수 있습니까? 감사합니다 :) 그리고 대답으로 확인해 보겠습니다. – grep

+0

및 - 이는 오전 12 시부 터 오전 12시 30 분 사이의 매일 30 분마다 즉 매일 01:00, 01:30과 같은 것을 의미합니다. .. 맞아? – grep

관련 문제