Zend_Queue-Adapters.xml 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <!-- EN-Revision: 17508 -->
  4. <sect1 id="zend.queue.adapters">
  5. <title>アダプタ</title>
  6. <para>
  7. <classname>Zend_Queue</classname>は、
  8. インターフェース<classname>Zend_Queue_Adapter_AdapterInterface</classname>を実装する
  9. すべての待ち行列をサポートします。
  10. 以下のメッセージ待ち行列サービスがサポートされます:
  11. </para>
  12. <itemizedlist>
  13. <listitem>
  14. <para>
  15. <ulink url="http://activemq.apache.org/">Apache ActiveMQ</ulink>.
  16. </para>
  17. </listitem>
  18. <listitem>
  19. <para>
  20. <classname>Zend_Db</classname>を経たデータベースによる待ち行列
  21. </para>
  22. </listitem>
  23. <listitem>
  24. <para>
  25. <classname>Memcache</classname>による
  26. <ulink url="http://memcachedb.org/memcacheq/">MemcacheQ</ulink>待ち行列
  27. </para>
  28. </listitem>
  29. <listitem>
  30. <para>
  31. <ulink url="http://www.zend.com/en/products/platform/">Zend Platform</ulink>
  32. のジョブキュー。
  33. </para>
  34. </listitem>
  35. <listitem>
  36. <para>
  37. 内部配列。ユニットテストに役立ちます。
  38. </para>
  39. </listitem>
  40. </itemizedlist>
  41. <note id="zend.queue.adapters.limitations">
  42. <title>限定事項</title>
  43. <para>
  44. メッセージ・トランザクション処理は、サポートされません。
  45. </para>
  46. </note>
  47. <sect2 id="zend.queue.adapters.configuration">
  48. <title>固有のアダプタ - 設定の構成</title>
  49. <para>
  50. デフォルトの設定が示される場合は、パラメータは任意です。
  51. デフォルトの設定が指定されない場合は、パラメータが必要です。
  52. </para>
  53. <sect3 id="zend.queue.adapters.configuration.activemq">
  54. <title>Apache ActiveMQ - Zend_Queue_Adapter_Activemq</title>
  55. <para>
  56. ここでリストされたオプションは、既知の必須条件です。
  57. すべてのメッセージ発信サーバが、
  58. ユーザー名またはパスワードを必要とするというわけではありません。
  59. </para>
  60. <itemizedlist>
  61. <listitem>
  62. <para>
  63. <emphasis>$options['name'] = '/temp/queue1';</emphasis>
  64. </para>
  65. <para>
  66. これは、使い始めたい待ち行列の名前です。(必須)
  67. </para>
  68. </listitem>
  69. <listitem>
  70. <para>
  71. <emphasis>$options['driverOptions']['host'] = 'host.domain.tld';</emphasis>
  72. </para>
  73. <para>
  74. <emphasis>$options['driverOptions']['host'] = '127.0.0.1';</emphasis>
  75. </para>
  76. <para>
  77. ホストをIPアドレスまたはホスト名にセットするかもしれません。
  78. </para>
  79. <para>
  80. ホストのデフォルトの設定は '127.0.0.1' です。
  81. </para>
  82. </listitem>
  83. <listitem>
  84. <para>
  85. <emphasis>$options['driverOptions']['port'] = 61613;</emphasis>
  86. </para>
  87. <para>ポートのデフォルトの設定は 61613 です。</para>
  88. </listitem>
  89. <listitem>
  90. <para>
  91. <emphasis>$options['driverOptions']['username'] = 'username';</emphasis>
  92. </para>
  93. <para>
  94. 一部のメッセージ発信サーバのために選択できます。
  95. メッセージ発信サーバのためのマニュアルを読んでください。
  96. </para>
  97. </listitem>
  98. <listitem>
  99. <para>
  100. <emphasis>$options['driverOptions']['password'] = 'password';</emphasis>
  101. </para>
  102. <para>
  103. 一部のメッセージ発信サーバのために選択できます。
  104. メッセージ発信サーバのためのマニュアルを読んでください。
  105. </para>
  106. </listitem>
  107. <listitem>
  108. <para>
  109. <emphasis>$options['driverOptions']['timeout_sec'] = 2;</emphasis>
  110. </para>
  111. <para>
  112. <emphasis>$options['driverOptions']['timeout_usec'] = 0;</emphasis>
  113. </para>
  114. <para>
  115. これは、<classname>Zend_Queue_Adapter_Activemq</classname>がメッセージを返さない前に
  116. ソケットで読み取り活動を待つ時間です。
  117. </para>
  118. </listitem>
  119. </itemizedlist>
  120. </sect3>
  121. <sect3 id="zend.queue.adapters.configuration.Db">
  122. <title>Db - Zend_Queue_Adapter_Db</title>
  123. <para>
  124. ドライバオプションは、多少の必須のオプションのためにチェックされます。
  125. (例えば<emphasis>type</emphasis>、<emphasis>host</emphasis>、<emphasis>username</emphasis>、
  126. <emphasis>password</emphasis>と<emphasis>dbname</emphasis>)
  127. <varname>$options['driverOptions']</varname>でパラメータとして、
  128. <methodname>Zend_DB::factory()</methodname>のために付加パラメータに沿って渡すかもしれません。
  129. ここでは一覧に示されていませんが、
  130. 渡すことができる付加的なオプションは<emphasis>port</emphasis>でしょう。
  131. </para>
  132. <programlisting language="php"><![CDATA[
  133. $options = array(
  134. 'driverOptions' => array(
  135. 'host' => 'db1.domain.tld',
  136. 'username' => 'my_username',
  137. 'password' => 'my_password',
  138. 'dbname' => 'messaging',
  139. 'type' => 'pdo_mysql',
  140. 'port' => 3306, // optional parameter.
  141. ),
  142. 'options' => array(
  143. // 更新のためにZend_Db_Selectを使います。
  144. // 全てのデータベースがこのフィーチャをサポートできるわけではありません。
  145. Zend_Db_Select::FOR_UPDATE => true
  146. )
  147. );
  148. // データベース待ち行列を作成
  149. $queue = Zend_Queue::factory('Db', $options);
  150. ]]></programlisting>
  151. <itemizedlist>
  152. <listitem>
  153. <para>
  154. <emphasis>$options['name'] = 'queue1';</emphasis>
  155. </para>
  156. <para>
  157. これは、使い始めたい待ち行列の名前です。(必須)
  158. </para>
  159. </listitem>
  160. <listitem>
  161. <para>
  162. <emphasis>$options['driverOptions']['type'] = 'Pdo';</emphasis>
  163. </para>
  164. <para>
  165. <emphasis>type</emphasis>は、
  166. <methodname>Zend_Db::factory()</methodname>を
  167. 使ってもらいたいアダプタです。
  168. これは、<methodname>Zend_Db::factory()</methodname>
  169. クラス・メソッド呼び出しの最初のパラメータです。
  170. </para>
  171. </listitem>
  172. <listitem>
  173. <para>
  174. <emphasis>$options['driverOptions']['host'] = 'host.domain.tld';</emphasis>
  175. </para>
  176. <para>
  177. <emphasis>$options['driverOptions']['host'] = '127.0.0.1';</emphasis>
  178. </para>
  179. <para>ホストをIPアドレスまたはホスト名にセットするかもしれません。</para>
  180. <para>ホストのデフォルトの設定は '127.0.0.1' です。</para>
  181. </listitem>
  182. <listitem>
  183. <para>
  184. <emphasis>$options['driverOptions']['username'] = 'username';</emphasis>
  185. </para>
  186. </listitem>
  187. <listitem>
  188. <para>
  189. <emphasis>$options['driverOptions']['password'] = 'password';</emphasis>
  190. </para>
  191. </listitem>
  192. <listitem>
  193. <para>
  194. <emphasis>$options['driverOptions']['dbname'] = 'dbname';</emphasis>
  195. </para>
  196. <para>
  197. 必須のテーブルを作成したデータベース名。
  198. 下記の注意部分を見てください。
  199. </para>
  200. </listitem>
  201. </itemizedlist>
  202. </sect3>
  203. <sect3 id="zend.queue.adapters.configuration.memcacheq">
  204. <title>MemcacheQ - Zend_Queue_Adapter_Memcacheq</title>
  205. <itemizedlist>
  206. <listitem>
  207. <para>
  208. <emphasis>$options['name'] = 'queue1';</emphasis>
  209. </para>
  210. <para>
  211. これは、使い始めたい待ち行列の名前です。(必須)
  212. </para>
  213. </listitem>
  214. <listitem>
  215. <para>
  216. <emphasis>$options['driverOptions']['host'] = 'host.domain.tld';</emphasis>
  217. </para>
  218. <para>
  219. <emphasis>$options['driverOptions']['host'] = '127.0.0.1;'</emphasis>
  220. </para>
  221. <para>ホストをIPアドレスまたはホスト名にセットするかもしれません。</para>
  222. <para>ホストのデフォルトの設定は '127.0.0.1' です。</para>
  223. </listitem>
  224. <listitem>
  225. <para>
  226. <emphasis>$options['driverOptions']['port'] = 22201;</emphasis>
  227. </para>
  228. <para>ポートのデフォルトの設定は 22201 です。</para>
  229. </listitem>
  230. </itemizedlist>
  231. </sect3>
  232. <!-- TODO: to be translated -->
  233. <sect3 id="zend.queue.adapters.configuration.platformjq">
  234. <title>Zend Platform Job Queue - Zend_Queue_Adapter_PlatformJobQueue</title>
  235. <itemizedlist>
  236. <listitem>
  237. <para>
  238. <emphasis>$options['daemonOptions']['host'] = '127.0.0.1:10003';</emphasis>
  239. </para>
  240. <para>
  241. The hostname and port corresponding to the Zend Platform Job Queue daemon
  242. you will use. (Required)
  243. </para>
  244. </listitem>
  245. <listitem>
  246. <para>
  247. <emphasis>$options['daemonOptions']['password'] = '1234';</emphasis>
  248. </para>
  249. <para>
  250. The password required for accessing the Zend Platform Job Queue daemon.
  251. (Required)
  252. </para>
  253. </listitem>
  254. </itemizedlist>
  255. </sect3>
  256. <sect3 id="zend.queue.adapters.configuration.array">
  257. <title>配列 - Zend_Queue_Adapter_Array</title>
  258. <itemizedlist>
  259. <listitem>
  260. <para>
  261. <emphasis>$options['name'] = 'queue1';</emphasis>
  262. </para>
  263. <para>
  264. これは、使い始めたい待ち行列の名前です。(必須)
  265. </para>
  266. </listitem>
  267. </itemizedlist>
  268. </sect3>
  269. </sect2>
  270. <sect2 id="zend.queue.adapters.notes">
  271. <title>アダプタ固有の注意</title>
  272. <para>下記のアダプタには注意があります:</para>
  273. <sect3 id="zend.queue.adapters.notes.activemq">
  274. <title>Apache ActiveMQ</title>
  275. <para>
  276. <classname>Zend_Queue_Adapter_Activemq</classname>のための可視性期間は利用できません。
  277. </para>
  278. <para>
  279. ApacheのActiveMQが複数のサブスクリプションをサポートするのに対して、
  280. <classname>Zend_Queue</classname>はそうしません。
  281. それぞれのサブスクリプションのために
  282. 新しい<classname>Zend_Queue</classname>オブジェクトを作成しなければなりません。
  283. </para>
  284. <para>
  285. ActiveMQの待ち行列または項目の名前は下記のうちの一つで始めなくてはいけません:
  286. </para>
  287. <itemizedlist>
  288. <listitem>
  289. <para>
  290. <filename>/queue/</filename>
  291. </para>
  292. </listitem>
  293. <listitem>
  294. <para>
  295. <filename>/topic/</filename>
  296. </para>
  297. </listitem>
  298. <listitem>
  299. <para>
  300. <filename>/temp-queue/</filename>
  301. </para>
  302. </listitem>
  303. <listitem>
  304. <para>
  305. <filename>/temp-topic/</filename>
  306. </para>
  307. </listitem>
  308. </itemizedlist>
  309. <para>
  310. 例えば: <filename>/queue/testing</filename>
  311. </para>
  312. <para>
  313. 下記の関数はサポートされません:
  314. </para>
  315. <itemizedlist>
  316. <listitem>
  317. <para>
  318. <methodname>create()</methodname> - 待ち行列の作成。
  319. この関数を呼ぶと例外を発生します。
  320. </para>
  321. </listitem>
  322. <listitem>
  323. <para>
  324. <methodname>delete()</methodname> - 待ち行列の削除。
  325. この関数を呼ぶと例外を発生します。
  326. </para>
  327. </listitem>
  328. <listitem>
  329. <para>
  330. <methodname>getQueues()</methodname> - 待ち行列の一覧。
  331. この関数を呼ぶと例外を発生します。
  332. </para>
  333. </listitem>
  334. </itemizedlist>
  335. </sect3>
  336. <sect3 id="zend.queue.adapters.notes.zend_db">
  337. <title>Zend_Db</title>
  338. <para>
  339. データベース<emphasis>CREATE TABLE ( ... )</emphasis> <acronym>SQL</acronym>
  340. 文が<filename>Zend/Queue/Adapter/Db/queue.sql</filename>にあります。
  341. </para>
  342. </sect3>
  343. <sect3 id="zend.queue.adapters.notes.memcacheQ">
  344. <title>MemcacheQ</title>
  345. <para>
  346. Memcacheは<ulink
  347. url="http://www.danga.com/memcached/">http://www.danga.com/memcached/</ulink>
  348. からダウンロードできます。
  349. </para>
  350. <para>
  351. MemcacheQは<ulink
  352. url="http://memcachedb.org/memcacheq/">http://memcachedb.org/memcacheq/</ulink>
  353. からダウンロードできます。
  354. </para>
  355. <itemizedlist>
  356. <listitem>
  357. <para>
  358. <methodname>deleteMessage()</methodname> -
  359. メッセージは、待ち行列から受信と同時に削除されます。
  360. この関数を呼んでも効果がありません。
  361. この関数を呼ぶとエラーを発生します。
  362. </para>
  363. </listitem>
  364. <listitem>
  365. <para>
  366. <methodname>count()</methodname>または<methodname>count($adapter)</methodname>
  367. - MemcacheQは、待ち行列で件数を数えるためのメソッドをサポートしません。
  368. この関数を呼ぶとエラーを発生します。
  369. </para>
  370. </listitem>
  371. </itemizedlist>
  372. </sect3>
  373. <!-- TODO: to be translated -->
  374. <sect3 id="zend.queue.adapters.notes.platformjq">
  375. <title>Zend Platform Job Queue</title>
  376. <para>
  377. Job Queue is a feature of Zend Platform's Enterprise Solution offering. It is not a
  378. traditional message queue, and instead allows you to queue a script to execute,
  379. along with the parameters you wish to pass to it. You can find out more about Job
  380. Queue <ulink url="http://www.zend.com/en/products/platform/">on the zend.com
  381. website</ulink>.
  382. </para>
  383. <para>
  384. The following is a list of methods where this adapter's behavior diverges from the
  385. standard offerings:
  386. </para>
  387. <itemizedlist>
  388. <listitem>
  389. <para>
  390. <methodname>create()</methodname> - Zend Platform does not have the concept
  391. of discrete queues; instead, it allows administrators to provide scripts for
  392. processing jobs. Since adding new scripts is restricted to the
  393. administration interface, this method simply throws an exception indicating
  394. the action is forbidden.
  395. </para>
  396. </listitem>
  397. <listitem>
  398. <para>
  399. <methodname>isExists()</methodname> - Just like
  400. <methodname>create()</methodname>, since Job Queue does not have a notion of
  401. named queues, this method throws an exception when invoked.
  402. </para>
  403. </listitem>
  404. <listitem>
  405. <para>
  406. <methodname>delete()</methodname> - similar to
  407. <methodname>create()</methodname>, deletion of JQ scripts is not possible
  408. except via the admin interface; this method raises an exception.
  409. </para>
  410. </listitem>
  411. <listitem>
  412. <para>
  413. <methodname>getQueues()</methodname> - Zend Platform does not allow
  414. introspection into the attached job handling scripts via the API. This
  415. method throws an exception.
  416. </para>
  417. </listitem>
  418. <listitem>
  419. <para>
  420. <methodname>count()</methodname> - returns the total number of jobs
  421. currently active in the Job Queue.
  422. </para>
  423. </listitem>
  424. <listitem>
  425. <para>
  426. <methodname>send()</methodname> - this method is perhaps the one method that
  427. diverges most from other adapters. The <varname>$message</varname> argument
  428. may be one of three possible types, and will operate differently based on
  429. the value passed:
  430. </para>
  431. <itemizedlist>
  432. <listitem>
  433. <para>
  434. <acronym>string</acronym> - the name of a script registered with Job
  435. Queue to invoke. If passed in this way, no arguments are provided to
  436. the script.
  437. </para>
  438. </listitem>
  439. <listitem>
  440. <para>
  441. <acronym>array</acronym> - an array of values with which to
  442. configure a <classname>ZendApi_Job</classname> object. These may
  443. include the following:
  444. </para>
  445. <itemizedlist>
  446. <listitem>
  447. <para>
  448. <varname>script</varname> - the name of the Job Queue script
  449. to invoke. (Required)
  450. </para>
  451. </listitem>
  452. <listitem>
  453. <para>
  454. <varname>priority</varname> - the job priority to use when
  455. registering with the queue.
  456. </para>
  457. </listitem>
  458. <listitem>
  459. <para>
  460. <varname>name</varname> - a short string describing the job.
  461. </para>
  462. </listitem>
  463. <listitem>
  464. <para>
  465. <varname>predecessor</varname> - the ID of a job on which
  466. this one depends, and which must be executed before this one
  467. may begin.
  468. </para>
  469. </listitem>
  470. <listitem>
  471. <para>
  472. <varname>preserved</varname> - whether or not to retain the
  473. job within the Job Queue history. By default, off; pass a
  474. true value to retain it.
  475. </para>
  476. </listitem>
  477. <listitem>
  478. <para>
  479. <varname>user_variables</varname> - an associative array of
  480. all variables you wish to have in scope during job execution
  481. (similar to named arguments).
  482. </para>
  483. </listitem>
  484. <listitem>
  485. <para>
  486. <varname>interval</varname> - how often, in seconds, the job
  487. should run. By default, this is set to 0, indicating it
  488. should run once, and once only.
  489. </para>
  490. </listitem>
  491. <listitem>
  492. <para>
  493. <varname>end_time</varname> - an expiry time, past which the
  494. job should not run. If the job was set to run only once,
  495. and <varname>end_time</varname> has passed, then the job
  496. will not be executed. If the job was set to run on an
  497. interval, it will not execute again once
  498. <varname>end_time</varname> has passed.
  499. </para>
  500. </listitem>
  501. <listitem>
  502. <para>
  503. <varname>schedule_time</varname> - a <acronym>UNIX</acronym>
  504. timestamp indicating when to run the job; by default, 0,
  505. indicating the job should run as soon as possible.
  506. </para>
  507. </listitem>
  508. <listitem>
  509. <para>
  510. <varname>application_id</varname> - the application
  511. identifier of the job. By default, this is null, indicating
  512. that one will be automatically assigned by the queue, if the
  513. queue was assigned an application ID.
  514. </para>
  515. </listitem>
  516. </itemizedlist>
  517. <para>
  518. As noted, only the <varname>script</varname> argument is required;
  519. all others are simply available to allow passing more fine-grained
  520. detail on how and when to run the job.
  521. </para>
  522. </listitem>
  523. <listitem>
  524. <para>
  525. <classname>ZendApi_Job</classname> - finally, you may simply pass a
  526. <classname>ZendApi_Job</classname> instance, and it will be passed
  527. along to Platform's Job Queue.
  528. </para>
  529. </listitem>
  530. </itemizedlist>
  531. <para>
  532. In all instances, <methodname>send()</methodname> returns a
  533. <classname>Zend_Queue_Message_PlatformJob</classname> object, which provides
  534. access to the <classname>ZendApi_Job</classname> object used to communicate
  535. with Job Queue.
  536. </para>
  537. </listitem>
  538. <listitem>
  539. <para>
  540. <methodname>receive()</methodname> - retrieves a list of active jobs from
  541. Job Queue. Each job in the returned set will be an instance of
  542. <classname>Zend_Queue_Message_PlatformJob</classname>.
  543. </para>
  544. </listitem>
  545. <listitem>
  546. <para>
  547. <methodname>deleteMessage()</methodname> - since this adapter only works
  548. with Job Queue, this method expects the provided <varname>$message</varname>
  549. to be a <classname>Zend_Queue_Message_PlatformJob</classname> instance, and
  550. will throw an exception otherwise.
  551. </para>
  552. </listitem>
  553. </itemizedlist>
  554. </sect3>
  555. <sect3 id="zend.queue.adapters.notes.array">
  556. <title>配列 (内部)</title>
  557. <para>
  558. 配列待ち行列はローカルメモリ上の<acronym>PHP</acronym> <methodname>array()</methodname>です。
  559. <classname>Zend_Queue_Adapter_Array</classname>はユニットテスト用に適しています。
  560. </para>
  561. </sect3>
  562. </sect2>
  563. </sect1>