james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eric Charles <e...@apache.org>
Subject Re: svn commit: r1005067 - in /james/server/trunk: queue-activemq/src/main/java/org/apache/james/queue/activemq/ActiveMQMailQueue.java spring-deployment/src/main/config/james/spring-beans.xml
Date Thu, 07 Oct 2010 15:25:08 GMT
MAIL_PRORITY header could be named X-Priority (X- namespace being 
reserved for non-standard headers).

Additional values could be foreseen:
Highest Priority
High Priority
Normal (default if not defined)
Low Priority
Lowest Priority

I don't know if we have to use low or high numbers for high priority?

(see also for example
http://emailuniverse.com/ezine-tips/?Obscure-Email-Headers-%28Effective-Use-of-Email-Header-Fields,-Part-VI%29&id=182
http://www.chilkatsoft.com/p/p_471.asp

they seem to use 1 for high priority

)

Tks,

Eric

On 6/10/2010 16:48, norman@apache.org wrote:
> Author: norman
> Date: Wed Oct  6 14:48:27 2010
> New Revision: 1005067
>
> URL: http://svn.apache.org/viewvc?rev=1005067&view=rev
> Log:
> Add support for mail priority while dequeue mails from the ActiveMQMailQueue (JAMES-1058)
>
> Modified:
>      james/server/trunk/queue-activemq/src/main/java/org/apache/james/queue/activemq/ActiveMQMailQueue.java
>      james/server/trunk/spring-deployment/src/main/config/james/spring-beans.xml
>
> Modified: james/server/trunk/queue-activemq/src/main/java/org/apache/james/queue/activemq/ActiveMQMailQueue.java
> URL: http://svn.apache.org/viewvc/james/server/trunk/queue-activemq/src/main/java/org/apache/james/queue/activemq/ActiveMQMailQueue.java?rev=1005067&r1=1005066&r2=1005067&view=diff
> ==============================================================================
> --- james/server/trunk/queue-activemq/src/main/java/org/apache/james/queue/activemq/ActiveMQMailQueue.java
(original)
> +++ james/server/trunk/queue-activemq/src/main/java/org/apache/james/queue/activemq/ActiveMQMailQueue.java
Wed Oct  6 14:48:27 2010
> @@ -66,6 +66,14 @@ import org.apache.mailet.MailAddress;
>    *
>    * See http://activemq.apache.org/blob-messages.html for more details
>    *
> + *
> + * Some other supported feature is handling of priorities. See:
> + *
> + * http://activemq.apache.org/how-can-i-support-priority-queues.html
> + *
> + * For this just add a {@link Mail} attribute with name {@link #MAIL_PRIORITY} to it.
It should use one of the following
> + * value {@link #LOW_PRIORITY}, {@link #NORMAL_PRIORITY}, {@link #HIGH_PRIORITY}
> + *
>    *
>    */
>   public class ActiveMQMailQueue implements MailQueue {
> @@ -92,6 +100,31 @@ public class ActiveMQMailQueue implement
>       public final static int BLOBMESSAGE_ONLY = 0;
>
>       /**
> +     * Handle mail with lowest priority
> +     */
> +    public final static int LOW_PRIORITY = 1;
> +
> +    /**
> +     * Handle mail with normal priority (this is the default)
> +     */
> +    public final static int NORMAL_PRIORITY = 2;
> +
> +    /**
> +     * Handle mail with highest priority
> +     */
> +    public final static int HIGH_PRIORITY = 3;
> +
> +    /**
> +     * Attribute name for support if priority. If the attribute is set and priority
handling is enabled it will take care of move the Mails with
> +     * higher priority to the head of the queue (so the mails are faster handled).
> +     *
> +     * For enabling the feature in AMQ and get some more informations see:
> +     *
> +     * http://activemq.apache.org/how-can-i-support-priority-queues.html
> +     */
> +    public final static String MAIL_PRIORITY = "JMSPriority";
> +
> +    /**
>        * Construct a new ActiveMQ based {@link MailQueue}.
>        * The messageTreshold is used to calculate if a {@link BytesMessage} or a {@link
BlobMessage} should be used when queuing the mail in
>        * ActiveMQ. A {@link BlobMessage} is used If the message size is bigger then the
messageTreshold. The size if in bytes.
> @@ -362,7 +395,7 @@ public class ActiveMQMailQueue implement
>                   BytesMessage message  = session.createBytesMessage();
>
>                   populateJMSProperties(message, mail, delayInMillis);
> -
> +                populateJMSHeaders(message, mail);
>                   mail.getMessage().writeTo(new BytesMessageOutputStream(message));;
>                   return message;
>               } else {
> @@ -374,6 +407,8 @@ public class ActiveMQMailQueue implement
>                   }
>                   BlobMessage message  = amqSession.createBlobMessage(new MimeMessageInputStream(mail.getMessage()));
>                   populateJMSProperties(message, mail, delayInMillis);
> +                populateJMSHeaders(message, mail);
> +
>                   return message;
>               }
>
> @@ -447,8 +482,17 @@ public class ActiveMQMailQueue implement
>           message.setStringProperty(JAMES_MAIL_ATTRIBUTE_NAMES, attrsBuilder.toString());
>           message.setStringProperty(JAMES_MAIL_SENDER, sender);
>           message.setStringProperty(JAMES_MAIL_STATE, mail.getState());
> -
> +
> +
>       }
> +
> +    private void populateJMSHeaders(Message message, Mail mail) throws JMSException,
MessagingException {
> +    	Object prio = mail.getAttribute(MAIL_PRIORITY);
> +    	if (prio instanceof Integer) {
> +        	message.setJMSPriority((Integer) prio);
> +    	}
> +    }
> +
>       /**
>        * Convert the attribute value if necessary.
>        *
>
> Modified: james/server/trunk/spring-deployment/src/main/config/james/spring-beans.xml
> URL: http://svn.apache.org/viewvc/james/server/trunk/spring-deployment/src/main/config/james/spring-beans.xml?rev=1005067&r1=1005066&r2=1005067&view=diff
> ==============================================================================
> --- james/server/trunk/spring-deployment/src/main/config/james/spring-beans.xml (original)
> +++ james/server/trunk/spring-deployment/src/main/config/james/spring-beans.xml Wed Oct
 6 14:48:27 2010
> @@ -130,6 +130,17 @@
>
>       <!--  lets create an embedded ActiveMQ Broker -->
>       <amq:broker useJmx="false" persistent="true" dataDirectory="../data/" schedulerSupport="true"
id="broker">
> +<amq:destinationPolicy>
> +<amq:policyMap>
> +<amq:policyEntries>
> +<!-- Support priority handling of messages -->
> +<!-- http://activemq.apache.org/how-can-i-support-priority-queues.html -->
> +<!--
> +<amq:policyEntry queue=">" prioritizedMessages="true"/>
> +                    -->
> +</amq:policyEntries>
> +</amq:policyMap>
> +</amq:destinationPolicy>
>           <amq:transportConnectors>
>               <amq:transportConnector uri="tcp://localhost:0" />
>           </amq:transportConnectors>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
> For additional commands, e-mail: server-dev-help@james.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message