Here is a primitive example of embedded Artemis broker sending and receiving messages using Point-to-Point send/receive. This example is self-contained and requires no further configuration with XML or any other external file.
In this example a new core queue is created under this broker using these lines:
QueueConfiguration coreQueueConfiguration = new QueueConfiguration(QUEUE_NAME);
coreQueueConfiguration.setAddress(QUEUE_NAME)
.setName(QUEUE_NAME)
.setDurable(true)
.setRoutingType(RoutingType.ANYCAST);
configuration.addQueueConfiguration(coreQueueConfiguration);
Configuration
is a class used by the broker to configure itself.
The class org.apache.activemq.artemis.api.core.QueueConfiguration
is provided by the Artemis project in order to create queues.
However, I was unable to find any example of how to programmatically (no XML or any other files) to create/delete and otherwise manage JMS Topics in an embedded Artemis broker.
Question: How can I programmatically manage Artemis topics?
Technically speaking, there's no such thing as a "JMS topic" in ActiveMQ Artemis as something which can be managed directly. There's only addresses, queues, and routing types. These are the core resources used by the broker to implement all the semantics for all the different protocols which the broker supports.
A JMS topic is most simply represented by an address configured to support multicast queues. To build on your example:
CoreAddressConfiguration coreAddressConfiguration = new CoreAddressConfiguration();
coreAddressConfiguration
.setName("myTopic")
.addRoutingType(RoutingType.MULTICAST);
configuration.addAddressConfiguration(coreAddressConfiguration);
You can read more about how JMS semantics map to core resources in the JMS mapping documentation.
Once the configuration is done on the broker you can configure JNDI for your JMS client using the topic.
prefix in your JNDI properties as described in the JNDI documentation.