I have to connect newly created app to ActiveMQ which is inside WildFly app server. I don't want Spring App to be inside WildFly server. It will run as standalone app on embedded Tomcat. In Spring App I have added:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-activemq</artifactId>
</dependency>
And now I want to connect like in documentation:
spring.activemq.broker-url=tcp://localhost:9876
spring.activemq.user=admin
spring.activemq.password=admin
Of course I know that user, password and url are wrong but I really don't know what default values of java:jboss/DefaultJMSConnectionFactory are, it's not explictly said anywere.
In standalone.xml
it looks like this:
<subsystem xmlns="urn:jboss:domain:messaging-activemq:5.0">
<server name="default">
<security-setting name="#">
<role name="guest" send="true" consume="true" create-non-durable-queue="true" delete-non-durable-queue="true"/>
</security-setting>
<http-connector name="http-connector" socket-binding="http" endpoint="http-acceptor"/>
<http-connector name="http-connector-throughput" socket-binding="http" endpoint="http-acceptor-throughput">
<param name="batch-delay" value="50"/>
</http-connector>
<in-vm-connector name="in-vm" server-id="0">
<param name="buffer-pooling" value="false"/>
</in-vm-connector>
<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">
<param name="buffer-pooling" value="false"/>
</in-vm-acceptor>
and
<pooled-connection-factory name="activemq-ra" entries="java:/JmsXA java:jboss/DefaultJMSConnectionFactory" connectors="in-vm" transaction="xa"/>
I expect that I should add a port expose and enable some ?connector? over tcp to activeMQ so that I can connect remotely. Could you give me some advice what should I do?
CodePudding user response:
The first thing to note is that the ActiveMQ embedded within WildFly is ActiveMQ Artemis. Therefore, you should be using:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-artemis</artifactId>
</dependency>
And since you're connecting directly to the embedded instance of ActiveMQ Artemis and not looking up the JMS ConnectionFactory
in JDNI then you can use the http-acceptor
which is already exposed on port 8080
, e.g.:
spring.artemis.mode=native
spring.artemis.broker-url=tcp://localhost:8080?httpUpgradeEnabled=true
spring.artemis.user=admin
spring.artemis.password=secret
Lastly, I recommend you move to a more recent version of WildFly. Version 14 was released almost 4 years ago now. The latest release is 26.0.1.