2929 * com.github.sonus21.rqueue.exception.QueueDoesNotExist}. In such case register your queue using
3030 * {@link RqueueEndpointManager#registerQueue(String, String...)} method.
3131 *
32- * <p>There are three types of interfaces in this 1. enqueueXYZ 2. enqueueInXYZ 3. enqueueAtXYZ
32+ * <p>There are four types of interfaces in this
3333 *
34- * <p>Messages enqueue using enqueueXYZ shall be consumed as soon as possible
34+ * <p>enqueueXYZ : Messages enqueue using this method shall be consumed as soon as possible
3535 *
36- * <p>Messages enqueue using enqueueInXYZ shall be consumed once the given time is elapsed, like in
37- * 30 seconds.
36+ * <p>enqueueInXYZ: Messages enqueue using enqueueInXYZ shall be consumed once the given time is
37+ * elapsed, like in 30 seconds.
3838 *
39- * <p>Messages send using enqueueAtXYZ shall be consumed as soon as the given time is reached for
40- * example 3PM tomorrow.
39+ * <p>enqueueAtXYZ: Messages send using enqueueAtXYZ shall be consumed as soon as the given time is
40+ * reached for example 3PM tomorrow.
41+ *
42+ * <p>enqueueUniqueXYZ: This method enqueue unique messages on a queue. New messages overwrite the
43+ * existing message, the overwriting only works till the point message is not consumed, once message
44+ * is consumed it's of no use.
4145 *
4246 * @author Sonu Kumar
4347 */
@@ -61,6 +65,18 @@ public interface RqueueMessageEnqueuer {
6165 */
6266 boolean enqueue (String queueName , String messageId , Object message );
6367
68+ /**
69+ * Enqueue unique message on a given queue without any delay, consume as soon as possible.
70+ *
71+ * @param queueName on which queue message has to be send
72+ * @param messageId the message id for uniqueness
73+ * @param message message object it could be any arbitrary object.
74+ * @return message id on successful enqueue otherwise null.
75+ */
76+ default boolean enqueueUnique (String queueName , String messageId , Object message ) {
77+ return enqueue (queueName , messageId , message );
78+ }
79+
6480 /**
6581 * Enqueue a message on the given queue with the given retry count. This message would not be
6682 * consumed more than the specified time due to failure in underlying systems.
@@ -107,18 +123,6 @@ public interface RqueueMessageEnqueuer {
107123 */
108124 boolean enqueueWithPriority (String queueName , String priority , String messageId , Object message );
109125
110- /**
111- * Enqueue unique message on a given queue without any delay, consume as soon as possible.
112- *
113- * @param queueName on which queue message has to be send
114- * @param messageId the message id for uniqueness
115- * @param message message object it could be any arbitrary object.
116- * @return message id on successful enqueue otherwise null.
117- */
118- default boolean enqueueUnique (String queueName , String messageId , Object message ) {
119- return enqueue (queueName , messageId , message );
120- }
121-
122126 /**
123127 * Enqueue unique message on given queue, that will be consumed as soon as possible.
124128 *
@@ -213,6 +217,20 @@ default boolean enqueueIn(
213217 return enqueueIn (queueName , messageId , message , unit .toMillis (delay ));
214218 }
215219
220+ /**
221+ * Enqueue a message on given queue with delay, consume as soon as the delayed is expired.
222+ *
223+ * @param queueName on which queue message has to be send
224+ * @param messageId the message id for uniqueness
225+ * @param message message object it could be any arbitrary object.
226+ * @param delayInMillisecond total execution delay
227+ * @return message id on successful enqueue otherwise {@literal null}.
228+ */
229+ default boolean enqueueUniqueIn (
230+ String queueName , String messageId , Object message , long delayInMillisecond ) {
231+ return enqueueIn (queueName , messageId , message , delayInMillisecond );
232+ }
233+
216234 /**
217235 * Enqueue a task that would be scheduled to run in the specified milli seconds.
218236 *
@@ -339,17 +357,25 @@ default boolean enqueueInWithPriority(
339357 }
340358
341359 /**
342- * Enqueue a message on given queue with delay, consume as soon as the delayed is expired.
360+ * Schedule unique message on the given queue at the provided time. It will be executed as soon as
361+ * the given delay is elapse.
343362 *
344363 * @param queueName on which queue message has to be send
345- * @param messageId the message id for uniqueness
364+ * @param priority the name of the priority level
365+ * @param messageId the message id
346366 * @param message message object it could be any arbitrary object.
347- * @param delayInMillisecond total execution delay
348- * @return message id on successful enqueue otherwise {@literal null}.
367+ * @param delay time to wait before it can be consumed.
368+ * @param unit unit of the delay
369+ * @return message was enqueue successfully or failed.
349370 */
350- default boolean enqueueUniqueIn (
351- String queueName , String messageId , Object message , long delayInMillisecond ) {
352- return enqueueIn (queueName , messageId , message , delayInMillisecond );
371+ default boolean enqueueUniqueInWithPriority (
372+ String queueName ,
373+ String priority ,
374+ String messageId ,
375+ Object message ,
376+ long delay ,
377+ TimeUnit unit ) {
378+ return enqueueInWithPriority (queueName , priority , messageId , message , unit .toMillis (delay ));
353379 }
354380
355381 /**
@@ -435,6 +461,22 @@ default boolean enqueueAt(String queueName, String messageId, Object message, Da
435461 return enqueueAt (queueName , messageId , message , starTime .toInstant ());
436462 }
437463
464+ /**
465+ * Schedule unique messages on the given queue at the provided time. It will be available to
466+ * consume as soon as the given time is reached.
467+ *
468+ * @param queueName on which queue message has to be send
469+ * @param message message object it could be any arbitrary object.
470+ * @param messageId a unique identifier message id for this message
471+ * @param timeInMilliSeconds time at which this message has to be consumed.
472+ * @return message was enqueue successfully or failed.
473+ */
474+ default boolean enqueueUniqueAt (
475+ String queueName , String messageId , Object message , long timeInMilliSeconds ) {
476+ return enqueueUniqueIn (
477+ queueName , messageId , message , timeInMilliSeconds - System .currentTimeMillis ());
478+ }
479+
438480 /**
439481 * Schedule a message on the given queue at the provided time. It will be executed as soon as the
440482 * given time is reached, time must be in the future.
@@ -543,14 +585,19 @@ default boolean enqueueAtWithPriority(
543585 * consume as soon as the given time is reached.
544586 *
545587 * @param queueName on which queue message has to be send
588+ * @param priority priority of the given message
546589 * @param message message object it could be any arbitrary object.
547590 * @param messageId a unique identifier message id for this message
548591 * @param timeInMilliSeconds time at which this message has to be consumed.
549592 * @return message was enqueue successfully or failed.
550593 */
551- default boolean enqueueUniqueAt (
552- String queueName , String messageId , Object message , long timeInMilliSeconds ) {
553- return enqueueUniqueIn (
554- queueName , messageId , message , timeInMilliSeconds - System .currentTimeMillis ());
594+ default boolean enqueueUniqueAtWithPriority (
595+ String queueName ,
596+ String priority ,
597+ String messageId ,
598+ Object message ,
599+ long timeInMilliSeconds ) {
600+ return enqueueAtWithPriority (
601+ queueName , priority , messageId , message , timeInMilliSeconds - System .currentTimeMillis ());
555602 }
556603}
0 commit comments