I am having issue with spring 4+Stomp+socks js app. It was working fine with simple message broker but when switch to rabbitmq it is not working and could not solve it with the answer mentioned at Configure External Broker(RabbitMQ) In Spring4+STOMP+SockJS Application
My code is:
<websocket:message-broker application-destination-prefix="/app">
<websocket:stomp-endpoint path="/hello">
<websocket:sockjs/>
</websocket:stomp-endpoint>
<websocket:stomp-broker-relay prefix="/topic" system-login="guest" system-passcode="guest" client-login="guest"
client-passcode="guest" relay-host="localhost" relay-port="15672"/>
</websocket:message-broker>
Controller:
@Controller
public class StompController {
@MessageMapping("/hello")
@SendTo("/topic/greetings")
public Greeting greetUser(User user) throws Exception {
Thread.sleep(3000); // simulated delay
return new Greeting("Hello, " + user.getName() + "!");
}
}
Js:
function connect() {
var socket = new SockJS('/hello');
stompClient = Stomp.over(socket);
stompClient.connect('guest','guest', function(frame) {
setConnected(true);
console.log('Connected: ' + frame);
stompClient.subscribe('/topic/greetings', function(greeting){
showGreeting(JSON.parse(greeting.body).content);
});
});
}
While connecting it is saying:
SEVERE [clientInboundChannel-1] org.springframework.messaging.simp.stomp.StompBrokerRelayMessageHandler.handleMessageInternal Message broker is not active. Ignoring: [Payload byte[0]][Headers={stompCommand=CONNECT, stompCredentials=[PROTECTED], nativeHeaders={heart-beat=[10000,10000], passcode=[PROTECTED], login=[guest], accept-version=[1.1,1.0]}, simpMessageType=CONNECT, simpSessionAttributes={}, simpSessionId=ih_04mxa, id=d36fc1c1-e00c-fb48-51af-c526e3018e20, timestamp=1413617272621}]
I have even enabled stomp plugin in rabbit mq.