/** {@inheritDoc} */ @Override public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) { try { this.waitInSeconds(1); // try once again executor.execute(r); } catch (InterruptedException e) { // Trace error System.err.println("Cannot send Audit Event"); } }
/** * Default constructor. */ public EventPublisher(int queueCapacity, int poolSize, EventRepository er, long submitTimeout) { // Initializing queue final BlockingQueue<Runnable> queue = new ArrayBlockingQueue<Runnable>(queueCapacity); // Executor with worker to process threads RejectedExecutionHandler rej = new EventRejectedExecutionHandler(); ThreadFactory tFactorty = new PublisherThreadFactory(); this.executor = new ThreadPoolExecutor(poolSize, poolSize, 0L, TimeUnit.MILLISECONDS, queue, tFactorty, rej); // Override repository this.repository = er; this.submitTimeout = submitTimeout; this.shutdownExecutor = true; }