Skip to content

Excessive messages are returned when subscribe to /app endpoint multiple times. #12

@wjx

Description

@wjx

One subscribe to @SubscribeMapping should return one message, but when subscribe multiple times, excessive messages are returned:

Client:

stompClient.subscribe('/app/msg', function(msg) {
            console.log("subscribe1 callback");
        });
        stompClient.subscribe('/app/msg', function(msg) {
            console.log("subscribe2 callback");
        });

Server:

@SubscribeMapping("/msg")
	public Greeting msg() {
		return new Greeting("Hello, World!");
	}

Expected:
Two messages with content Hello, World! returned.

But excessive messages are returned.

Logs:

Web Socket Opened...
18:10:24.104 stomp.min.js:8 >>> CONNECT
accept-version:1.1,1.0
heart-beat:10000,10000


18:10:24.173 stomp.min.js:8 <<< CONNECTED
version:1.1
heart-beat:0,0


18:10:24.174 stomp.min.js:8 connected to server undefined
18:10:24.181 app.js?_=dsd:24 Connected: CONNECTED
heart-beat:0,0
version:1.1


18:10:24.182 stomp.min.js:8 >>> SUBSCRIBE
id:sub-0
destination:/app/msg


18:10:24.182 stomp.min.js:8 >>> SUBSCRIBE
id:sub-1
destination:/app/msg


18:10:25.271 stomp.min.js:8 <<< MESSAGE
destination:/app/msg
message-id:559f29a724bd48b794f270b71a18aa71-1
content-type:application/json;charset=UTF-8
subscription:sub-0
content-length:27

{"content":"Hello, World!"}
18:10:25.272 app.js?_=dsd:34 subscribe1 callback
18:10:25.273 stomp.min.js:8 <<< MESSAGE
destination:/app/msg
message-id:559f29a724bd48b794f270b71a18aa71-1
content-type:application/json;charset=UTF-8
subscription:sub-1
content-length:27

{"content":"Hello, World!"}
18:10:25.273 app.js?_=dsd:37 subscribe2 callback
18:10:25.277 stomp.min.js:8 <<< MESSAGE
destination:/app/msg
message-id:559f29a724bd48b794f270b71a18aa71-0
content-type:application/json;charset=UTF-8
subscription:sub-0
content-length:27

{"content":"Hello, World!"}
18:10:25.277 app.js?_=dsd:34 subscribe1 callback
18:10:25.278 stomp.min.js:8 <<< MESSAGE
destination:/app/msg
message-id:559f29a724bd48b794f270b71a18aa71-0
content-type:application/json;charset=UTF-8
subscription:sub-1
content-length:27

{"content":"Hello, World!"}
18:10:25.279 app.js?_=dsd:37 subscribe2 callback

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions