activemq-artemis/docs/user-manual/zh/scheduled-messages.xml

48 lines
2.9 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?xml version="1.0" encoding="UTF-8"?>
<!-- ============================================================================= -->
<!-- Copyright © 2009 Red Hat, Inc. and others. -->
<!-- -->
<!-- The text of and illustrations in this document are licensed by Red Hat under -->
<!-- a Creative Commons AttributionShare Alike 3.0 Unported license ("CC-BY-SA"). -->
<!-- -->
<!-- An explanation of CC-BY-SA is available at -->
<!-- -->
<!-- http://creativecommons.org/licenses/by-sa/3.0/. -->
<!-- -->
<!-- In accordance with CC-BY-SA, if you distribute this document or an adaptation -->
<!-- of it, you must provide the URL for the original version. -->
<!-- -->
<!-- Red Hat, as the licensor of this document, waives the right to enforce, -->
<!-- and agrees not to assert, Section 4d of CC-BY-SA to the fullest extent -->
<!-- permitted by applicable law. -->
<!-- ============================================================================= -->
<chapter id="scheduled-messages">
<title>定期消息</title>
<para>与普通消息不同,定期消息是在未来某个指定时间发送的消息。</para>
<para>为了创建定期消息,需要设定一个特殊的参数.</para>
<section>
<title>定期传递参数</title>
<para>用来标识一个定期消息的参数是<literal
>"_HQ_SCHED_DELIVERY"</literal> (相当于常量<literal
>Message.HDR_SCHEDULED_DELIVERY_TIME</literal>)。</para>
<para>这个参数的值必须是一个大于零的长整型单位是毫秒。下面例子给出了使用JMS接口创建定期消息的方法</para>
<programlisting>
TextMessage message =
session.createTextMessage("This is a scheduled message message which will be delivered
in 5 sec.");
message.setLongProperty("_HQ_SCHED_DELIVERY", System.currentTimeMillis() + 5000);
producer.send(message);
...
// message will not be received immediately but 5 seconds later
TextMessage messageReceived = (TextMessage) consumer.receive();
</programlisting>
<para>也可以使用核心接口来发送定期消息。它只需要将同样的参数设定到核心消息上即可。</para>
</section>
<section>
<title>例子</title>
<para>参见<xref linkend="examples.scheduled-message"/>它是一个JMS使用定期消息的例子。</para>
</section>
</chapter>