53 lines
2.9 KiB
HTML
53 lines
2.9 KiB
HTML
<!--
|
|
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.
|
|
-->
|
|
|
|
<html>
|
|
<head>
|
|
<title>ActiveMQ Artemis JMS Queue Selector Example</title>
|
|
<link rel="stylesheet" type="text/css" href="../common/common.css" />
|
|
<link rel="stylesheet" type="text/css" href="../common/prettify.css" />
|
|
<script type="text/javascript" src="../common/prettify.js"></script>
|
|
</head>
|
|
<body onload="prettyPrint()">
|
|
<h1>JMS Queue Selector Example</h1>
|
|
|
|
<pre>To run the example, simply type <b>mvn verify</b> from this directory, <br>or <b>mvn -PnoServer verify</b> if you want to start and create the server manually.</pre>
|
|
|
|
<p>This example shows you how to selectively consume messages using message selectors with queue consumers.</p>
|
|
|
|
<p>Message selectors are strings with special syntax that can be used in creating consumers. Message consumers
|
|
created with a message selector will only receive messages that match its selector. On message delivery, the JBoss Message
|
|
Server evaluates the corresponding message headers of the messages against each selector, if any, and then delivers
|
|
the 'matched' messages to its consumer. Please consult the JMS 1.1 specification for full details.</p>
|
|
|
|
<p>In this example, three message consumers are created on a queue. The first consumer is created with selector
|
|
<code>'color=red'</code>, it only receives messages that
|
|
have a 'color' string property of 'red' value; the second is created with selector <code>'color=green'</code>, it
|
|
only receives messages who have a 'color' string property of
|
|
'green' value; and the third without a selector, which means it receives all messages. To illustrate, three messages
|
|
with different 'color' property values are created and sent.</p>
|
|
|
|
<p>Selectors can be used with both queue consumers and topic consumers. The difference is that with queue consumers,
|
|
a message is only delivered to one consumer on the queue, while topic consumers the message will be delivered to every
|
|
matching consumers. In this example, if the third consumer (anyConsumer) were the first consumer created, it will
|
|
consume the first message delivered, therefore there is no chance for the next consumer to get the message, even if it
|
|
matches the selector.</p>
|
|
</body>
|
|
</html>
|