You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -399,6 +399,46 @@ try (PulsarConnectionFactory factory = new PulsarConnectionFactory(properties);
399
399
400
400
For more on multi-topic subscriptions in Pulsar, see the https://pulsar.apache.org/docs/client-libraries-java/#multi-topic-subscriptions[Pulsar documentation].
401
401
402
+
[#jms-priority]
403
+
== JMS priority
404
+
405
+
*JMS priority* allows messages to be dispatched at different rates according to priority. +
406
+
Priorities are <<Mapping JMS priority to partitions,mapped to Pulsar partition IDs>> with the `jms.priorityMapping` parameter in the ConnectionFactory. +
407
+
408
+
When a producer writes a message, the message is routed to a partition based on its priority mapping. By default, the higher the partition name (0 is highest priority), the higher the priority. +
409
+
On the consumer side, messages are re-ordered in memory so high priority partitions are drained faster than other partitions. +
410
+
Both producers and consumers advertise their priority routing behavior in metadata, so priority behavior can be detected and used by Pulsar admin for subscriptions, filters, and metrics. +
411
+
Even if a consumer is not looking for a message's priority mapping metadata, it will still consume the message.
412
+
413
+
[#jms-priority-mapping]
414
+
=== Mapping JMS priority to partitions
415
+
416
+
The parameter `jms.priorityMapping` controls how priorities are mapped to partitions.
417
+
418
+
The `jms.priorityMapping` parameter can be set to `linear` or `non-linear`. The default is `linear`. +
419
+
420
+
In `jms.priorityMapping = "linear"` mode, the priority level (from 0 to 9) is linearly mapped to the partition id. +
421
+
If you have 10 partitions, priority 0 goes to partition 0, priority 1 to partition 1, and so on. +
422
+
If you have 20 partitions, priority 0 goes to partitions 0 and 1, priority 1 goes to partitions 2 and 3, and so on.
423
+
424
+
The benefit of this approach is that you are guaranteed that each priority level is sent to different partitions. +
425
+
The drawback is that if you don't use all the priority levels, then some partitions will be left underutilized.
426
+
427
+
In `jms.priorityMapping = "non-linear"`, the mapping between JMSPriority and the partition id is not linear.
428
+
The assumption is that there will be more regular messages than high/low priority messages.
429
+
430
+
Priorities are divided into 3 classes: low, default, and high priority.
431
+
432
+
* 1/4 of the partitions are for low priority messages.
433
+
* 1/2 of the partitions are for the default priority.
434
+
* 1/4 of the partitions are for high priority messages.
435
+
436
+
With non-linear partition mapping, the JMS Client will tend to:
437
+
438
+
* use more partitions for default level priorities (especially 4, the default priority).
439
+
* map higher level priorities to higher partition ids.
440
+
* map lower level priorities to lower partition ids.
441
+
402
442
== What's next?
403
443
404
444
* *xref:jms-migration:pulsar-jms-quickstart-sa.adoc[]*: Create a simple command line Java JMS client that connects to a local Pulsar installation.
0 commit comments