简体   繁体   English

ActiveMQ 的 PHP stomp 选择器

[英]PHP stomp selector for ActiveMQ

$topic  = '/topic/orders';
$selector = "orders IN ('1233', '345', '22222')";
$username = 'username'; $pass = 'pass';

$connection = new Connection($brokerUri);
$client = new Client($connection);
$client->setLogin($username, $pass);
$stomp = new StatefulStomp($client);
$stomp->subscribe($topic,$selector);

It will subscribe to the topic on ActiveMQ but the subscription will prefix with convert_string_expressions:它将订阅 ActiveMQ 上的主题,但订阅将以 convert_string_expressions 为前缀:

Please see attached image.请参阅附图。

在此处输入图像描述

How can I fix this prefix?如何修复此前缀?

ActiveMQ "Classic" is hard-coded to prefix any selector used by a STOMP client with convert_string_expressions: . ActiveMQ "Classic" 被硬编码为 STOMP 客户端使用的任何选择器的前缀convert_string_expressions: This was done via AMQ-4146 almost 10 years ago now.这是大约 10 年前通过AMQ-4146完成的。 The prefix is documented here which states:前缀记录在这里,其中指出:

The JMS spec states that a String property should not get converted to a numeric when used in a selector. JMS 规范规定,在选择器中使用时不应将 String 属性转换为数字。 So for example, if a message has the 'age' property set to String '21' then the following selector should not match it: 'age > 18'.例如,如果一条消息的“年龄”属性设置为字符串“21”,则以下选择器不应匹配它:“年龄 > 18”。 Since ActiveMQ support STOMP client which can only send messages with string properties, that restriction is a bit limiting.由于 ActiveMQ 支持只能发送具有字符串属性的消息的 STOMP 客户端,因此该限制有点限制。 If you want your JMS selectors to auto-convert String properties the the appropriate number type, just prefix the the selector with 'convert_string_expressions:'.如果您希望 JMS 选择器自动将字符串属性转换为适当的数字类型,只需在选择器前面加上“convert_string_expressions:”即可。 If you changed selector in the previous example to be 'convert_string_expressions:age > 18', then it would match the message.如果您将前面示例中的选择器更改为“convert_string_expressions:age > 18”,那么它将匹配消息。

To "fix" this you'd have to submit a PR to the ActiveMQ project which adds a new configuration parameter for the STOMP connector to make this behavior configurable.要“修复”这个问题,您必须向 ActiveMQ 项目提交一个 PR,该项目为 STOMP 连接器添加一个新的配置参数,以使此行为可配置。 That said, there should be no reason to change this as it shouldn't be hurting anything.也就是说,应该没有理由改变它,因为它不应该伤害任何东西。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM