After so much fumbling around the internet, it's a surprise that I can't find a sample configuration for pushing to a remote message queue using JMS in WildFly 10 with ActiveMQ (Artemis). To worsen the situation standalone-full.xml
is not bound to a schema (why???) and when I finally found the XSD for it here on GitHub, it contains no documentation stating what each node/attribute means and what values can be put in what.
Below is the original configuration from standalone-full.xml.
<subsystem xmlns="urn:jboss:domain:messaging-activemq:1.0">
<server name="default">
<security-setting name="#">
<role name="guest" delete-non-durable-queue="true" create-non-durable-queue="true" consume="true" send="true"/>
</security-setting>
<address-setting name="#" message-counter-history-day-limit="10" page-size-bytes="2097152" max-size-bytes="10485760" expiry-address="jms.queue.ExpiryQueue" dead-letter-address="jms.queue.DLQ"/>
<http-connector name="http-connector" endpoint="http-acceptor" socket-binding="http"/>
<http-connector name="http-connector-throughput" endpoint="http-acceptor-throughput" socket-binding="http">
<param name="batch-delay" value="50"/>
</http-connector>
<in-vm-connector name="in-vm" server-id="0"/>
<http-acceptor name="http-acceptor" http-listener="default"/>
<http-acceptor name="http-acceptor-throughput" http-listener="default">
<param name="batch-delay" value="50"/>
<param name="direct-deliver" value="false"/>
</http-acceptor>
<in-vm-acceptor name="in-vm" server-id="0"/>
<jms-queue name="ExpiryQueue" entries="java:/jms/queue/ExpiryQueue"/>
<jms-queue name="DLQ" entries="java:/jms/queue/DLQ"/>
<connection-factory name="InVmConnectionFactory" entries="java:/ConnectionFactory" connectors="in-vm"/>
<connection-factory name="RemoteConnectionFactory" entries="java:jboss/exported/jms/RemoteConnectionFactory" connectors="http-connector"/>
<pooled-connection-factory name="activemq-ra" transaction="xa" entries="java:/JmsXA java:jboss/DefaultJMSConnectionFactory" connectors="in-vm"/>
</server>
</subsystem>
Below is my CDI queue client which is able to post messages to the local Artemis instance in the WildFly.
@ApplicationScoped
public class QueueClient {
private static final Gson GSON = new Gson();
@Resource(mappedName = "java:jboss/DefaultJMSConnectionFactory")
private ConnectionFactory connectionFactory;
public void sendMessage(String destinationName, Object message) throws JMSException {
try (Connection conn = connectionFactory.createConnection();
Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE)) {
Queue queue = session.createQueue(destinationName);
final Message consignment = session.createMessage();
consignment.setStringProperty("MEDIA_TYPE", "application/json");
consignment.setStringProperty("BODY", GSON.toJson(message));
session.createProducer(queue).send(consignment);
}
}
}
My goal: to post messages to a remote ActiveMQ instance.
What I have: server url
, topic name
, username
and password
.
My question: how do I modify the configuration to achieve this goal?
Alternative question: if the above can't be answered, how else do I achieve this goal?
Thanks!