You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by pmmerritt1 <pm...@gmail.com> on 2010/04/07 22:26:40 UTC

ActiveMQ JMSPriority (AMQ-122)

We had a need to use priority based queuing on a project I am working on and
do not have enough time to wait on 6.0.0 to come out which is what AMQ-122
states as the release date, so I took a stab at implementing it. Since I am
not too familiar with ActiveMQ I was hoping that one of the developers may
be able to pick it up and incorporate into a 5.3 release if at all possible.
I ran the unit tests and they seem to run with the exception of issues with
the SSL but I do not believe that is related to the changes I made. 

Here is the summary of the changes, all source files are attached:
1) Created class PriorityMessageDispatchChannel which replaced
MessageDispatchChannel
2) Updated ActiveMQMessageConsumer.java and ActiveMQSessionExecutor.java in
order to instantiate the PriorityMessageDispatchChannel instead of the the
MessageDispatchChannel. This would be best done at runtime based upon a
configuration option such as supportsJMSPriority, however I did not want to
make that significant of a change until I could figure out the feasibility
of getting it incorporated into ActiveMQ.
3) Updated ActiveMQConnection.java and ActiveMQSession.java to only set the
message priority to the defaultPriority if it wasn't set on the Message.
4) Added a unit test ChangeSentMessagePriorityTest.java

I have attached all of the source files to this post, please let me know if
it is possible to get this into a release and if so if I can do anything to
help make that happen.

Thanks,
Phillip Merritt
http://old.nabble.com/file/p28170545/ActiveMQConnection.java
ActiveMQConnection.java 
http://old.nabble.com/file/p28170545/ActiveMQMessageConsumer.java
ActiveMQMessageConsumer.java 
http://old.nabble.com/file/p28170545/ActiveMQSession.java
ActiveMQSession.java 
http://old.nabble.com/file/p28170545/ActiveMQSessionExecutor.java
ActiveMQSessionExecutor.java 
http://old.nabble.com/file/p28170545/ChangeSentMessagePriorityTest.java
ChangeSentMessagePriorityTest.java 
http://old.nabble.com/file/p28170545/PriorityMessageDispatchChannel.java
PriorityMessageDispatchChannel.java 
-- 
View this message in context: http://old.nabble.com/ActiveMQ-JMSPriority-%28AMQ-122%29-tp28170545p28170545.html
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.


Re: ActiveMQ JMSPriority (AMQ-122)

Posted by pmmerritt1 <pm...@gmail.com>.
I added the files as suggested using svn add and created a new patch file and
will upload it, however I cannot get to the issues.apache.org site right now
for some reason. As far as unit testing goes I did write a unit test
specifically to test priority "JmsPriorityTest". It sends 200 messages using
a modulus to send priorities 1,2,3,4,5,6,7,8,9,10 in repeating order and
then verifies that it receives them in the correct priority order
(10,10,10,10,9,9,9,9....1,1,1,1). In addition, I temporarily updated the
MessageDispatchChannelFactory to always return the
PrioritizedDispatchMessageChannel and ran some of the unit tests and got the
same results as before although I did not run all of them because the tests
using SSL will not run on my machine for some reason. Can you think of some
good tests already included in activemq-core that would be good to run with
a prioritized broker as well? Theoretically all of them should still run
with the PrioritizedDispatchMessageChannel as long as none of the tests are
specifying the JMSPriority, but rerunning all of them would be overkill. If
you can think of some specific ones that would be good to run again with a
Prioritized broker I will look into converting them to run both with and
without the useJmsPriority flag.

Thanks,
Phil
-- 
View this message in context: http://old.nabble.com/ActiveMQ-JMSPriority-%28AMQ-122%29-tp28170545p28196721.html
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.


Re: ActiveMQ JMSPriority (AMQ-122)

