Hi Cole,

I have no experience with 2.3 branch but the code responsible for
routing is loacated in:
http://svn.apache.org/repos/asf/james/server/branches/v2.3/src/java/org/apache/james/dnsserver/DNSServer.java
. Namely: getSMTPHostAddresses, findMXRecords and findMXRecordsRaw.
The javadoc for findMXRecords shows:

Sorting is done in findMXRecordsRaw:

    public List findMXRecordsRaw(String hostname) {
        Record answers[] = lookup(hostname, Type.MX);
        List servers = new ArrayList();
        if (answers == null) {
            return servers;
        }

        MXRecord mxAnswers[] = new MXRecord[answers.length];
        for (int i = 0; i < answers.length; i++) {
            mxAnswers[i] = (MXRecord)answers[i];
        }

        Arrays.sort(mxAnswers, mxComparator);

        for (int i = 0; i < mxAnswers.length; i++) {
            servers.add(mxAnswers[i].getTarget ().toString ());
            getLogger().debug(new StringBuffer("Found MX record
").append(mxAnswers[i].getTarget ().toString ()).toString());
        }
        return servers;
    }


MX sorting and randomization is done via:

    /* RFC 2821 section 5 requires that we sort the MX records by their
     * preference, and introduce a randomization.  This Comparator does
     * comparisons as normal unless the values are equal, in which case
     * it "tosses a coin", randomly speaking.
     *
     * This way MX record w/preference 0 appears before MX record
     * w/preference 1, but a bunch of MX records with the same preference
     * would appear in different orders each time.
     *
     * Reminder for maintainers: the return value on a Comparator can
     * be counter-intuitive for those who aren't used to the old C
     * strcmp function:
     *
     * < 0 ==> a < b
     * = 0 ==> a = b
     * > 0 ==> a > b
     */
    private static class MXRecordComparator implements Comparator {
        private final static Random random = new Random();
        public int compare (Object a, Object b) {
            int pa = ((MXRecord)a).getPriority();
            int pb = ((MXRecord)b).getPriority();
            return (pa == pb) ? (512 - random.nextInt(1024)) : pa - pb;
        }
    }


Most likely the problems come from here. Hope this helps,

Cheers,

2012/5/9 Cole Ferrier <[email protected]>:
> Recycle of James did not work, it is still equally using all 6 of the mail
> servers, even though they are at a different preference levels.
>
> Any Ideas?
>
> Cole
>
> On Tue, May 8, 2012 at 3:03 PM, Cole Ferrier <[email protected]> wrote:
>
>> talking with our internal mail system people, all 6 servers had a priority
>> of 10 the last time apache James was restarted.
>>
>> Does James cache this data for the life of it running? or is there a time
>> to live? or?
>>
>> I will schedule a recycle of james to see if it stops using the servers
>> that now have a lower preference.
>>
>> Let me know if you have any ideas in the mean time.
>>
>> Cole
>>
>>
>> On Tue, May 8, 2012 at 9:42 AM, Cole Ferrier <[email protected]> wrote:
>>
>>> We have an internal mail system that has 6 MX records 3 at priority 10
>>> (new servers recently added) and 3 at priority 20 (old servers that where
>>> previously at 10).
>>>
>>> and it appears that apache james 2.3 is sending mail to all of them about
>>> equally?
>>>
>>> i was instructed that it should only connect to the 20's when all of the
>>> 10s are unavailable?
>>>
>>> any help would be appreciated?
>>>
>>> (or is there any need to restart James? aka, how long does it cache its
>>> data about the MX preferences?)
>>>
>>> Cole
>>>
>>
>>



-- 
Ioan Eugen Stan
http://ieugen.blogspot.com/  *** http://bucharest-jug.github.com/ ***

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to