Reputation: 17203
I'm trying get the MQTT acceptor in Apache Artemis of the Wildfly 18 server to run.
The server is running, I can even send messages to a defined topic (though it has to be defined).
Initially I had to add the permission create-durable-queue="true"
to security, otherwise, as soon as I try to subscribe to that topic, the server would terminate the communication.
That said, I try to figure out how I can create on the JMS side, a subscription to a topic with wildcards, and I can find neither current documentation nor any other information about that.
To give some background to the use case:
I want to use the builtin Artemis server of Wildfly 18, and have a bunch of devices which publish to topics like /device/reader/SOMEID/temperature
and similar.
Within my EJBs I want to subscribe to the topic /device/#
and get all messages for that topic and all sub topics.
How can I achieve that?
Also when my entry in the config is
<jms-topic name="TestTopic" entries="java:/jms/topic/TestTopic" />
Why is the MQTT topic then jms/topic/TestTopic
? I'm not happy about using a prefix there.
Upvotes: 0
Views: 505
Reputation: 35038
The server is running, I can even send messages to a defined topic (though it has to be defined).
If you're using true
for the auto-create-addresses
address-setting
then the topic (i.e. the address) should be created for you automatically either when you send a message to it or create a subscription on it.
Initially I had to add the permission create-durable-queue="true" to security, otherwise, as soon as I try to subscribe to that topic, the server would terminate the communication.
This is expected as the create-durable-queue
permission is not set by default.
If you want your JMS topic subscriber to get all the messages sent to a certain set of addresses then simply specify the desired wildcard address in your jms-topic
definition in the server config or in the code. You can find the latest documentation on this subject for ActiveMQ Artemis here and an example of it being used here.
Why is the MQTT topic then jms/topic/TestTopic? I'm not happy about using a prefix there.
Unfortunately the prefix is not optional in Wildfly for historical backwards compatibility issues. Also, while it is technically possible for the embedded ActiveMQ Artemis instance to service non-JMS clients the embedded broker is really meant to just serve as the JMS implementation as required by Java EE. You'll have more flexibility (i.e. the ability to not use the aforementioned prefix) if you run ActiveMQ Artemis standalone.
Upvotes: 2