Posted by Bruce Snyder <br...@gmail.com>.
On Fri, Apr 9, 2010 at 11:43 AM, pmmerritt1 <pm...@gmail.com> wrote:
>
> I have attached the files to AMQ-122. I cleaned up the implementation a
> little bit before attaching
>
> In summary I made the following changes
> 1) Added a useJmsPriority option to the Broker
> 2) Added the useJmsPriority parameter to the BrokerInfo class
> 3) Updated code which was creating BrokerInfo instances to set the
> useJmsPriority
> 4) Converted MessageDispatchChannel into an Interface
> 5) Created a new class FifoMessageDispatchChannel which implements
> MessageDispatchChannel and contains the same implementation as was
> previously in MessageDispatchChannel
> 6) Created a new class PriorityMessageDispatchChannel which contains the
> newly created PrioritizedMessageDispatchChannel. This implementation
> contains an array of priority linkedlists and a current index to the highest
> priority linkedlist. So messages are dequeued from the highest priority
> linked list with messages and enqueued to the linked list which corresponds
> to the priority in the message.
> 7) Created a MessageDispatchChannelFactory which returns the appropriate
> MessageDispatchChannel dependent upon the value of the useJmsPriority
> parameter
> 8) Updated ActiveMQConnection and ActiveMQSession to only override the
> message priority when useJmsPriority is false or the message priority is not
> set.
> 9) Added a new unit test JmsPriorityTest in order to test priority ordering

If you 'svn add' the new files so that they're scheduled to be added
to the repo, then they will be included in the diff file. Do you have
JUnit test that validates these changes at all? Providing tests will
expedite the process.

Bruce
-- 
perl -e 'print unpack("u30","D0G)U8V4\@4VYY9&5R\"F)R=6-E+G-N>61E<D\!G;6%I;\"YC;VT*"
);'

ActiveMQ in Action: http://bit.ly/2je6cQ
Blog: http://bruceblog.org/
Twitter: http://twitter.com/brucesnyder

Re: ActiveMQ JMSPriority (AMQ-122)

Posted by pmmerritt1 <pm...@gmail.com>.
I have attached the files to AMQ-122. I cleaned up the implementation a
little bit before attaching

In summary I made the following changes
1) Added a useJmsPriority option to the Broker
2) Added the useJmsPriority parameter to the BrokerInfo class
3) Updated code which was creating BrokerInfo instances to set the
useJmsPriority
4) Converted MessageDispatchChannel into an Interface
5) Created a new class FifoMessageDispatchChannel which implements
MessageDispatchChannel and contains the same implementation as was
previously in MessageDispatchChannel
6) Created a new class PriorityMessageDispatchChannel which contains the
newly created PrioritizedMessageDispatchChannel. This implementation
contains an array of priority linkedlists and a current index to the highest
priority linkedlist. So messages are dequeued from the highest priority
linked list with messages and enqueued to the linked list which corresponds
to the priority in the message.
7) Created a MessageDispatchChannelFactory which returns the appropriate
MessageDispatchChannel dependent upon the value of the useJmsPriority
parameter
8) Updated ActiveMQConnection and ActiveMQSession to only override the
message priority when useJmsPriority is false or the message priority is not
set.
9) Added a new unit test JmsPriorityTest in order to test priority ordering

Thanks,
Phillip Merritt


bsnyder wrote:
> 
> On Wed, Apr 7, 2010 at 2:26 PM, pmmerritt1 <pm...@gmail.com> wrote:
>>
>> We had a need to use priority based queuing on a project I am working on
>> and
>> do not have enough time to wait on 6.0.0 to come out which is what
>> AMQ-122
>> states as the release date, so I took a stab at implementing it. Since I
>> am
>> not too familiar with ActiveMQ I was hoping that one of the developers
>> may
>> be able to pick it up and incorporate into a 5.3 release if at all
>> possible.
>> I ran the unit tests and they seem to run with the exception of issues
>> with
>> the SSL but I do not believe that is related to the changes I made.
>>
>> Here is the summary of the changes, all source files are attached:
>> 1) Created class PriorityMessageDispatchChannel which replaced
>> MessageDispatchChannel
>> 2) Updated ActiveMQMessageConsumer.java and ActiveMQSessionExecutor.java
>> in
>> order to instantiate the PriorityMessageDispatchChannel instead of the
>> the
>> MessageDispatchChannel. This would be best done at runtime based upon a
>> configuration option such as supportsJMSPriority, however I did not want
>> to
>> make that significant of a change until I could figure out the
>> feasibility
>> of getting it incorporated into ActiveMQ.
>> 3) Updated ActiveMQConnection.java and ActiveMQSession.java to only set
>> the
>> message priority to the defaultPriority if it wasn't set on the Message.
>> 4) Added a unit test ChangeSentMessagePriorityTest.java
>>
>> I have attached all of the source files to this post, please let me know
>> if
>> it is possible to get this into a release and if so if I can do anything
>> to
>> help make that happen.
>>
>> Thanks,
>> Phillip Merritt
>> http://old.nabble.com/file/p28170545/ActiveMQConnection.java
>> ActiveMQConnection.java
>> http://old.nabble.com/file/p28170545/ActiveMQMessageConsumer.java
>> ActiveMQMessageConsumer.java
>> http://old.nabble.com/file/p28170545/ActiveMQSession.java
>> ActiveMQSession.java
>> http://old.nabble.com/file/p28170545/ActiveMQSessionExecutor.java
>> ActiveMQSessionExecutor.java
>> http://old.nabble.com/file/p28170545/ChangeSentMessagePriorityTest.java
>> ChangeSentMessagePriorityTest.java
>> http://old.nabble.com/file/p28170545/PriorityMessageDispatchChannel.java
>> PriorityMessageDispatchChannel.java
> 
> Please create a diff of your changes and attach it to the JIRA issue
> as noted here:
> 
> http://activemq.apache.org/contributing.html#Contributing-Submittingpatches
> 
> Bruce
> -- 
> perl -e 'print
> unpack("u30","D0G)U8V4\@4VYY9&5R\"F)R=6-E+G-N>61E<D\!G;6%I;\"YC;VT*"
> );'
> 
> ActiveMQ in Action: http://bit.ly/2je6cQ
> Blog: http://bruceblog.org/
> Twitter: http://twitter.com/brucesnyder
> 
> 

