activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bill Harts (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (AMQ-4797) Unable to add multiple AJAX listeners for the same topic in the same browser window
Date Thu, 10 Oct 2013 18:41:47 GMT

     [ https://issues.apache.org/jira/browse/AMQ-4797?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Bill Harts updated AMQ-4797:
----------------------------

    Description: 
I'm using ExtJS to create two separate panels which run in one browser tab.  After loading
jquery, amq_jquery_adapter.js and amq.js I call amq_init (only once).  Then each panel calls
addlistener like so: 

Panel 1 code: 
{code}amq.addListener('testconnection1', topic://MyApp/IOIs/Simulator', myHandler1.rcvMessage);{code}

Panel 2 code: 
{code}amq.addListener('testconnection2', 'topic://MyApp/IOIs/Simulator', myHandler2.rcvMessage);{code}

Note that both are subscribing to the same topic.  This is because Panel 1 shows the data
in a different format than Panel 2. 

*The Problem:*
If I start Panel 1 alone, it receives data from the topic without problems. But then I start
Panel 2 and as soon as it executes the addlistener, Panel 2 starts receiving data but Panel
1 stops!   

So I started tracing into the network traffic and all looks fine, i.e, I can see each addlistener
trigger a 'listen' request with the proper id and topic.  And I see the amq server return
data to testconnection1, then stop suddenly when the 'listen' for testconnection2 is sent.
 So I turned my attention to the backend code and enabled a detailed trace.  Here's what I
found: 

When the Panel 1 'listen' is received, the trace shows: 
{quote}2013-10-10 09:10:09,701 | DEBUG | 0 destination=topic://MyApp/IOIs/Simulator message=testconnection1
type=listen | org.apache.activemq.web.MessageListenerServlet | qtp2088898587-51 - /demo/amq
2013-10-10 09:10:09,701 | DEBUG | topic://MyApp/IOIs/Simulator is a org.apache.activemq.command.ActiveMQTopic
| org.apache.activemq.web.MessageListenerServlet | qtp2088898587-51 - /demo/amq
2013-10-10 09:10:09,701 | DEBUG | amq-broker adding consumer: ID:MYAPPDATA-7392-1381410590247-5:1:1:1
for destination: topic://MyApp/IOIs/Simulator | org.apache.activemq.broker.region.AbstractRegion
| ActiveMQ VMTransport: vm://localhost#1-2
2013-10-10 09:10:09,701 | DEBUG | amq-broker adding destination: topic://ActiveMQ.Advisory.Consumer.Topic.MyApp/IOIs/Simulator
| org.apache.activemq.broker.region.AbstractRegion | ActiveMQ VMTransport: vm://localhost#1-2
2013-10-10 09:10:09,717 | DEBUG | Initialized TaskRunnerFactory[ActiveMQ Session Task] using
ExecutorService: java.util.concurrent.ThreadPoolExecutor@2e2667db[Running, pool size = 0,
active threads = 0, queued tasks = 0, completed tasks = 0] | org.apache.activemq.thread.TaskRunnerFactory
| qtp2088898587-51 - /demo/amq
2013-10-10 09:10:09,717 | DEBUG | Subscribed: ActiveMQMessageConsumer { value=ID:MYAPPDATA-7392-1381410590247-5:1:1:1,
started=true } to topic://MyApp/IOIs/Simulator id=testconnection1 | org.apache.activemq.web.MessageListenerServlet
| qtp2088898587-51 - /demo/amq{quote}

When the Panel 2 'listen' is received, I see this trace: 
{quote}2013-10-10 09:10:09,888 | DEBUG | 0 destination=topic://MyApp/IOIs/Simulator message=testconnection2
type=listen | org.apache.activemq.web.MessageListenerServlet | qtp2088898587-53 - /demo/amq
2013-10-10 09:10:09,888 | DEBUG | topic://MyApp/IOIs/Simulator is a org.apache.activemq.command.ActiveMQTopic
| org.apache.activemq.web.MessageListenerServlet | qtp2088898587-53 - /demo/amq
2013-10-10 09:10:09,888 | DEBUG | remove: ID:MYAPPDATA-7392-1381410590247-5:1:1:1, lastDeliveredSequenceId:0
| org.apache.activemq.ActiveMQMessageConsumer | qtp2088898587-53 - /demo/amq
2013-10-10 09:10:09,888 | DEBUG | Unregistering MBean org.apache.activemq:type=Broker,brokerName=amq-broker,destinationType=Topic,destinationName=MyApp/IOIs/Simulator,endpoint=Consumer,clientId=ID_MYAPPDATA-7392-1381410590247-4_1,consumerId=ID_MYAPPDATA-7392-1381410590247-5_1_1_1
| org.apache.activemq.broker.jmx.ManagementContext | ActiveMQ VMTransport: vm://localhost#1-2
2013-10-10 09:10:09,888 | DEBUG | amq-broker removing consumer: ID:MYAPPDATA-7392-1381410590247-5:1:1:1
for destination: topic://MyApp/IOIs/Simulator | org.apache.activemq.broker.region.AbstractRegion
| ActiveMQ VMTransport: vm://localhost#1-2
2013-10-10 09:10:09,888 | DEBUG | amq-broker adding consumer: ID:MYAPPDATA-7392-1381410590247-5:1:1:2
for destination: topic://MyApp/IOIs/Simulator | org.apache.activemq.broker.region.AbstractRegion
| ActiveMQ VMTransport: vm://localhost#1-2
2013-10-10 09:10:09,904 | DEBUG | Subscribed: ActiveMQMessageConsumer { value=ID:MYAPPDATA-7392-1381410590247-5:1:1:2,
started=true } to topic://MyApp/IOIs/Simulator id=testconnection2 | org.apache.activemq.web.MessageListenerServlet
| qtp2088898587-53 - /demo/amq{quote}

What is happening is that in MessageListenerServlet.js, function doPost, line 165 is dropping
any previous consumer to the same destination: 
{code}client.closeConsumer(destination); // drop any existing consumer.{code}

But why?  There doesn't seem to be a good reason for doing this--maybe it was originally put
there for cleanup purposes?.  Or if there is a good reason, maybe the behavior should be to
not do it if the id of the new destination (in this case 'testconnection2') is different than
the id of the existing destination ('testconnection1'). 

I believe this can be fixed by simply removing line 165 from MessageListenerServlet.js but
I'm not sure if this will break something else.

  was:
I'm using ExtJS to create two separate panels which run in one browser tab.  After loading
jquery, amq_jquery_adapter.js and amq.js I call amq_init (only once).  Then each panel calls
addlistener like so: 

Panel 1 code: 
{{	amq.addListener('testconnection1', 'topic://MyApp/IOIs/Simulator', myHandler1.rcvMessage);}}

Panel 2 code: 
{{	amq.addListener('testconnection2', 'topic://MyApp/IOIs/Simulator', myHandler2.rcvMessage);}}

Note that both are subscribing to the same topic.  This is because Panel 1 shows the data
in a different format than Panel 2. 

*The Problem:*
If I start Panel 1 alone, it receives data from the topic without problems. But then I start
Panel 2 and as soon as it executes the addlistener, Panel 2 starts receiving data but Panel
1 stops!   

So I started tracing into the network traffic and all looks fine, i.e, I can see each addlistener
trigger a 'listen' request with the proper id and topic.  And I see the amq server return
data to testconnection1, then stop suddenly when the 'listen' for testconnection2 is sent.
 So I turned my attention to the backend code and enabled a detailed trace.  Here's what I
found: 

When the Panel 1 'listen' is received, the trace shows: 
{{2013-10-10 09:10:09,701 | DEBUG | 0 destination=topic://MyApp/IOIs/Simulator message=testconnection1
type=listen | org.apache.activemq.web.MessageListenerServlet | qtp2088898587-51 - /demo/amq
2013-10-10 09:10:09,701 | DEBUG | topic://MyApp/IOIs/Simulator is a org.apache.activemq.command.ActiveMQTopic
| org.apache.activemq.web.MessageListenerServlet | qtp2088898587-51 - /demo/amq
2013-10-10 09:10:09,701 | DEBUG | amq-broker adding consumer: ID:MYAPPDATA-7392-1381410590247-5:1:1:1
for destination: topic://MyApp/IOIs/Simulator | org.apache.activemq.broker.region.AbstractRegion
| ActiveMQ VMTransport: vm://localhost#1-2
2013-10-10 09:10:09,701 | DEBUG | amq-broker adding destination: topic://ActiveMQ.Advisory.Consumer.Topic.MyApp/IOIs/Simulator
| org.apache.activemq.broker.region.AbstractRegion | ActiveMQ VMTransport: vm://localhost#1-2
2013-10-10 09:10:09,717 | DEBUG | Initialized TaskRunnerFactory[ActiveMQ Session Task] using
ExecutorService: java.util.concurrent.ThreadPoolExecutor@2e2667db[Running, pool size = 0,
active threads = 0, queued tasks = 0, completed tasks = 0] | org.apache.activemq.thread.TaskRunnerFactory
| qtp2088898587-51 - /demo/amq
2013-10-10 09:10:09,717 | DEBUG | Subscribed: ActiveMQMessageConsumer { value=ID:MYAPPDATA-7392-1381410590247-5:1:1:1,
started=true } to topic://MyApp/IOIs/Simulator id=testconnection1 | org.apache.activemq.web.MessageListenerServlet
| qtp2088898587-51 - /demo/amq}}

When the Panel 2 'listen' is received, I see this trace: 
{{2013-10-10 09:10:09,888 | DEBUG | 0 destination=topic://MyApp/IOIs/Simulator message=testconnection2
type=listen | org.apache.activemq.web.MessageListenerServlet | qtp2088898587-53 - /demo/amq
2013-10-10 09:10:09,888 | DEBUG | topic://MyApp/IOIs/Simulator is a org.apache.activemq.command.ActiveMQTopic
| org.apache.activemq.web.MessageListenerServlet | qtp2088898587-53 - /demo/amq
2013-10-10 09:10:09,888 | DEBUG | remove: ID:MYAPPDATA-7392-1381410590247-5:1:1:1, lastDeliveredSequenceId:0
| org.apache.activemq.ActiveMQMessageConsumer | qtp2088898587-53 - /demo/amq
2013-10-10 09:10:09,888 | DEBUG | Unregistering MBean org.apache.activemq:type=Broker,brokerName=amq-broker,destinationType=Topic,destinationName=MyApp/IOIs/Simulator,endpoint=Consumer,clientId=ID_MYAPPDATA-7392-1381410590247-4_1,consumerId=ID_MYAPPDATA-7392-1381410590247-5_1_1_1
| org.apache.activemq.broker.jmx.ManagementContext | ActiveMQ VMTransport: vm://localhost#1-2
2013-10-10 09:10:09,888 | DEBUG | amq-broker removing consumer: ID:MYAPPDATA-7392-1381410590247-5:1:1:1
for destination: topic://MyApp/IOIs/Simulator | org.apache.activemq.broker.region.AbstractRegion
| ActiveMQ VMTransport: vm://localhost#1-2
2013-10-10 09:10:09,888 | DEBUG | amq-broker adding consumer: ID:MYAPPDATA-7392-1381410590247-5:1:1:2
for destination: topic://MyApp/IOIs/Simulator | org.apache.activemq.broker.region.AbstractRegion
| ActiveMQ VMTransport: vm://localhost#1-2
2013-10-10 09:10:09,904 | DEBUG | Subscribed: ActiveMQMessageConsumer { value=ID:MYAPPDATA-7392-1381410590247-5:1:1:2,
started=true } to topic://MyApp/IOIs/Simulator id=testconnection2 | org.apache.activemq.web.MessageListenerServlet
| qtp2088898587-53 - /demo/amq}}

SO what is happening is that in MessageListenerServlet.js, function doPost, line 165 is dropping
any previous consumer to the same destination: 
client.closeConsumer(destination); // drop any existing consumer.

But why?  There doesn't seem to be a good reason for doing this--maybe it was originally put
there for cleanup purposes?.  Or if there is a good reason, maybe the behavior should be to
not do it if the id of the new destination (in this case 'testconnection2') is different than
the id of the existing destination ('testconnection1'). 

I believe this can be fixed by simply removing line 165 from MessageListenerServlet.js but
I'm not sure if this will break something else


> Unable to add multiple AJAX listeners for the same topic in the same browser window
> -----------------------------------------------------------------------------------
>
>                 Key: AMQ-4797
>                 URL: https://issues.apache.org/jira/browse/AMQ-4797
>             Project: ActiveMQ
>          Issue Type: Bug
>    Affects Versions: 5.8.0
>         Environment: Windows Server 2008 R2 on Dell server boxes
>            Reporter: Bill Harts
>              Labels: addlistener, ajax, web
>
> I'm using ExtJS to create two separate panels which run in one browser tab.  After loading
jquery, amq_jquery_adapter.js and amq.js I call amq_init (only once).  Then each panel calls
addlistener like so: 
> Panel 1 code: 
> {code}amq.addListener('testconnection1', topic://MyApp/IOIs/Simulator', myHandler1.rcvMessage);{code}
> Panel 2 code: 
> {code}amq.addListener('testconnection2', 'topic://MyApp/IOIs/Simulator', myHandler2.rcvMessage);{code}
> Note that both are subscribing to the same topic.  This is because Panel 1 shows the
data in a different format than Panel 2. 
> *The Problem:*
> If I start Panel 1 alone, it receives data from the topic without problems. But then
I start Panel 2 and as soon as it executes the addlistener, Panel 2 starts receiving data
but Panel 1 stops!   
> So I started tracing into the network traffic and all looks fine, i.e, I can see each
addlistener trigger a 'listen' request with the proper id and topic.  And I see the amq server
return data to testconnection1, then stop suddenly when the 'listen' for testconnection2 is
sent.  So I turned my attention to the backend code and enabled a detailed trace.  Here's
what I found: 
> When the Panel 1 'listen' is received, the trace shows: 
> {quote}2013-10-10 09:10:09,701 | DEBUG | 0 destination=topic://MyApp/IOIs/Simulator message=testconnection1
type=listen | org.apache.activemq.web.MessageListenerServlet | qtp2088898587-51 - /demo/amq
> 2013-10-10 09:10:09,701 | DEBUG | topic://MyApp/IOIs/Simulator is a org.apache.activemq.command.ActiveMQTopic
| org.apache.activemq.web.MessageListenerServlet | qtp2088898587-51 - /demo/amq
> 2013-10-10 09:10:09,701 | DEBUG | amq-broker adding consumer: ID:MYAPPDATA-7392-1381410590247-5:1:1:1
for destination: topic://MyApp/IOIs/Simulator | org.apache.activemq.broker.region.AbstractRegion
| ActiveMQ VMTransport: vm://localhost#1-2
> 2013-10-10 09:10:09,701 | DEBUG | amq-broker adding destination: topic://ActiveMQ.Advisory.Consumer.Topic.MyApp/IOIs/Simulator
| org.apache.activemq.broker.region.AbstractRegion | ActiveMQ VMTransport: vm://localhost#1-2
> 2013-10-10 09:10:09,717 | DEBUG | Initialized TaskRunnerFactory[ActiveMQ Session Task]
using ExecutorService: java.util.concurrent.ThreadPoolExecutor@2e2667db[Running, pool size
= 0, active threads = 0, queued tasks = 0, completed tasks = 0] | org.apache.activemq.thread.TaskRunnerFactory
| qtp2088898587-51 - /demo/amq
> 2013-10-10 09:10:09,717 | DEBUG | Subscribed: ActiveMQMessageConsumer { value=ID:MYAPPDATA-7392-1381410590247-5:1:1:1,
started=true } to topic://MyApp/IOIs/Simulator id=testconnection1 | org.apache.activemq.web.MessageListenerServlet
| qtp2088898587-51 - /demo/amq{quote}
> When the Panel 2 'listen' is received, I see this trace: 
> {quote}2013-10-10 09:10:09,888 | DEBUG | 0 destination=topic://MyApp/IOIs/Simulator message=testconnection2
type=listen | org.apache.activemq.web.MessageListenerServlet | qtp2088898587-53 - /demo/amq
> 2013-10-10 09:10:09,888 | DEBUG | topic://MyApp/IOIs/Simulator is a org.apache.activemq.command.ActiveMQTopic
| org.apache.activemq.web.MessageListenerServlet | qtp2088898587-53 - /demo/amq
> 2013-10-10 09:10:09,888 | DEBUG | remove: ID:MYAPPDATA-7392-1381410590247-5:1:1:1, lastDeliveredSequenceId:0
| org.apache.activemq.ActiveMQMessageConsumer | qtp2088898587-53 - /demo/amq
> 2013-10-10 09:10:09,888 | DEBUG | Unregistering MBean org.apache.activemq:type=Broker,brokerName=amq-broker,destinationType=Topic,destinationName=MyApp/IOIs/Simulator,endpoint=Consumer,clientId=ID_MYAPPDATA-7392-1381410590247-4_1,consumerId=ID_MYAPPDATA-7392-1381410590247-5_1_1_1
| org.apache.activemq.broker.jmx.ManagementContext | ActiveMQ VMTransport: vm://localhost#1-2
> 2013-10-10 09:10:09,888 | DEBUG | amq-broker removing consumer: ID:MYAPPDATA-7392-1381410590247-5:1:1:1
for destination: topic://MyApp/IOIs/Simulator | org.apache.activemq.broker.region.AbstractRegion
| ActiveMQ VMTransport: vm://localhost#1-2
> 2013-10-10 09:10:09,888 | DEBUG | amq-broker adding consumer: ID:MYAPPDATA-7392-1381410590247-5:1:1:2
for destination: topic://MyApp/IOIs/Simulator | org.apache.activemq.broker.region.AbstractRegion
| ActiveMQ VMTransport: vm://localhost#1-2
> 2013-10-10 09:10:09,904 | DEBUG | Subscribed: ActiveMQMessageConsumer { value=ID:MYAPPDATA-7392-1381410590247-5:1:1:2,
started=true } to topic://MyApp/IOIs/Simulator id=testconnection2 | org.apache.activemq.web.MessageListenerServlet
| qtp2088898587-53 - /demo/amq{quote}
> What is happening is that in MessageListenerServlet.js, function doPost, line 165 is
dropping any previous consumer to the same destination: 
> {code}client.closeConsumer(destination); // drop any existing consumer.{code}
> But why?  There doesn't seem to be a good reason for doing this--maybe it was originally
put there for cleanup purposes?.  Or if there is a good reason, maybe the behavior should
be to not do it if the id of the new destination (in this case 'testconnection2') is different
than the id of the existing destination ('testconnection1'). 
> I believe this can be fixed by simply removing line 165 from MessageListenerServlet.js
but I'm not sure if this will break something else.



--
This message was sent by Atlassian JIRA
(v6.1#6144)

Mime
View raw message