54 lines
3.2 KiB
XML
54 lines
3.2 KiB
XML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!-- ============================================================================= -->
|
|
<!-- Licensed to the Apache Software Foundation (ASF) under one or more -->
|
|
<!-- contributor license agreements. See the NOTICE file distributed with -->
|
|
<!-- this work for additional information regarding copyright ownership. -->
|
|
<!-- The ASF licenses this file to You under the Apache License, Version 2.0 -->
|
|
<!-- (the "License"); you may not use this file except in compliance with -->
|
|
<!-- the License. You may obtain a copy of the License at -->
|
|
<!-- -->
|
|
<!-- http://www.apache.org/licenses/LICENSE-2.0 -->
|
|
<!-- -->
|
|
<!-- Unless required by applicable law or agreed to in writing, software -->
|
|
<!-- distributed under the License is distributed on an "AS IS" BASIS, -->
|
|
<!-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -->
|
|
<!-- See the License for the specific language governing permissions and -->
|
|
<!-- limitations under the License. -->
|
|
<!-- ============================================================================= -->
|
|
|
|
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
|
|
<!ENTITY % BOOK_ENTITIES SYSTEM "ActiveMQ_User_Manual.ent">
|
|
%BOOK_ENTITIES;
|
|
]>
|
|
<chapter id="scheduled-messages">
|
|
<title>Scheduled Messages</title>
|
|
<para>Scheduled messages differ from normal messages in that they won't be delivered until a
|
|
specified time in the future, at the earliest.</para>
|
|
<para>To do this, a special property is set on the message before sending it.</para>
|
|
<section>
|
|
<title>Scheduled Delivery Property</title>
|
|
<para>The property name used to identify a scheduled message is <literal
|
|
>"_HQ_SCHED_DELIVERY"</literal> (or the constant <literal
|
|
>Message.HDR_SCHEDULED_DELIVERY_TIME</literal>).</para>
|
|
<para>The specified value must be a positive <literal>long</literal> corresponding to the time the
|
|
message must be delivered (in milliseconds). An example of sending a scheduled message
|
|
using the JMS API is as follows.</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>Scheduled messages can also be sent using the core API, by setting the same property on
|
|
the core message before sending.</para>
|
|
</section>
|
|
<section>
|
|
<title>Example</title>
|
|
<para>See <xref linkend="examples.scheduled-message"/> for an example which shows how
|
|
scheduled messages can be used with JMS.</para>
|
|
</section>
|
|
</chapter>
|