Skip to content
This repository has been archived by the owner on Jan 6, 2023. It is now read-only.

Multiple topics #73

Closed
evgenyfedorenko opened this issue Jun 15, 2018 · 4 comments
Closed

Multiple topics #73

evgenyfedorenko opened this issue Jun 15, 2018 · 4 comments

Comments

@evgenyfedorenko
Copy link

Hi there.

I am having an issue with subscription to multiple topics where I want to specify different success callbacks. For example:

this.firstOne = this.stompService.subscribe(topic1, this.headers);
this.secondOne = this.stompService.subscribe(topic2, this.headers);

this.firstOne.subscribe(this.topic1Callback);
this.secondOne.subscribe(this.topic2Callback);

So when the message is pushed to the first topic it would always use this.topic2Callback instead of topic1Callback. Looks like it is somehow always using the last callback which is used for a sequence of topics subscriptions.

Please advise.

@kum-deepak
Copy link
Member

Not sure what the issue can be. The multiple topic operations have been covered in tests - https://github.com/stomp-js/ng2-stompjs/blob/master/src/specs/app/services/stomp-queue.operations.spec.ts

Please share a full example showing the problem as a git hub project for me to assist further.

@evgenyfedorenko
Copy link
Author

I have the following code (similar):

public someSubscribeMethod() {
  var topics = ['topic1', topic2];
  topics.forEach((topic) => {
    this.stompService.subscribe(topic).subscribe(this[topic + 'Hander']);
  });
}
public topic1Handler(msg: Messages) {
  console.log('in topic1Handler');
}
public topic1Handler(msg: Messages) {
  console.log('in topic2Handler');
}

So when message is pushed to either of the 2 topics it always ends up in topic2Handler.
Basically if you subscribe to multiple topics in a loop then the last loop value is set as a callback for all subscriptions.

@kum-deepak
Copy link
Member

Please share a full example as a GitHub project. You may fork one of the demos (https://github.com/stomp-js/ng2-stompjs#usage) and add your code.

@kum-deepak
Copy link
Member

This issue will be closed because lack of information.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants