use of org.apache.sling.distribution.queue.impl.CachingDistributionQueue in project sling by apache.
the class JobHandlingDistributionQueueProvider method getQueue.
@Nonnull
public DistributionQueue getQueue(@Nonnull String queueName) {
String topic = JobHandlingDistributionQueue.DISTRIBUTION_QUEUE_TOPIC + '/' + prefix + "/" + queueName;
boolean isActive = jobConsumer != null && (processingQueueNames == null || processingQueueNames.contains(queueName));
DistributionQueue queue = new JobHandlingDistributionQueue(queueName, topic, jobManager, isActive, DistributionQueueType.ORDERED);
queue = new CachingDistributionQueue(topic, queue);
return queue;
}
use of org.apache.sling.distribution.queue.impl.CachingDistributionQueue in project sling by apache.
the class JobHandlingDistributionQueueProvider method getQueue.
@Override
public DistributionQueue getQueue(@Nonnull String queueName, @Nonnull DistributionQueueType type) {
String topic = JobHandlingDistributionQueue.DISTRIBUTION_QUEUE_TOPIC + '/' + type.name().toLowerCase() + '/' + prefix + "/" + queueName;
boolean isActive = jobConsumer != null && (processingQueueNames == null || processingQueueNames.contains(queueName));
try {
if (configAdmin != null && jobManager.getQueue(queueName) == null && configAdmin.getConfiguration(queueName) == null) {
Configuration config = configAdmin.createFactoryConfiguration(QueueConfiguration.class.getName(), null);
Dictionary<String, Object> props = new Hashtable<String, Object>();
props.put(ConfigurationConstants.PROP_NAME, queueName);
props.put(ConfigurationConstants.PROP_TYPE, QueueConfiguration.Type.UNORDERED.name());
props.put(ConfigurationConstants.PROP_TOPICS, new String[] { topic });
props.put(ConfigurationConstants.PROP_RETRIES, -1);
props.put(ConfigurationConstants.PROP_RETRY_DELAY, 2000L);
props.put(ConfigurationConstants.PROP_KEEP_JOBS, true);
props.put(ConfigurationConstants.PROP_PRIORITY, "MAX");
config.update(props);
}
} catch (IOException e) {
throw new RuntimeException("could not create config for queue " + queueName, e);
}
DistributionQueue queue = new JobHandlingDistributionQueue(queueName, topic, jobManager, isActive, type);
queue = new CachingDistributionQueue(topic, queue);
return queue;
}
Aggregations