Search code examples
javascriptmessagingblazeds

BlazeDS using subtopics set at server side with ajax-bridge


I'm doing research into BlazeDS , and i am trying to use the ajax-bridge to perform this trough javascript.

What i'm trying to do is send an asynchronous message from the server to the client(s)

On it's own, this work perfectly.

However , now i'm trying to use subtopics , to be able to limit the number of clients the message is sent to.

As i understand it , setting the subtopic at server side ,works by setting the header in AsynchMessage :

msg.setDestination("TestingDestination");
msg.setHeader("DSSubtopic", "siteData.subtopic1" );

And then setting the subtopic in the client :

consumer.setDestination("TestingDestination");
consumer.subtopic = "siteData.subtopic1" ;

However, this is not working correctly : I do not receive any message at the client side.


Solution

  • I found the reason it didn't work :

    When using the ajax-bridge , you cannot use consumer.subtopic .

    You need to use consumer.setSubtopic() :

    consumer.setDestination("TestingDestination"); 
    consumer.setSubtopic("siteData.subtopic1") ; 
    

    Now it works correctly.