com.github.davidmarquis.redisq.utils.KeysFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of redisq Show documentation
Show all versions of redisq Show documentation
RedisQ - Java implementation of a reliable Pub/Sub message queue based on Redis
The newest version!
package com.github.davidmarquis.redisq.utils;
public class KeysFactory {
private static final String REGISTERED_CONSUMERS_KEY_PATTERN = "redisq.%s.consumers";
private static final String MESSAGE_KEY_PATTERN = "redisq.%s.messages.%s";
private static final String QUEUE_PATTERN = "redisq.%s.queues.%s";
private static final String NEXT_MESSAGE_ID_PATTERN = "redisq.%s.nextID";
private static final String LOCK_SUFFIX = ".lock";
private static final String NOTIF_LIST_SUFFIX = ".notifs";
public static String keyForConsumerSpecificQueue(String queue, String consumerId) {
return String.format(QUEUE_PATTERN, queue, consumerId);
}
public static String keyForConsumerSpecificQueueNotificationList(String queue, String consumerId) {
return keyForConsumerSpecificQueue(queue, consumerId) + NOTIF_LIST_SUFFIX;
}
public static String keyForConsumerSpecificQueueLock(String queue, String consumerId) {
return keyForConsumerSpecificQueue(queue, consumerId) + LOCK_SUFFIX;
}
public static String keyForMessage(String queueName, String messageId) {
return String.format(MESSAGE_KEY_PATTERN, queueName, messageId);
}
public static String keyForRegisteredConsumers(String queue) {
return String.format(REGISTERED_CONSUMERS_KEY_PATTERN, queue);
}
public static String keyForNextID(String queue) {
return String.format(NEXT_MESSAGE_ID_PATTERN, queue);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy