DWR Reverse ajax using JMS Topic

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

DWR Reverse ajax using JMS Topic

pandharinath.barve
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: DWR Reverse ajax using JMS Topic

david@butterdev.com
You need to provide more information and debug on your end.

If JMS is indeed pushing the same message twice then this is not an
issue with DWR.  I suspect you meant to say DWR is pushing the same
message twice.  If this is the case are you opening new tabs or new
windows?  Most browsers share sessions across tabs so if you are opening
tabs, the behavior you are seeing is expected. Perhaps you need to use
another of the methods on Browser?

-David

On 03/04/2015 11:32 PM, [hidden email] wrote:

> Hello,
>
> I am trying to develope dashboard(monitor), which will recive data from
> JMS topics. As soon as dashboard url opened by browser , JMS Topic
> should
> pump the messages to broser window ( dashboard ).
>
> I tried to implement the DWR JMS packages as per the documentation but
> facing strange problem, If I open more than one brosers then, JMS
> publishes
> dupicate data on both the windows.  For e.g.  JMS message is "Message
> 1"
>
> Broser 1 will have
> Message 1
> Message 1
>
> Browser 2 will have
> Message 1
> Message 1
>
>   Browser.withAllSessionsFiltered(new UpdatesEnabledFilter(
> "UPDATES_ENABLED"), new Runnable() {
>
> @Override
> public void run() {
>
> System.out.println(" updating data
> "+this.getClass().getName());
>
> String[][] data = { { output } };
> Util.addRows("messageDisplay", data);
>
>
> }
> });
>
> It seems it updates same message on all browser sessions.
>
> Could you please help or let me know is there any good way to implement
> this kind of functionality
>
> Thanks
> barvepan
>

Reply | Threaded
Open this post in threaded view
|

Re: DWR Reverse ajax using JMS Topic

pandharinath.barve
In reply to this post by pandharinath.barve
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: DWR Reverse ajax using JMS Topic

david@butterdev.com
What browser are you using?  Do you see the same behavior in all
browsers?

On 2015-03-05 06:01, [hidden email] wrote:

> Thanks David for quick response. If i open separate window or tabs, DWR
> is pushing message twice to web page.
>
> Here is my code.
>
> Server Side
>
> // opening and setting up JMS subscriber. calling this on page load
> public void open() throws JMSException {
>
> // JMS connection
>  getConnection();
>
> connection.setExceptionListener(new ExceptionListener() {
>   // code here
> });
>
> topicConsumer.setMessageListener(new MessageListener() {
>
> public void onMessage(Message message) {
> // on message calling setMessageDisplay
> }
> });
>
>  jmsConnection.start();
>
> }
>
>
> public void setMessageDisplay(final String output) {
> Browser.withAllSessionsFiltered(new
> UpdatesEnabledFilter(
> "UPDATES_ENABLED"), new Runnable() {
>
> @Override
> public void run() {
> String[][] data = { { output } };
> Util.addRows("messageDisplay", data)
>
> }
>
> });
>
> }
>
> // calling this on page unload
> public close(){
>   // closing jms connection which started in open method.
> }
>
> Thanks for help in advance. Thanks
Reply | Threaded
Open this post in threaded view
|

Re: DWR Reverse ajax using JMS Topic

david@butterdev.com
And are you absolutely certain your JMS listener is not receiving two
messages with the same data?

On 2015-03-05 06:24, [hidden email] wrote:

> What browser are you using?  Do you see the same behavior in all
> browsers?
>
> On 2015-03-05 06:01, [hidden email] wrote:
>> Thanks David for quick response. If i open separate window or tabs,
>> DWR
>> is pushing message twice to web page.
>>
>> Here is my code.
>>
>> Server Side
>>
>> // opening and setting up JMS subscriber. calling this on page load
>> public void open() throws JMSException {
>>
>> // JMS connection
>>  getConnection();
>>
>> connection.setExceptionListener(new ExceptionListener() {
>>   // code here
>> });
>>
>> topicConsumer.setMessageListener(new MessageListener() {
>>
>> public void onMessage(Message message) {
>> // on message calling setMessageDisplay
>> }
>> });
>>
>>  jmsConnection.start();
>>
>> }
>>
>>
>> public void setMessageDisplay(final String output) {
>> Browser.withAllSessionsFiltered(new
>> UpdatesEnabledFilter(
>> "UPDATES_ENABLED"), new Runnable() {
>>
>> @Override
>> public void run() {
>> String[][] data = { { output } };
>> Util.addRows("messageDisplay", data)
>>
>> }
>>
>> });
>>
>> }
>>
>> // calling this on page unload
>> public close(){
>>   // closing jms connection which started in open method.
>> }
>>
>> Thanks for help in advance. Thanks
Reply | Threaded
Open this post in threaded view
|

Re: DWR Reverse ajax using JMS Topic

Mike Wilson
Administrator
In reply to this post by pandharinath.barve
The HttpSession is normally shared over the whole browser process regardless
of whether tabs or windows are used. To get two distinct sessions it is best
to start two different browsers (say Chrome and Firefox) with one tab each
navigated to your site.

Best regards
Mike Wilson

pandharinath.barve wrote:
> Thanks David for quick response. If i open separate window or
> tabs, DWR
> is pushing message twice to web page.

Reply | Threaded
Open this post in threaded view
|

Re: DWR Reverse ajax using JMS Topic

david@butterdev.com
OFF-LIST

Mike a few things because I forgot how Reverse AJAX works :).  Is the
browser api session methods per http session or per script session?  If
two browser windows are opened and one http session is shared (same
browser process) are two script sessions created?

On 2015-03-05 09:08, Mike Wilson wrote:

> The HttpSession is normally shared over the whole browser process
> regardless
> of whether tabs or windows are used. To get two distinct sessions it is
> best
> to start two different browsers (say Chrome and Firefox) with one tab
> each
> navigated to your site.
>
> Best regards
> Mike Wilson
>
> pandharinath.barve wrote:
>> Thanks David for quick response. If i open separate window or
>> tabs, DWR
>> is pushing message twice to web page.
Reply | Threaded
Open this post in threaded view
|

Re: DWR Reverse ajax using JMS Topic

Mike Wilson
Administrator
Ah, forgot to reply to the list as well, here it is:

Without "filtering" the Browser API sends to all script sessions.

Script sessions are created per *page load* so they will differ between tabs
and even between different navigations within the same tab.

Best regards
Mike

david wrote:

> Mike a few things because I forgot how Reverse AJAX works :).  Is the
> browser api session methods per http session or per script
> session?  If
> two browser windows are opened and one http session is shared (same
> browser process) are two script sessions created?
>
> On 2015-03-05 09:08, Mike Wilson wrote:
> > The HttpSession is normally shared over the whole browser process
> > regardless
> > of whether tabs or windows are used. To get two distinct
> sessions it is
> > best
> > to start two different browsers (say Chrome and Firefox)
> with one tab
> > each
> > navigated to your site.
> >
> > Best regards
> > Mike Wilson
> >
> > pandharinath.barve wrote:
> >> Thanks David for quick response. If i open separate window or
> >> tabs, DWR
> >> is pushing message twice to web page.