Search in sources :

Example 1 with ExecutorNotStartedException

use of org.jbpm.executor.ExecutorNotStartedException in project jbpm by kiegroup.

the class ExecutorImpl method init.

/**
 * {@inheritDoc}
 */
public void init() {
    if (!"true".equalsIgnoreCase(System.getProperty("org.kie.executor.disabled"))) {
        logger.info("Starting jBPM Executor Component ...\n" + " \t - Thread Pool Size: {}" + "\n" + " \t - Retries per Request: {}\n" + " \t - Load from storage interval: {} {} (if less or equal 0 only initial sync with storage) \n", threadPoolSize, retries, interval, timeunit.toString());
        scheduler = getScheduledExecutorService();
        if (useJMS) {
            try {
                InitialContext ctx = new InitialContext();
                if (this.connectionFactory == null) {
                    this.connectionFactory = (ConnectionFactory) ctx.lookup(connectionFactoryName);
                }
                if (this.queue == null) {
                    this.queue = (Queue) ctx.lookup(queueName);
                }
                logger.info("Executor JMS based support successfully activated on queue {}", queue);
            } catch (Exception e) {
                logger.warn("Disabling JMS support in executor because: unable to initialize JMS configuration for executor due to {}", e.getMessage());
                logger.debug("JMS support executor failed due to {}", e.getMessage(), e);
                // since it cannot be initialized disable jms
                useJMS = false;
            }
        }
        LoadAndScheduleRequestsTask loadTask = new LoadAndScheduleRequestsTask(executorStoreService, scheduler, jobProcessor);
        if (interval <= 0) {
            scheduler.execute(loadTask);
        } else {
            logger.info("Interval ({}) is more than 0, scheduling periodic load of jobs from the storage", interval);
            loadTaskFuture = scheduler.scheduleAtFixedRate(loadTask, 0, interval, timeunit);
        }
    } else {
        throw new ExecutorNotStartedException();
    }
}
Also used : LoadAndScheduleRequestsTask(org.jbpm.executor.impl.concurrent.LoadAndScheduleRequestsTask) InitialContext(javax.naming.InitialContext) ExecutorNotStartedException(org.jbpm.executor.ExecutorNotStartedException) IOException(java.io.IOException) JMSException(javax.jms.JMSException) ExecutorNotStartedException(org.jbpm.executor.ExecutorNotStartedException)

Aggregations

IOException (java.io.IOException)1 JMSException (javax.jms.JMSException)1 InitialContext (javax.naming.InitialContext)1 ExecutorNotStartedException (org.jbpm.executor.ExecutorNotStartedException)1 LoadAndScheduleRequestsTask (org.jbpm.executor.impl.concurrent.LoadAndScheduleRequestsTask)1