Java (Qpid JMS) 与 Azure 服务总线的持久订阅

Durable subscription in Java (Qpid JMS) with Azure Service Bus

我正在使用 Java 和 Qpid JMS 0.23 对 pub/sub 进行测试。

我在 SB 中创建了一个名为 "test.topic" 的主题。

我可以从测试应用程序向主题发布消息,但在尝试订阅(动态创建订阅)时失败并出现异常:

javax.jms.InvalidDestinationException: The messaging entity 'mynamespace:topic:test.topic~15|DurableSubscriber2' could not be found. TrackingId:12ecc2a3-f8f3-42a3-8bd5-ad5d9823c367_B20, SystemTracker:mynamespace:topic:test.topic~15|DurableSubscriber2, Timestamp:8/8/2017 12:13:31 PM TrackingId:7e0d46404c8c45f39bffff2b77c7a140_G21, SystemTracker:gateway6, Timestamp:8/8/2017 12:13:31 PM [condition = amqp:not-found]

一些代码:

env.put("topic.TOPIC", "test.topic");

Context context = new InitialContext(env);

ConnectionFactory connectionFactory = (ConnectionFactory) context.lookup("SBCF");
Topic topic = (Topic) context.lookup("TOPIC");

connection = connectionFactory.createConnection("user", "secret");

subscriberSession = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);

subscriber = subscriberSession.createDurableConsumer(topic, "DurableSubscriber2");

如果我在该主题上创建名为 "sub1" 的静态订阅,它会接收已发布的消息。检索时,我需要将主题定义为:

test.topic/Subscriptions/sub1

<<topic-name>>/Subscriptions/<<subscription-name>>

请参阅文档 How to use the Java Message Service (JMS) API with Service Bus and AMQP 1.0Unsupported features and restrictions 部分并关注选项 Temporary destinations,如下所示。

Temporary destinations, i.e., TemporaryQueue, TemporaryTopic are not currently supported, along with the QueueRequestor and TopicRequestor APIs that use them.

所以我认为 Azure 服务总线不支持动态创建订阅。