You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by "Rob Lugt (JIRA)" <ji...@apache.org> on 2006/10/24 12:16:02 UTC

[jira] Created: (AMQ-999) Message dispatcher issues (use dedicated dispatching thread for each session)

Message dispatcher issues (use dedicated dispatching thread for each session)
-----------------------------------------------------------------------------

                 Key: AMQ-999
                 URL: https://issues.apache.org/activemq/browse/AMQ-999
             Project: ActiveMQ
          Issue Type: Improvement
          Components: NMS (C# client)
    Affects Versions: 4.0.2
         Environment: Windows
            Reporter: Rob Lugt
         Assigned To: Rob Lugt


There are a number of issues with the dispatching of inbound messages.

- A slow consumer will potentially use and block all ThreadPool threads
- Use of a ThreadPool thread to dispatch a single message is inefficient due to context switching
- No mechanism to suspend asynchronous delivery to a session (i.e. Connection.Stop() is currently a no-op)
- Retroactive consumer is currently broken because retoractive messages are delivered before the listener delegate is assigned.
- [minor] Application cannot predict which thread messages will be dispatched on

All of these problems can simply be resolved by creating a dedicated dispatcher thread for a session

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/activemq/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Reopened: (AMQ-999) Message dispatcher issues (use dedicated dispatching thread for each session)

Posted by "Rob Lugt (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/AMQ-999?page=all ]

Rob Lugt reopened AMQ-999:
--------------------------

             
Minor build problem: DispatcherThread.cs needs to be added to vs2005-activemq.csproj

> Message dispatcher issues (use dedicated dispatching thread for each session)
> -----------------------------------------------------------------------------
>
>                 Key: AMQ-999
>                 URL: https://issues.apache.org/activemq/browse/AMQ-999
>             Project: ActiveMQ
>          Issue Type: Improvement
>          Components: NMS (C# client)
>    Affects Versions: 4.0.2
>         Environment: Windows
>            Reporter: Rob Lugt
>         Assigned To: james strachan
>             Fix For: 4.1
>
>         Attachments: amq999-patch.txt, AtomicBoolean.cs, DispatchingThread.cs
>
>
> There are a number of issues with the dispatching of inbound messages.
> - A slow consumer will potentially use and block all ThreadPool threads
> - Use of a ThreadPool thread to dispatch a single message is inefficient due to context switching
> - No mechanism to suspend asynchronous delivery to a session (i.e. Connection.Stop() is currently a no-op)
> - Retroactive consumer is currently broken because retoractive messages are delivered before the listener delegate is assigned.
> - [minor] Application cannot predict which thread messages will be dispatched on
> All of these problems can simply be resolved by creating a dedicated dispatcher thread for a session

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/activemq/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Updated: (AMQ-999) Message dispatcher issues (use dedicated dispatching thread for each session)

Posted by "Rob Lugt (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/AMQ-999?page=all ]

Rob Lugt updated AMQ-999:
-------------------------

    Attachment: amq999-patch.txt

Patch to use dedicated DispacherThread instead of the application ThreadPool.

In addition to using the dedicated thread, this patch also moves the NMS client closer to the JMS specification:

Connection.Start() and Connection.Stop() now perform as advertised for asynchronous message delievery (but they have no affect on synchronous delivery).  The big difference between JMS and NMS at the moment is that a new session is started by default (whereas a JMS connection is stopped I believe).  I've done this to ensure backwards compatability with existing .Net users, but am more than happy for it to be reversed to align with JMS.

Retroactive consumers are catered for by setting the message delivery event at the same tiem as registering an asynchronous even listener - so that messages already received  will be delivered immediately.

Where applicable I've also added Close methods to compliment Dispose() and to make both Close and Dispose behave correctly when called multiple times.

Use of a dedicated dispatching thread improves message throughput in my test client by about 40%!



> Message dispatcher issues (use dedicated dispatching thread for each session)
> -----------------------------------------------------------------------------
>
>                 Key: AMQ-999
>                 URL: https://issues.apache.org/activemq/browse/AMQ-999
>             Project: ActiveMQ
>          Issue Type: Improvement
>          Components: NMS (C# client)
>    Affects Versions: 4.0.2
>         Environment: Windows
>            Reporter: Rob Lugt
>         Assigned To: Rob Lugt
>         Attachments: amq999-patch.txt, AtomicBoolean.cs, DispatchingThread.cs
>
>
> There are a number of issues with the dispatching of inbound messages.
> - A slow consumer will potentially use and block all ThreadPool threads
> - Use of a ThreadPool thread to dispatch a single message is inefficient due to context switching
> - No mechanism to suspend asynchronous delivery to a session (i.e. Connection.Stop() is currently a no-op)
> - Retroactive consumer is currently broken because retoractive messages are delivered before the listener delegate is assigned.
> - [minor] Application cannot predict which thread messages will be dispatched on
> All of these problems can simply be resolved by creating a dedicated dispatcher thread for a session

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/activemq/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Assigned: (AMQ-999) Message dispatcher issues (use dedicated dispatching thread for each session)

Posted by "Rob Lugt (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/AMQ-999?page=all ]

Rob Lugt reassigned AMQ-999:
----------------------------

    Assignee: james strachan  (was: Rob Lugt)

Hi James.  Please review and apply the attached patches.

> Message dispatcher issues (use dedicated dispatching thread for each session)
> -----------------------------------------------------------------------------
>
>                 Key: AMQ-999
>                 URL: https://issues.apache.org/activemq/browse/AMQ-999
>             Project: ActiveMQ
>          Issue Type: Improvement
>          Components: NMS (C# client)
>    Affects Versions: 4.0.2
>         Environment: Windows
>            Reporter: Rob Lugt
>         Assigned To: james strachan
>         Attachments: amq999-patch.txt, AtomicBoolean.cs, DispatchingThread.cs
>
>
> There are a number of issues with the dispatching of inbound messages.
> - A slow consumer will potentially use and block all ThreadPool threads
> - Use of a ThreadPool thread to dispatch a single message is inefficient due to context switching
> - No mechanism to suspend asynchronous delivery to a session (i.e. Connection.Stop() is currently a no-op)
> - Retroactive consumer is currently broken because retoractive messages are delivered before the listener delegate is assigned.
> - [minor] Application cannot predict which thread messages will be dispatched on
> All of these problems can simply be resolved by creating a dedicated dispatcher thread for a session

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/activemq/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Updated: (AMQ-999) Message dispatcher issues (use dedicated dispatching thread for each session)

Posted by "Rob Lugt (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/AMQ-999?page=all ]

Rob Lugt updated AMQ-999:
-------------------------

    Attachment: DispatchingThread.cs

New class: DispatchingThread.  This is a worker thread attached to a session, which has responsibility for asynchronous dispatching of inbound messages to all consumers for the session.

> Message dispatcher issues (use dedicated dispatching thread for each session)
> -----------------------------------------------------------------------------
>
>                 Key: AMQ-999
>                 URL: https://issues.apache.org/activemq/browse/AMQ-999
>             Project: ActiveMQ
>          Issue Type: Improvement
>          Components: NMS (C# client)
>    Affects Versions: 4.0.2
>         Environment: Windows
>            Reporter: Rob Lugt
>         Assigned To: Rob Lugt
>         Attachments: AtomicBoolean.cs, DispatchingThread.cs
>
>
> There are a number of issues with the dispatching of inbound messages.
> - A slow consumer will potentially use and block all ThreadPool threads
> - Use of a ThreadPool thread to dispatch a single message is inefficient due to context switching
> - No mechanism to suspend asynchronous delivery to a session (i.e. Connection.Stop() is currently a no-op)
> - Retroactive consumer is currently broken because retoractive messages are delivered before the listener delegate is assigned.
> - [minor] Application cannot predict which thread messages will be dispatched on
> All of these problems can simply be resolved by creating a dedicated dispatcher thread for a session

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/activemq/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Resolved: (AMQ-999) Message dispatcher issues (use dedicated dispatching thread for each session)

Posted by "james strachan (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/AMQ-999?page=all ]

james strachan resolved AMQ-999.
--------------------------------

    Fix Version/s: 4.1
       Resolution: Fixed

Patches applied with thanks Rob!

I made a minor change to the patch so that the code still works on Mono 1.0; I used the class AutoResetEvent instead of EventWaitHandle to avoid compile errors in Dispatcher.cs and DispatchingThead.cs - see the TODO notes in those files in case you can think of a cleaner solution.

Cheers!

> Message dispatcher issues (use dedicated dispatching thread for each session)
> -----------------------------------------------------------------------------
>
>                 Key: AMQ-999
>                 URL: https://issues.apache.org/activemq/browse/AMQ-999
>             Project: ActiveMQ
>          Issue Type: Improvement
>          Components: NMS (C# client)
>    Affects Versions: 4.0.2
>         Environment: Windows
>            Reporter: Rob Lugt
>         Assigned To: james strachan
>             Fix For: 4.1
>
>         Attachments: amq999-patch.txt, AtomicBoolean.cs, DispatchingThread.cs
>
>
> There are a number of issues with the dispatching of inbound messages.
> - A slow consumer will potentially use and block all ThreadPool threads
> - Use of a ThreadPool thread to dispatch a single message is inefficient due to context switching
> - No mechanism to suspend asynchronous delivery to a session (i.e. Connection.Stop() is currently a no-op)
> - Retroactive consumer is currently broken because retoractive messages are delivered before the listener delegate is assigned.
> - [minor] Application cannot predict which thread messages will be dispatched on
> All of these problems can simply be resolved by creating a dedicated dispatcher thread for a session

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/activemq/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Updated: (AMQ-999) Message dispatcher issues (use dedicated dispatching thread for each session)

Posted by "Hiram Chirino (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/AMQ-999?page=all ]

Hiram Chirino updated AMQ-999:
------------------------------

    Fix Version/s: 4.2
                       (was: 4.1.0)

> Message dispatcher issues (use dedicated dispatching thread for each session)
> -----------------------------------------------------------------------------
>
>                 Key: AMQ-999
>                 URL: https://issues.apache.org/activemq/browse/AMQ-999
>             Project: ActiveMQ
>          Issue Type: Improvement
>          Components: NMS (C# client)
>    Affects Versions: 4.0.2
>         Environment: Windows
>            Reporter: Rob Lugt
>         Assigned To: james strachan
>             Fix For: 4.2.0
>
>         Attachments: amq999-patch.txt, AtomicBoolean.cs, DispatchingThread.cs
>
>
> There are a number of issues with the dispatching of inbound messages.
> - A slow consumer will potentially use and block all ThreadPool threads
> - Use of a ThreadPool thread to dispatch a single message is inefficient due to context switching
> - No mechanism to suspend asynchronous delivery to a session (i.e. Connection.Stop() is currently a no-op)
> - Retroactive consumer is currently broken because retoractive messages are delivered before the listener delegate is assigned.
> - [minor] Application cannot predict which thread messages will be dispatched on
> All of these problems can simply be resolved by creating a dedicated dispatcher thread for a session

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/activemq/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (AMQ-999) Message dispatcher issues (use dedicated dispatching thread for each session)

Posted by "Stuart Bain (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/AMQ-999?page=comments#action_37348 ] 
            
Stuart Bain commented on AMQ-999:
---------------------------------

DispatcherThread.cs also needs to be added to vs2005-activemq-cf20.csproj

Addition of the Close method to the ISession, IConnection, and IMessageConsumer interfaces in this patch breaks the corresponding MSMQ Session, Connection and MessageConsumer implementation classes.



> Message dispatcher issues (use dedicated dispatching thread for each session)
> -----------------------------------------------------------------------------
>
>                 Key: AMQ-999
>                 URL: https://issues.apache.org/activemq/browse/AMQ-999
>             Project: ActiveMQ
>          Issue Type: Improvement
>          Components: NMS (C# client)
>    Affects Versions: 4.0.2
>         Environment: Windows
>            Reporter: Rob Lugt
>         Assigned To: james strachan
>             Fix For: 4.1
>
>         Attachments: amq999-patch.txt, AtomicBoolean.cs, DispatchingThread.cs
>
>
> There are a number of issues with the dispatching of inbound messages.
> - A slow consumer will potentially use and block all ThreadPool threads
> - Use of a ThreadPool thread to dispatch a single message is inefficient due to context switching
> - No mechanism to suspend asynchronous delivery to a session (i.e. Connection.Stop() is currently a no-op)
> - Retroactive consumer is currently broken because retoractive messages are delivered before the listener delegate is assigned.
> - [minor] Application cannot predict which thread messages will be dispatched on
> All of these problems can simply be resolved by creating a dedicated dispatcher thread for a session

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/activemq/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Updated: (AMQ-999) Message dispatcher issues (use dedicated dispatching thread for each session)

Posted by "Rob Lugt (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/AMQ-999?page=all ]

Rob Lugt updated AMQ-999:
-------------------------

    Attachment: AtomicBoolean.cs

Added Value property (this file also supplied in AMQ-995)

> Message dispatcher issues (use dedicated dispatching thread for each session)
> -----------------------------------------------------------------------------
>
>                 Key: AMQ-999
>                 URL: https://issues.apache.org/activemq/browse/AMQ-999
>             Project: ActiveMQ
>          Issue Type: Improvement
>          Components: NMS (C# client)
>    Affects Versions: 4.0.2
>         Environment: Windows
>            Reporter: Rob Lugt
>         Assigned To: Rob Lugt
>         Attachments: AtomicBoolean.cs
>
>
> There are a number of issues with the dispatching of inbound messages.
> - A slow consumer will potentially use and block all ThreadPool threads
> - Use of a ThreadPool thread to dispatch a single message is inefficient due to context switching
> - No mechanism to suspend asynchronous delivery to a session (i.e. Connection.Stop() is currently a no-op)
> - Retroactive consumer is currently broken because retoractive messages are delivered before the listener delegate is assigned.
> - [minor] Application cannot predict which thread messages will be dispatched on
> All of these problems can simply be resolved by creating a dedicated dispatcher thread for a session

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/activemq/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira