1 DestinationResolver
聽聽聽 DestinationResolver鎺ュ彛鐨勪綔鐢ㄦ槸灝嗘寚瀹氱殑鐩殑鍦板悕瑙f瀽涓虹洰鐨勫湴瀹炰緥銆傚叾瀹氫箟濡備笅錛?/p>
聽聽聽 鍙傛暟pubSubDomain鐢ㄤ簬鎸囧畾鏄嬌鐢ㄢ滃彂甯?璁㈤槄鈥濇ā寮忥紙瑙f瀽鍚庣殑鐩殑鍦版槸Topic錛夛紝榪樻槸浣跨敤鈥滅偣瀵圭偣鈥濇ā寮忥紙瑙f瀽鍚庣殑鐩殑鍦版槸Queue錛夈?/p>
聽
聽聽聽 CachingDestinationResolver鎺ュ彛緇ф壙浜咲estinationResolver錛屽鍔犱簡緙撳瓨鐨勫姛鑳斤紝鍏舵帴鍙e畾涔夊涓嬶細
聽聽聽 鍦ㄧ洰鐨勫湴澶辨晥鐨勬椂鍊欙紝removeFromCache鏂規硶浼氳璋冪敤錛涘湪JMS provider澶辨晥鐨勬椂鍊欙紝clearCache鏂規硶浼氳璋冪敤銆?br />
1.1 DynamicDestinationResolver
聽聽聽 DynamicDestinationResolver瀹炵幇浜咲estinationResolver鎺ュ彛銆傛牴鎹寚瀹氱殑鐩殑鍦板悕錛孌ynamicDestinationResolver浼氬姩鎬佸垱寤虹洰鐨勫湴瀹炰緥銆傞拡瀵笿MS1.1瑙勮寖錛屽畠閲囩敤濡備笅鏂規硶鍒涘緩鐩殑鍦幫細
1.2 JndiDestinationResolver
聽聽聽 JndiDestinationResolver緇ф壙鑷狫ndiLocatorSupport錛?
鍚屾椂瀹炵幇浜咰achingDestinationResolver鎺ュ彛銆傚鏋滃湪JMS
provider涓厤緗簡闈欐佺洰鐨勫湴錛岄偅涔圝ndiDestinationResolver閫氳繃JNDI鏌ユ壘鐨勬柟寮忚幏寰楃洰鐨勫湴瀹炰緥銆?/p>
聽聽聽
JndiDestinationResolver鐨刦allbackToDynamicDestination灞炴х敤浜庢寚瀹氬湪JNDI鏌ユ壘澶辮觸鍚庯紝鏄惁浣?
鐢ㄥ姩鎬佺洰鐨勫湴錛岄粯璁ゅ兼槸false銆侸ndiDestinationResolver鐨刢ache灞炴х敤浜庢寚瀹氭槸鍚﹀鐩殑鍦板疄渚嬭繘琛岀紦瀛橈紝榛樿鍊兼槸
true銆?/p>
聽
1.3 BeanFactoryDestinationResolver
聽聽聽 BeanFactoryDestinationResolver瀹炵幇浜咲estinationResolver鎺ュ彛鍜孊eanFactoryAware鎺ュ彛銆傚畠浼氭牴鎹寚瀹氱殑鐩殑鍦板悕浠嶣eanFactory涓煡鎵劇洰鐨勫湴瀹炰緥銆備互涓嬫槸鐩稿叧鐨勪唬鐮侊細
聽
2 JmsAccessor
聽聽聽
鎶借薄綾籎msAccessor鏄疛msTemplate銆丼impleMessageListenerContainer鍜?
DefaultMessageListenerContainer絳塩oncrete
class鐨勫熀綾匯侸msAccessor瀹氫箟浜嗗涓嬪嚑涓敤浜庤闂甁MS鏈嶅姟鐨勫叡閫氬睘鎬с?/p>
聽聽聽 JmsAccessor鎻愪緵浜嗗垱寤篊onnection鍜孲ession鐨勬柟娉曪紝濡備笅錛?/p>
聽
2.1 JmsDestinationAccessor
聽聽聽
鎶借薄綾籎msDestinationAccessor緇ф壙鑷狫msAccessor錛屽鍔犱簡destinationResolver鍜?
pubSubDomain灞炴с俤estinationResolver鐨勯粯璁ゅ兼槸DynamicDestinationResolver鐨勫疄渚嬶紝涔熷氨鏄?
璇撮粯璁ら噰鐢ㄥ姩鎬佺洰鐨勫湴瑙f瀽鐨勬柟寮忥紱pubSubDomain鐢ㄤ簬鎸囧畾鏄嬌鐢ㄢ滃彂甯?璁㈤槄鈥濇ā寮忚繕鏄嬌鐢ㄢ滅偣瀵圭偣鈥濇ā寮忥紝榛樿鍊兼槸false銆?br />
聽聽聽 JmsDestinationAccessor鎻愪緵浜嗙敤浜庤В鏋愮洰鐨勫湴鐨勬柟娉曪紝濡備笅錛?/p>
2.2 AbstractJmsListeningContainer
聽聽聽 AbstractJmsListeningContainer緇ф壙鑷狫msDestinationAccessor錛屼綔涓烘墍鏈塎essage
Listener Container鐨勫叕鍏卞熀綾匯傚畠涓昏鎻愪緵浜咼MS
connection鐨勭敓鍛藉懆鏈熺鐞嗙殑鍔熻兘錛屼絾鏄病鏈夊娑堟伅鎺ユ敹鐨勬柟寮忥紙涓誨姩鎺ユ敹鏂瑰紡鎴栬呭紓姝ユ帴鏀舵柟寮忥級絳夊仛浠諱綍鍋囧畾銆傝綾諱富瑕佺殑灞炴у涓嬶細
聽聽聽 clientId閫氬父鐢ㄤ簬鎸佷箙璁㈤槄錛泂haredConnection淇濆瓨浜嗚鍏變韓鐨凧MS connection銆?/p>
聽
聽聽聽 璇ョ被瀹氫箟浜嗗涓嬬殑鎶借薄鏂規硶錛屼互渚垮瓙綾誨彲浠ュ喅瀹氭槸鍚︿嬌鐢ㄥ叡浜殑JMS connection銆?/p>
聽
2.3 AbstractMessageListenerContainer
聽聽聽 AbstractMessageListenerContainer緇ф壙鑷狝bstractJmsListeningContainer錛屼篃鏄綔涓烘墍鏈塎essage Listener Container鐨勫叕鍏卞熀綾匯傝綾諱富瑕佺殑灞炴у涓嬶細
聽聽聽 destination鐢ㄤ簬鎸囧畾鎺ユ敹娑堟伅鐨勭洰鐨勫湴銆?br /> 聽聽聽 messageListener鐢ㄤ簬鎸囧畾澶勭悊娑堟伅鐨刲istener銆傚浜巑essageListener錛屽畠鏃㈠彲浠ユ槸絎﹀悎JMS瑙勮寖鐨? javax.jms.MessageListener錛屼篃鍙互鏄疭pring鐗規湁鐨? org.springframework.jms.listener.SessionAwareMessageListener銆? SessionAwareMessageListener鐨勫畾涔夊涓嬶細
聽聽聽 璺焜avax.jms.MessageListener鐩告瘮錛岃繖涓帴鍙g殑onMessage鏂規硶澧炲姞浜嗕竴涓猄ession 綾誨瀷鐨勫弬鏁幫紝鍙互閫氳繃榪欎釜session鍙戦佸洖澶嶆秷鎭紙reply message錛夈?/p>
聽聽聽 濡傛灉浣跨敤浜哠essionAwareMessageListener 綾誨瀷鐨刴essage
listener錛岄偅涔坋xposeListenerSession鍙傛暟鎸囧畾浜嗕紶鍏nMessage鏂規硶鐨剆ession鍙傛暟鏄惁鏄垱寤轟簡
MessageConsumer鐨剆ession錛岄粯璁ゅ兼槸true銆傚鏋滄槸false錛岄偅涔?
AbstractMessageListenerContainer浼氬湪connection涓婃柊寤轟竴涓猻ession錛屽茍浼犲叆onMessage鏂規硶銆?br />
2.4 AbstractPollingMessageListenerContainer
聽聽聽 AbstractPollingMessageListenerContainer緇ф壙鑷狝bstractMessageListenerContainer錛屽畠鎻愪緵浜嗗浜庝富鍔ㄦ帴鏀舵秷鎭?polling)鐨勬敮鎸侊紝浠ュ強鏀寔澶栭儴鐨勪簨鍔$鐞嗐?/p>
聽聽聽 濡傛灉浣跨敤鈥滃彂甯?璁㈤槄鈥濇ā寮忥紝閭d箞pubSubNoLocal 灞炴ф寚瀹氶氳繃鏌愪釜榪炴帴鍙戦佸埌鏌愪釜Topic鐨勬秷鎭紝鏄惁搴旇琚姇閫掑洖榪欎釜榪炴帴銆?/p>
聽聽聽 receiveTimeout灞炴х敤浜庢寚瀹氳皟鐢∕essageConsumer鐨剅eceive鏂規硶鏃剁殑瓚呮椂鏃墮棿錛岄粯璁ゅ兼槸1縐掋傞渶瑕佹敞鎰忕殑鏄紝榪欎釜鍊煎簲璇ユ瘮transactionManager 涓寚瀹氱殑浜嬪姟瓚呮椂鏃墮棿鐣ュ皬銆?/p>
聽聽聽
閫氬父鎯呭喌涓嬶紝搴旇涓簍ransactionManager璁劇疆涓涓?
org.springframework.transaction.jta.JtaTransactionManager鐨勫疄渚嬶紝姝ゅ涔熻璁劇疆涓涓敮鎸?
XA鐨凜onnectionFactory銆傞渶瑕佹敞鎰忕殑鏄紝XA 浜嬪姟瀵規ц兘鏈夎緝澶х殑褰卞搷銆?br />
聽聽聽 濡傛灉鍙槸甯屾湜浣跨敤local JMS
transaction錛岄偅涔堝彧瑕佽緗畇essionTransacted涓簍rue鎴栬呬嬌鐢↗msTransactionManager鍗沖彲銆傚疄闄呬笂錛?
濡傛灉璁劇疆浜嗛潪JTA鐨則ransactionManager錛岄偅涔坰essionTransacted灞炴т細鑷姩琚緗垚true銆?br />
聽聽聽 鐢變簬local JMS transaction鏃犳硶鍚屽叾瀹僱ocal transaction錛堜緥濡俵ocal database
transaction錛夎繘琛屽崗璋冿紝鍥犳瀹㈡埛绔▼搴忓彲鑳介渶瑕佸閲嶅彂鐨勬秷鎭繘琛屾鏌ャ侸MS瑙勮寖瑕佹眰錛欽MS
provider搴旇灝嗛噸鍙戞秷鎭殑JMSRedelivered灞炴ц緗負true銆?br />
2.5 SimpleMessageListenerContainer
聽聽聽
SimpleMessageListenerContainer緇ф壙鑷狝bstractMessageListenerContainer錛屼嬌鐢ㄥ紓姝ユ柟寮?
鎺ユ敹娑堟伅錛堜篃灝辨槸閫氳繃MessageConsumer涓婃敞鍐孧essageListener鐨勬柟寮忔帴鏀舵秷鎭級銆傝綾諱富瑕佺殑灞炴у涓嬶細
聽聽聽 濡傛灉浣跨敤鈥滃彂甯?璁㈤槄鈥濇ā寮忥紝閭d箞pubSubNoLocal 灞炴ф寚瀹氶氳繃鏌愪釜榪炴帴鍙戦佸埌鏌愪釜Topic鐨勬秷鎭紝鏄惁搴旇琚姇閫掑洖榪欎釜榪炴帴銆?/p>
聽
聽聽聽 SimpleMessageListenerContainer鍏佽鍒涘緩澶氫釜Session鍜孧essageConsumer鏉ユ帴鏀舵秷鎭傚叿浣撶殑涓暟鐢? concurrentConsumers灞炴ф寚瀹氥傞渶瑕佹敞鎰忕殑鏄紝搴旇鍙槸鍦―estination涓篞ueue鐨勬椂鍊欐墠浣跨敤澶氫釜 MessageConsumer錛圦ueue涓殑涓涓秷鎭彧鑳借涓涓狢onsumer鎺ユ敹錛夛紝铏界劧浣跨敤澶氫釜MessageConsumer浼氭彁楂樻秷鎭鐞? 鐨勬ц兘錛屼絾鏄秷鎭鐞嗙殑欏哄簭鍗村緱涓嶅埌淇濊瘉錛氭秷鎭鎺ユ敹鐨勯『搴忎粛鐒舵槸娑堟伅鍙戦佹椂鐨勯『搴忥紝浣嗘槸鐢變簬娑堟伅鍙兘浼氳騫跺彂澶勭悊錛屽洜姝ゆ秷鎭鐞嗙殑欏哄簭鍙兘鍜屾秷鎭彂閫佺殑 欏哄簭涓嶅悓銆傛澶栵紝涓嶅簲璇ュ湪Destination涓篢opic鐨勬椂鍊欎嬌鐢ㄥ涓狹essageConsumer錛岃繖鏄洜涓哄涓? MessageConsumer浼氭帴鏀跺埌鍚屾牱鐨勬秷鎭?/p>
聽聽聽 SimpleMessageListenerContainer鍒涘緩鐨凷ession鍜孧essageConsumer鍒嗗埆淇濆瓨鍦╯essions鍜宑onsumers灞炴т腑銆?/p>
聽聽聽
taskExecutor灞炴х殑榛樿鍊兼槸null錛屼篃灝辨槸璇達紝瀵筂essageListener錛堟垨鑰?
SessionAwareMessageListener錛夌殑鍥炶皟鏄湪MessageConsumer鐨勫唴閮ㄧ嚎紼嬩腑鎵ц銆傚鏋滄寚瀹氫簡
taskExecutor錛岄偅涔堝洖璋冩槸鍦═askExecutor鍐呴儴鐨勭嚎紼嬩腑鎵ц銆備互涓嬫槸鐩稿叧鐨勪唬鐮侊細
聽聽聽 闇瑕佹敞鎰忕殑鏄紝濡傛灉鎸囧畾浜唗askExecutor錛岄偅涔堟秷鎭湪琚玹askExecutor鍐呴儴鐨勭嚎紼嬪鐞嗗墠錛屽彲鑳藉凡緇忚紜榪囦簡錛堝灞傜殑 onMessage鏂規硶鍙兘宸茬粡鎵ц緇撴潫浜嗭級銆傚洜姝ゅ鏋滀嬌鐢ㄤ簨鍔ession鎴栬匰ession.CLIENT_ACKNOWLEDGE綾誨瀷鐨勭‘璁ゆā 寮忥紝閭d箞鍙兘浼氬鑷撮棶棰樸?/p>
聽
聽聽聽
璇ョ被鐨剆haredConnectionEnabled鏂規硶錛堝湪AbstractJmsListeningContainer涓畾涔夛級鎬繪槸榪斿洖true錛?
鍥犳SimpleMessageListenerContainer浼氫嬌鐢ㄥ叡浜殑JMS connection銆?br />
2.6 DefaultMessageListenerContainer
聽聽聽
DefaultMessageListenerContainer緇ф壙鑷?
AbstractPollingMessageListenerContainer錛屼富瑕佷嬌鐢ㄥ悓姝ョ殑鏂瑰紡鎺ユ敹娑堟伅錛堜篃灝辨槸閫氳繃寰幆璋冪敤
MessageConsumer.receive鐨勬柟寮忔帴鏀舵秷鎭級銆傝綾諱富瑕佺殑灞炴у涓嬶細
聽聽聽 璺烻impleMessageListenerContainer涓鏍鳳紝DefaultMessageListenerContainer涔熸敮鎸佸垱寤哄涓? Session鍜孧essageConsumer鏉ユ帴鏀舵秷鎭傝窡SimpleMessageListenerContainer涓嶅悓鐨? 鏄紝DefaultMessageListenerContainer鍒涘緩浜哻oncurrentConsumers鎵鎸囧畾涓暟鐨? AsyncMessageListenerInvoker錛堝疄鐜頒簡SchedulingAwareRunnable鎺ュ彛錛夛紝騫朵氦緇? taskExecutor榪愯銆?/p>
聽聽聽
maxMessagesPerTask灞炴х殑榛樿鍊兼槸Integer.MIN_VALUE錛屼絾鏄鏋滆緗殑taskExecutor錛堥粯璁ゅ兼槸
SimpleAsyncTaskExecutor錛夊疄鐜頒簡SchedulingTaskExecutor鎺ュ彛騫朵笖鍏?
prefersShortLivedTasks鏂規硶榪斿洖true錛堜篃灝辨槸璇磋TaskExecutor鍊懼悜浜庣煭鏈熶換鍔★級錛岄偅涔?
maxMessagesPerTask灞炴т細鑷姩琚緗負10銆?br />
聽聽聽
濡傛灉maxMessagesPerTask灞炴х殑鍊煎皬浜?錛岄偅涔圓syncMessageListenerInvoker.run鏂規硶浼氬湪寰幆涓弽澶嶅皾璇?
鎺ユ敹娑堟伅錛屽茍鍦ㄦ帴鏀跺埌娑堟伅鍚庤皟鐢∕essageListener錛堟垨鑰匰essionAwareMessageListener錛夛紱濡傛灉
maxMessagesPerTask灞炴х殑鍊間笉灝忎簬0錛岄偅涔圓syncMessageListenerInvoker.run鏂規硶閲屾渶澶氫細灝濊瘯鎺ユ敹娑堟伅
maxMessagesPerTask嬈★紝姣忔鎺ユ敹娑堟伅鐨勮秴鏃舵椂闂寸敱鍏剁埗綾?
AbstractPollingMessageListenerContainer鐨剅eceiveTimeout灞炴ф寚瀹氥傚鏋滃湪榪欎簺灝濊瘯涓兘娌℃湁鎺ユ敹
鍒版秷鎭紝閭d箞AsyncMessageListenerInvoker鐨刬dleTaskExecutionCount灞炴т細琚瘡鍔犮傚湪run鏂規硶鎵ц瀹?
姣曞墠浼氬idleTaskExecutionCount榪涜媯鏌ワ紝濡傛灉璇ュ艱秴榪囦簡
DefaultMessageListenerContainer.idleTaskExecutionLimit錛堥粯璁ゅ?錛夛紝閭d箞榪欎釜
AsyncMessageListenerInvoker鍙兘浼氳閿姣併?/p>
聽聽聽
鎵鏈堿syncMessageListenerInvoker瀹炰緥閮戒繚瀛樺湪scheduledInvokers涓紝瀹炰緥鐨勪釜鏁板彲浠ュ湪
concurrentConsumers鍜宮axConcurrentConsumers涔嬮棿嫻姩銆傝窡
SimpleMessageListenerContainer涓鏍鳳紝搴旇鍙槸鍦―estination涓篞ueue鐨勬椂鍊欐墠浣跨敤澶氫釜
AsyncMessageListenerInvoker瀹炰緥銆?/p>
聽
聽聽聽 cacheLevel灞炴х敤浜庢寚瀹氭槸鍚﹀JMS璧勬簮榪涜緙撳瓨錛屽彲閫夌殑鍊兼槸CACHE_NONE = 0銆丆ACHE_CONNECTION = 1銆丆ACHE_SESSION = 2銆丆ACHE_CONSUMER = 3鍜孋ACHE_AUTO = 4銆傞粯璁ゆ儏鍐典笅錛屽鏋渢ransactionManager灞炴т笉涓簄ull錛岄偅涔坈acheLevel琚嚜鍔ㄨ緗負CACHE_NONE錛堜笉榪涜緙? 瀛橈級錛屽惁鍒檆acheLevel琚嚜鍔ㄨ緗負CACHE_CONSUMER銆?/p>
聽聽聽 濡傛灉cacheLevel灞炴у煎ぇ浜庣瓑浜嶤ACHE_CONNECTION錛岄偅涔坰haredConnectionEnabled鏂規硶錛堝湪AbstractJmsListeningContainer涓畾涔夛級榪斿洖true錛屼篃灝辨槸璇翠嬌鐢ㄥ叡浜殑JMS榪炴帴銆?/p>
聽
聽
3 SingleConnectionFactory
聽聽聽
SingleConnectionFactory瀹炵幇浜咰onnectionFactory鎺ュ彛錛屽叾createConnection鏂規硶鎬繪槸榪斿洖鐩稿悓鐨?
Connection銆傚彲浠ュ湪SingleConnectionFactory鐨勬瀯閫犲嚱鏁頒腑浼犲叆Connection瀵硅薄鎴栬?
ConnectionFactory瀵硅薄錛岀敤鏉ュ垱寤鴻浠g悊鐨勮繛鎺ュ璞°?
SingleConnectionFactory.createConnection鏂規硶榪斿洖鐨勮繛鎺ユ槸涓唬鐞嗭紝瀹冨拷鐣ヤ簡瀵箂top鍜宑lose鏂規硶鐨勮皟鐢?
錛堣繛鎺ヤ細鍦⊿ingleConnectionFactory.destroy鏂規硶涓叧闂級銆?/p>
聽聽聽 SingleConnectionFactory鐨剅econnectOnException灞炴х敤鏉ユ寚瀹氭槸鍚﹀湪榪炴帴鎶涘嚭JMSException鐨勬椂鍊欙紝瀵硅繛鎺ヨ繘琛岄噸緗紝閲嶇疆鍚庡鏋滃啀璋冪敤createConnection鏂規硶錛岄偅涔堜細榪斿洖涓涓柊鐨勮繛鎺ャ?/p>
聽聽聽
闇瑕佹敞鎰忕殑鏄紝AbstractJmsListeningContainer綾葷殑鎶借薄鏂規硶sharedConnectionEnabled鎸囧畾浜嗘槸鍚﹀湪
message listener container鍐呴儴浣跨敤鍏變韓鐨凧MS榪炴帴銆傚洜姝ら氬父鎯呭喌涓嬩笉闇瑕佷負鍗曠嫭鐨刴essage listener
container璁劇疆SingleConnectionFactory錛堝強鍏跺瓙綾伙級錛涘鏋滃笇鏈涘湪涓嶅悓鐨刴essage listener
container涔嬮棿鍏變韓JMS榪炴帴錛岄偅涔堝彲浠ヨ冭檻浣跨敤SingleConnectionFactory銆?br />
3.1 CachingConnectionFactory
聽聽聽 CachingConnectionFactory緇ф壙鑷猄ingleConnectionFactory錛屽鍔犱簡瀵筍ession鍜孧essageProducer緙撳瓨鐨勫姛鑳姐傝綾諱富瑕佺殑灞炴у涓嬶細
聽聽聽 sessionCacheSize灞炴ф寚瀹氫簡琚紦瀛樼殑Session瀹炰緥鐨勪釜鏁幫紙榛樿鍊兼槸1錛夛紝涔熷氨鏄錛屽鏋滃悓鏃惰姹傜殑Session涓暟澶т簬sessionCacheSize錛岄偅涔堣繖浜汼ession涓嶄細琚紦瀛橈紝鑰屾槸姝e父鐨勮鍒涘緩鍜岄攢姣併?/p>
聽聽聽 cacheProducers灞炴ф寚瀹氫簡鏄惁瀵筂essageProducer榪涜緙撳瓨錛岄粯璁ゅ兼槸true銆?/p>
瀛楁 | 鍏佽鍊?/th> | 鍏佽鐨勭壒孌婂瓧絎?/th> | ||
---|---|---|---|---|
縐?/code> |
0-59 |
, - * / |
||
鍒?/code> |
0-59 |
, - * / |
||
灝忔椂 |
0-23 |
, - * / |
||
鏃ユ湡 |
1-31 |
, - * ? / L W C |
||
鏈堜喚 |
1-12 鎴栬?JAN-DEC |
, - * / |
||
鏄熸湡 |
1-7 鎴栬?SUN-SAT |
, - * ? / L C # |
||
騫達紙鍙夛級 |
鐣欑┖, 1970-2099 |
, - * / |
瀛楁 | 鍏佽鍊?/th> | 鍏佽鐨勭壒孌婂瓧絎?/th> | ||
---|---|---|---|---|
縐?/code>
|
0-59
|
, - * /
|
||
鍒?/code>
|
0-59
|
, - * /
|
||
灝忔椂
|
0-23
|
, - * /
|
||
鏃ユ湡
|
1-31
|
, - * ? / L W C
|
||
鏈堜喚
|
1-12 鎴栬?JAN-DEC
|
, - * /
|
||
鏄熸湡
|
1-7 鎴栬?SUN-SAT
|
, - * ? / L C #
|
||
騫達紙鍙夛級
|
鐣欑┖, 1970-2099
|
, - * /
|
The '*' character is used to specify all values. For example, "*" in the minute field means "every minute".
“*”瀛楃琚敤鏉ユ寚瀹氭墍鏈夌殑鍊箋傚錛?#8221;*“鍦ㄥ垎閽熺殑瀛楁鍩熼噷琛ㄧず“姣忓垎閽?#8221;銆?
The
'?' character is allowed for the day-of-month and day-of-week fields.
It is used to specify 'no specific value'. This is useful when you need
to specify something in one of the two fileds, but not the other. See
the examples below for clarification.
“?”瀛楃鍙湪鏃ユ湡鍩熷拰鏄熸湡鍩熶腑浣跨敤銆傚畠琚敤鏉ユ寚瀹?#8220;闈炴槑紜殑鍊?#8221;銆傚綋浣犻渶瑕侀氳繃鍦ㄨ繖涓や釜鍩熶腑鐨勪竴涓潵鎸囧畾涓浜涗笢瑗跨殑鏃跺欙紝瀹冩槸鏈夌敤鐨勩傜湅涓嬮潰鐨勪緥瀛愪綘灝變細鏄庣櫧銆?
鏈堜喚涓殑鏃ユ湡鍜屾槦鏈熶腑鐨勬棩鏈熻繖涓や釜鍏冪礌鏃朵簰鏂ョ殑涓璧峰簲璇ラ氳繃璁劇疆涓涓棶鍙??)鏉ヨ〃鏄庝笉鎯寵緗偅涓瓧孌?br />
The '-' character is used to specify ranges For example "10-12" in the hour field means "the hours 10, 11 and 12".
“-”瀛楃琚敤鏉ユ寚瀹氫竴涓寖鍥淬傚錛?#8220;10-12”鍦ㄥ皬鏃跺煙鎰忓懗鐫“10鐐廣?1鐐廣?2鐐?#8221;銆?
The
',' character is used to specify additional values. For example
"MON,WED,FRI" in the day-of-week field means "the days Monday,
Wednesday, and Friday".
“,”瀛楃琚敤鏉ユ寚瀹氬彟澶栫殑鍊箋傚錛?#8220;MON,WED,FRI”鍦ㄦ槦鏈熷煙閲岃〃紺?#8221;鏄熸湡涓銆佹槦鏈熶笁銆佹槦鏈熶簲”.
The
'/' character is used to specify increments. For example "0/15" in the
seconds field means "the seconds 0, 15, 30, and 45". And "5/15" in the
seconds field means "the seconds 5, 20, 35, and 50". Specifying '*'
before the '/' is equivalent to specifying 0 is the value to start
with. Essentially, for each field in the expression, there is a set of
numbers that can be turned on or off. For seconds and minutes, the
numbers range from 0 to 59. For hours 0 to 23, for days of the month 0
to 31, and for months 1 to 12. The "/" character simply helps you turn
on every "nth" value in the given set. Thus "7/6" in the month field
only turns on month "7", it does NOT mean every 6th month, please note
that subtlety.
The 'L' character is allowed for the
day-of-month and day-of-week fields. This character is short-hand for
"last", but it has different meaning in each of the two fields. For
example, the value "L" in the day-of-month field means "the last day of
the month" - day 31 for January, day 28 for February on non-leap years.
If used in the day-of-week field by itself, it simply means "7" or
"SAT". But if used in the day-of-week field after another value, it
means "the last xxx day of the month" - for example "6L" means "the
last friday of the month". When using the 'L' option, it is important
not to specify lists, or ranges of values, as you'll get confusing
results.
L鏄?#8216;last’鐨勭渷鐣ュ啓娉曞彲浠ヨ〃紺篸ay-of-month鍜宒ay-of-week鍩燂紝浣嗗湪涓や釜瀛楁涓殑鎰忔濅笉鍚岋紝渚嬪day-of-month鍩熶腑琛ㄧず涓涓湀鐨勬渶鍚庝竴澶╋紝
濡傛灉鍦╠ay-of-week鍩熻〃紺?#8216;7’鎴栬?#8216;SAT’錛屽鏋滃湪day-of-week鍩熶腑鍓嶉潰鍔犱笂鏁板瓧錛屽畠琛ㄧず涓涓湀鐨勬渶鍚庡嚑澶╋紝渚嬪‘6L’灝辮〃紺轟竴涓湀鐨勬渶鍚庝竴涓?br />
鏄熸湡浜旓紝
The
'W' character is allowed for the day-of-month field. This character is
used to specify the weekday (Monday-Friday) nearest the given day. As
an example, if you were to specify "15W" as the value for the
day-of-month field, the meaning is: "the nearest weekday to the 15th of
the month". So if the 15th is a Saturday, the trigger will fire on
Friday the 14th. If the 15th is a Sunday, the trigger will fire on
Monday the 16th. If the 15th is a Tuesday, then it will fire on Tuesday
the 15th. However if you specify "1W" as the value for day-of-month,
and the 1st is a Saturday, the trigger will fire on Monday the 3rd, as
it will not 'jump' over the boundary of a month's days. The 'W'
character can only be specified when the day-of-month is a single day,
not a range or list of days
.
The 'L' and 'W' characters can
also be combined for the day-of-month expression to yield 'LW', which
translates to "last weekday of the month".
The '#' character
is allowed for the day-of-week field. This character is used to specify
"the nth" XXX day of the month. For example, the value of "6#3" in the
day-of-week field means the third Friday of the month (day 6 = Friday
and "#3" = the 3rd one in the month). Other examples: "2#1" = the first
Monday of the month and "4#5" = the fifth Wednesday of the month. Note
that if you specify "#5" and there is not 5 of the given day-of-week in
the month, then no firing will occur that month.
The 'C'
character is allowed for the day-of-month and day-of-week fields. This
character is short-hand for "calendar". This means values are
calculated against the associated calendar, if any. If no calendar is
associated, then it is equivalent to having an all-inclusive calendar.
A value of "5C" in the day-of-month field means "the first day included
by the calendar on or after the 5th". A value of "1C" in the
day-of-week field means "the first day included by the calendar on or
after sunday".
鍏充簬cronExpression鐨勪粙緇?
瀛楁 鍏佽鍊?鍏佽鐨勭壒孌婂瓧絎?
縐?0-59 , - * /
鍒?0-59 , - * /
灝忔椂 0-23 , - * /
鏃ユ湡 1-31 , - * ? / L W C
鏈堜喚 1-12 鎴栬?JAN-DEC , - * /
鏄熸湡 1-7 鎴栬?SUN-SAT , - * ? / L C #
騫達紙鍙夛級 鐣欑┖, 1970-2099 , - * /
琛ㄨ揪寮忔剰涔?
"0 0 12 * * ?" 姣忓ぉ涓崍12鐐硅Е鍙?
"0 15 10 ? * *" 姣忓ぉ涓婂崍10:15瑙﹀彂
"0 15 10 * * ?" 姣忓ぉ涓婂崍10:15瑙﹀彂
"0 15 10 * * ? *" 姣忓ぉ涓婂崍10:15瑙﹀彂
"0 15 10 * * ? 2005" 2005騫寸殑姣忓ぉ涓婂崍10:15瑙﹀彂
"0 * 14 * * ?" 鍦ㄦ瘡澶╀笅鍗?鐐瑰埌涓嬪崍2:59鏈熼棿鐨勬瘡1鍒嗛挓瑙﹀彂
"0 0/5 14 * * ?" 鍦ㄦ瘡澶╀笅鍗?鐐瑰埌涓嬪崍2:55鏈熼棿鐨勬瘡5鍒嗛挓瑙﹀彂
"0 0/5 14,18 * * ?" 鍦ㄦ瘡澶╀笅鍗?鐐瑰埌2:55鏈熼棿鍜屼笅鍗?鐐瑰埌6:55鏈熼棿鐨勬瘡5鍒嗛挓瑙﹀彂
"0 0-5 14 * * ?" 鍦ㄦ瘡澶╀笅鍗?鐐瑰埌涓嬪崍2:05鏈熼棿鐨勬瘡1鍒嗛挓瑙﹀彂
"0 10,44 14 ? 3 WED" 姣忓勾涓夋湀鐨勬槦鏈熶笁鐨勪笅鍗?:10鍜?:44瑙﹀彂
"0 15 10 ? * MON-FRI" 鍛ㄤ竴鑷沖懆浜旂殑涓婂崍10:15瑙﹀彂
"0 15 10 15 * ?" 姣忔湀15鏃ヤ笂鍗?0:15瑙﹀彂
"0 15 10 L * ?" 姣忔湀鏈鍚庝竴鏃ョ殑涓婂崍10:15瑙﹀彂
"0 15 10 ? * 6L" 姣忔湀鐨勬渶鍚庝竴涓槦鏈熶簲涓婂崍10:15瑙﹀彂
"0 15 10 ? * 6L 2002-2005" 2002騫磋嚦2005騫寸殑姣忔湀鐨勬渶鍚庝竴涓槦鏈熶簲涓婂崍10:15瑙﹀彂
"0 15 10 ? * 6#3" 姣忔湀鐨勭涓変釜鏄熸湡浜斾笂鍗?0:15瑙﹀彂
姣忓ぉ鏃╀笂6鐐?
0 6 * * *
姣忎袱涓皬鏃?
0 */2 * * *
鏅氫笂11鐐瑰埌鏃╀笂8鐐逛箣闂存瘡涓や釜灝忔椂錛屾棭涓婂叓鐐?
0 23-7/2錛? * * *
姣忎釜鏈堢殑4鍙峰拰姣忎釜紺兼嫓鐨勭ぜ鎷滀竴鍒扮ぜ鎷滀笁鐨勬棭涓?1鐐?
0 11 4 * 1-3
1鏈?鏃ユ棭涓?鐐?
0 4 1 1 *
quartz鐨勯珮綰х壒鎬т笉浠呭姝?
1 鏁版嵁搴撳瓨鍌?
2 闆嗙兢鏀寔
3 鏁版嵁搴撴寔涔呭寲浠誨姟錛宼rigger
4 trigger 鐨勫仠姝紝榪愯
5 浠誨姟鐨勪換鎰忔坊鍔?
6 姣攃orntrigger 鏇磋灝界殑浠誨姟瀹夋帓
7 綰跨▼鐨勫唴閮ㄦ暟鎹氦鎹?/p>