You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Rodrigo Ramos <cr...@gmail.com> on 2014/01/20 20:51:04 UTC
Transport Options (Randomize algorithm)
Hello
I´m going to use randomize transport option, but, first I want to know how
does it work, in others words, What algorithm is used for randomize?
Regards
Re: Transport Options (Randomize algorithm)
Posted by Rodrigo Ramos <cr...@gmail.com>.
Thanks for your help and your code.
2014/1/21 Richard Kettelerij <ri...@gmail.com>
> Here's the implementation of ?randomize=true. Source
>
> https://github.com/apache/activemq/blob/trunk/activemq-client/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java
>
> if (randomize) {
> // Randomly, reorder the list by random swapping
> for (int i = 0; i < l.size(); i++) {
> // meed parenthesis due other JDKs (see AMQ-4826)
>
> int p = ((int) (Math.random() * 100)) % l.size();
> URI t = l.get(p);
> l.set(p, l.get(i));
> l.set(i, t);
> }
> }
>
>
>
> On Mon, Jan 20, 2014 at 8:51 PM, Rodrigo Ramos <cr...@gmail.com>
> wrote:
>
> > Hello
> >
> > I´m going to use randomize transport option, but, first I want to know
> how
> > does it work, in others words, What algorithm is used for randomize?
> >
> >
> > Regards
> >
>
Re: Transport Options (Randomize algorithm)
Posted by Richard Kettelerij <ri...@gmail.com>.
Here's the implementation of ?randomize=true. Source
https://github.com/apache/activemq/blob/trunk/activemq-client/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java
if (randomize) {
// Randomly, reorder the list by random swapping
for (int i = 0; i < l.size(); i++) {
// meed parenthesis due other JDKs (see AMQ-4826)
int p = ((int) (Math.random() * 100)) % l.size();
URI t = l.get(p);
l.set(p, l.get(i));
l.set(i, t);
}
}
On Mon, Jan 20, 2014 at 8:51 PM, Rodrigo Ramos <cr...@gmail.com> wrote:
> Hello
>
> I´m going to use randomize transport option, but, first I want to know how
> does it work, in others words, What algorithm is used for randomize?
>
>
> Regards
>