I am following the this guide http://spring.io/guides/gs/messaging-stomp-websocket/ and but instead of using the simple message broker, I am trying to use the stomp broker relay
@Override
public void configureMessageBroker(MessageBrokerRegistry registry) {
registry.enableStompBrokerRelay("/topic").setRelayHost("stomp://localhost").setRelayPort(61612);
registry.setApplicationDestinationPrefixes("/app");
}
and I am trying but my console keeps showing failed to connect
2016-02-26 01:38:05.786 INFO 3584 --- [ main] osmssStompBrokerRelayMessageHandler : Connecting "system" session to stomp://localhost:61612
2016-02-26 01:38:05.942 INFO 3584 --- [eactor-tcp-io-1] r.io.net.impl.netty.tcp.NettyTcpClient : Failed to connect to stomp://localhost:61612. Attempting reconnect in 5000ms.
2016-02-26 01:38:05.957 INFO 3584 --- [ main] osmssStompBrokerRelayMessageHandler : Started.
2016-02-26 01:38:06.025 INFO 3584 --- [ main] sbcetTomcatEmbeddedServletContainer : Tomcat started on port(s): 8052 (http)
2016-02-26 01:38:06.025 INFO 3584 --- [ main] main.java.test.TestApplication : Started TestApplication in 9.419 seconds (JVM running for 15.121)
2016-02-26 01:38:11.022 INFO 3584 --- [eactor-tcp-io-2] r.io.net.impl.netty.tcp.NettyTcpClient : Failed to connect to stomp://localhost:61612. Attempting reconnect in 5000ms.
2016-02-26 01:38:16.008 INFO 3584 --- [eactor-tcp-io-3] r.io.net.impl.netty.tcp.NettyTcpClient : Failed to connect to stomp://localhost:61612. Attempting reconnect in 5000ms.
My activemq.xml is the default except for this:
<transportConnectors>
<transportConnector name="stomp" uri="stomp://localhost:61612"/>
</transportConnectors>
ActiveMQ starts up with no problems as I am able to connect to the admin page at http://localhost:8161/admin .
Here is my maven pom.xml in case someone spots out that I might be using the wrong dependencies
<?xml version="1.0" encoding="UTF-8"?>
http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0
<groupId>com.test.program</groupId>
<artifactId>testapp</artifactId>
<version>0.1.0</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.2.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-messaging</artifactId>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20140107</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-core</artifactId>
<version>3.1.5</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>3.1.5</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>3.1.5</version>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-core</artifactId>
<version>2.0.7.RELEASE</version>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-net</artifactId>
<version>2.0.7.RELEASE</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport</artifactId>
<version>4.0.34.Final</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport-native-epoll</artifactId>
<version>4.0.34.Final</version>
</dependency>
</dependencies>
<properties>
<java.version>1.8</java.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-milestone</id>
<url>https://repo.spring.io/libs-release</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-milestone</id>
<url>https://repo.spring.io/libs-release</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
Problem solved.
I just needed to remove the "stomp://" prefix. As the spring configuration method implies it is a stomp relay, I did not need to add the prefix myself. Also need to enter a username and password if it is set in the default activemq installation.
@Override
public void configureMessageBroker(MessageBrokerRegistry registry) {
registry.enableStompBrokerRelay("/topic")
.setRelayHost("127.0.0.1")
.setRelayPort(61613)
.setClientLogin("system")
.setClientPasscode("password")
registry.setApplicationDestinationPrefixes("/app");
}
change the configureMessageBroker as shown below
@Override
public void configureMessageBroker(MessageBrokerRegistry registry) {
registry.setApplicationDestinationPrefixes("/app");
registry.enableStompBrokerRelay("/topic").setRelayHost("localhost").setRelayPort(15672).setClientLogin("guest")
.setClientPasscode("guest");
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.