Author: norman
Date: Thu Mar 4 19:04:51 2010
New Revision: 919131
URL: http://svn.apache.org/viewvc?rev=919131&view=rev
Log:
Add delayer for computing the time to sleep before try to deliver the message
again. See JAMES-977
Added:
james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/MailDeliveryDelayer.java
Added:
james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/MailDeliveryDelayer.java
URL:
http://svn.apache.org/viewvc/james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/MailDeliveryDelayer.java?rev=919131&view=auto
==============================================================================
---
james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/MailDeliveryDelayer.java
(added)
+++
james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/MailDeliveryDelayer.java
Thu Mar 4 19:04:51 2010
@@ -0,0 +1,54 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you under the Apache License, Version 2.0 (the *
+ * "License"); you may not use this file except in compliance *
+ * with the License. You may obtain a copy of the License at *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, *
+ * software distributed under the License is distributed on an *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
+ * KIND, either express or implied. See the License for the *
+ * specific language governing permissions and limitations *
+ * under the License. *
+ ****************************************************************/
+
+package org.apache.james.transport.camel;
+
+import org.apache.camel.Header;
+
+/**
+ * Delayer which use a Header called NEXT_DELIVERY which contains a long value
which represent the Date
+ * in milliseconds till which the processing of the next Processor should be
delayed
+ *
+ *
+ */
+public class MailDeliveryDelayer {
+
+ /**
+ * Header to use for storing the date till the processing should be
delayed (in milliseconds)
+ */
+ public final static String NEXT_DELIVERY ="NEXT_DELIVERY";
+
+
+ /**
+ * Return the time in milliseconds which should the execution of the next
processor get delayed
+ *
+ * @param nextDelivery
+ * @return millisToSleep
+ */
+ public long delay(@Header(NEXT_DELIVERY) long nextDelivery) {
+ long sleepTime = nextDelivery - System.currentTimeMillis();
+
+ // check if we should trigger the next processor now
+ if (sleepTime < 0) {
+ sleepTime = 0;
+ }
+ return sleepTime;
+ }
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]