You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Artemis Topic场景下JMS运行时选择器失效问题排查

Troubleshooting JMS Selector Not Matching JmsMessageUUID in Spring Boot + Artemis + Camel

Hey there, let's figure out why your JMS selector isn't picking up messages using the JmsMessageUUID property—since you can consume messages fine without the selector and confirm the property exists, we're probably looking at a syntax or configuration quirk. Here are the most likely fixes:

1. Double-Check Selector Syntax (String Values Need Single Quotes!)

JMS selectors treat string values differently than identifiers. If you're not wrapping your JmsMessageUUID value in single quotes, the broker will interpret it as a property name (not a value) and fail to match.

Wrong:

// This won't work—no quotes around the UUID
String badSelector = "JmsMessageUUID = abc123-def456-ghi789";

Correct:

// Wrap the UUID value in single quotes!
String goodSelector = "JmsMessageUUID = 'abc123-def456-ghi789'";

If you're setting the selector directly in a Camel URI, make sure the quotes are properly formatted (raw quotes work fine in most route definitions):

from("jms:queue:your-target-queue?selector=JmsMessageUUID='abc123-def456-ghi789'")
    .log("Matched message with UUID")
    .to("your-processing-endpoint");

2. Verify Property Name Case Sensitivity

JMS property names are case-sensitive. If you set the property as jmsMessageUUID (lowercase 'j') when sending, but your selector uses JmsMessageUUID (uppercase 'J'), they won't match.

Double-check:

  • How you're setting the property when sending the message (e.g., message.setStringProperty("JmsMessageUUID", randomUuid)—ensure the name matches exactly what's in your selector)
  • The property name shown in the received message (you confirmed it exists, just make sure the case is identical)

3. Confirm Camel Selector Configuration is Applied Correctly

If you're setting the selector via Camel's fluent API, make sure you're attaching it to the consumer properly. It's easy to accidentally place the selector in the wrong part of the route definition.

Correct Configuration Example:

@Bean
public RouteBuilder jmsRoute() {
    return new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            String targetUuid = "your-random-uuid-here";
            String selector = String.format("JmsMessageUUID = '%s'", targetUuid);

            from("jms:queue:your-queue")
                // Attach selector to the consumer explicitly
                .consumer().selector(selector)
                .end()
                .process(exchange -> {
                    // Your message processing logic here
                    String uuid = exchange.getIn().getHeader("JmsMessageUUID", String.class);
                    log.info("Processing message with UUID: {}", uuid);
                });
        }
    };
}

4. Rule Out Artemis-Specific Property Handling

While you confirmed the property exists on received messages, double-check that JmsMessageUUID is being set as a user-defined string property (not an internal Artemis property). When sending, ensure you're using the standard JMS API to set the property:

// When sending the message
Message message = session.createTextMessage("Your message content");
message.setStringProperty("JmsMessageUUID", UUID.randomUUID().toString());
producer.send(message);

Quick Recap of Key Checks

  • Always wrap string values in single quotes in JMS selectors
  • Match the exact case of the property name in selector and sender
  • Confirm Camel is applying the selector to the consumer correctly
  • Verify the property is set as a standard string property when sending

内容的提问来源于stack exchange,提问作者Baba

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 09:07:56