-- 
View this message in context: http://old.nabble.com/ActiveMQ-JMSPriority-%28AMQ-122%29-tp28170545p28195453.html
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.


Re: ActiveMQ JMSPriority (AMQ-122)

Posted by Bruce Snyder <br...@gmail.com>.
On Wed, Apr 7, 2010 at 2:26 PM, pmmerritt1 <pm...@gmail.com> wrote:
>
> We had a need to use priority based queuing on a project I am working on and
> do not have enough time to wait on 6.0.0 to come out which is what AMQ-122
> states as the release date, so I took a stab at implementing it. Since I am
> not too familiar with ActiveMQ I was hoping that one of the developers may
> be able to pick it up and incorporate into a 5.3 release if at all possible.
> I ran the unit tests and they seem to run with the exception of issues with
> the SSL but I do not believe that is related to the changes I made.
>
> Here is the summary of the changes, all source files are attached:
> 1) Created class PriorityMessageDispatchChannel which replaced
> MessageDispatchChannel
> 2) Updated ActiveMQMessageConsumer.java and ActiveMQSessionExecutor.java in
> order to instantiate the PriorityMessageDispatchChannel instead of the the
> MessageDispatchChannel. This would be best done at runtime based upon a
> configuration option such as supportsJMSPriority, however I did not want to
> make that significant of a change until I could figure out the feasibility
> of getting it incorporated into ActiveMQ.
> 3) Updated ActiveMQConnection.java and ActiveMQSession.java to only set the
> message priority to the defaultPriority if it wasn't set on the Message.
> 4) Added a unit test ChangeSentMessagePriorityTest.java
>
> I have attached all of the source files to this post, please let me know if
> it is possible to get this into a release and if so if I can do anything to
> help make that happen.
>
> Thanks,
> Phillip Merritt
> http://old.nabble.com/file/p28170545/ActiveMQConnection.java
> ActiveMQConnection.java
> http://old.nabble.com/file/p28170545/ActiveMQMessageConsumer.java
> ActiveMQMessageConsumer.java
> http://old.nabble.com/file/p28170545/ActiveMQSession.java
> ActiveMQSession.java
> http://old.nabble.com/file/p28170545/ActiveMQSessionExecutor.java
> ActiveMQSessionExecutor.java
> http://old.nabble.com/file/p28170545/ChangeSentMessagePriorityTest.java
> ChangeSentMessagePriorityTest.java
> http://old.nabble.com/file/p28170545/PriorityMessageDispatchChannel.java
> PriorityMessageDispatchChannel.java

Please create a diff of your changes and attach it to the JIRA issue
as noted here:

http://activemq.apache.org/contributing.html#Contributing-Submittingpatches

Bruce
-- 
perl -e 'print unpack("u30","D0G)U8V4\@4VYY9&5R\"F)R=6-E+G-N>61E<D\!G;6%I;\"YC;VT*"
);'

ActiveMQ in Action: http://bit.ly/2je6cQ
Blog: http://bruceblog.org/
Twitter: http://twitter.com/brucesnyder