Package edu.emory.mathcs.backport.java.util.concurrent

Examples of edu.emory.mathcs.backport.java.util.concurrent.BlockingQueue


   }
  
   public void sendEmailAsync(EmailData emailData) throws XmlBlasterException {
      if (emailData == null) throw new IllegalArgumentException("SmtpClient.sendEmailAsync(): Missing argument emailData");
      AsyncSender as = this.asyncSender;
      BlockingQueue queue = this.asyncSendQueue;
      if (as == null || queue == null) {
         throw new XmlBlasterException(glob,
               ErrorCode.RESOURCE_CONFIGURATION_ADDRESS, "SmtpClient",
               "Please configure asyncSendQueueSizeMax > 0 for sending emails asynchronously, the mail is lost: " + emailData.toXml(true));
      }
      try {
         if (this.asyncSendQueueBlockOnOverflow)
            queue.put(emailData);
         else {
            boolean added = queue.offer(emailData);
            if (!added) {
               throw new XmlBlasterException(glob,
                     ErrorCode.RESOURCE_CONFIGURATION_CONNECT, "SmtpClient",
                     "Can't send email, queueu overflow of asyncSendQueueSizeMax="+this.asyncSendQueueSizeMax+", there may be a problem with your Smtp server, the mail is lost: " + emailData.toXml(true));
            }
View Full Code Here


            worker = getWorker(session);
        }
        if (Thread.currentThread() == worker) {
            dispatcher.dispatch(session, event);
        } else {
            BlockingQueue queue = worker.queue;
            if (!queue.offer(event)) {
                // flow control
                if (elapsedTime.getElapsedTime() >= 10000) {
                    elapsedTime.reset();
                    log.warn("dispatcher flow control");
                }
                try {
                    queue.put(event);
                } catch (InterruptedException e) {
                }
            }
        }
    }
View Full Code Here

      logger.info("Initializing ThreadPoolExecutor" + (this.beanName != null ? " '" + this.beanName + "'" : ""));
    }
    if (!this.threadNamePrefixSet && this.beanName != null) {
      setThreadNamePrefix(this.beanName + "-");
    }
    BlockingQueue queue = createQueue(this.queueCapacity);
    this.threadPoolExecutor = new ThreadPoolExecutor(
        this.corePoolSize, this.maxPoolSize, this.keepAliveSeconds, TimeUnit.SECONDS,
        queue, this.threadFactory, this.rejectedExecutionHandler);
    if (this.allowCoreThreadTimeOut) {
      this.threadPoolExecutor.allowCoreThreadTimeOut(true);
View Full Code Here

   */
  public void initialize() {
    if (logger.isInfoEnabled()) {
      logger.info("Initializing ThreadPoolExecutor" + (this.beanName != null ? " '" + this.beanName + "'" : ""));
    }
    BlockingQueue queue = createQueue(this.queueCapacity);
    this.threadPoolExecutor = new ThreadPoolExecutor(
        this.corePoolSize, this.maxPoolSize, this.keepAliveSeconds, TimeUnit.SECONDS,
        queue, this.threadFactory, this.rejectedExecutionHandler);
  }
View Full Code Here

        this.rejectedExecutionHandler = (rejectedExecutionHandler != null ? rejectedExecutionHandler
                : new ThreadPoolExecutor.AbortPolicy());
    }

    protected Object createInstance() throws Exception {
        BlockingQueue queue = null;
        if (queueCapacity > 0) {
            queue = new LinkedBlockingQueue(queueCapacity);
        } else {
            queue = new SynchronousQueue();
        }
View Full Code Here

                : new ThreadPoolExecutor.AbortPolicy() );
    }
   
    protected Object createInstance() throws Exception
    {
        BlockingQueue queue = null;
        if( queueCapacity > 0 )
        {
            queue = new LinkedBlockingQueue( queueCapacity );
        }
        else
View Full Code Here

      logger.info("Initializing ThreadPoolExecutor" + (this.beanName != null ? " '" + this.beanName + "'" : ""));
    }
    if (!this.threadNamePrefixSet && this.beanName != null) {
      setThreadNamePrefix(this.beanName + "-");
    }
    BlockingQueue queue = createQueue(this.queueCapacity);
    this.threadPoolExecutor = new ThreadPoolExecutor(
        this.corePoolSize, this.maxPoolSize, this.keepAliveSeconds, TimeUnit.SECONDS,
        queue, this.threadFactory, this.rejectedExecutionHandler);
    if (this.allowCoreThreadTimeOut) {
      this.threadPoolExecutor.allowCoreThreadTimeOut(true);
View Full Code Here

            }).start();
        }
    }

    public int capacity() {
        BlockingQueue queue = threadPool.getQueue();
        return queue.remainingCapacity() + queue.size();
    }
View Full Code Here

        BlockingQueue queue = threadPool.getQueue();
        return queue.remainingCapacity() + queue.size();
    }

    public int size() {
        BlockingQueue queue = threadPool.getQueue();
        return queue.size();
    }
View Full Code Here

   
    protected ThreadPoolExecutor createService(String id, ExecutorConfig config) {
        if (config.getQueueSize() != 0 && config.getCorePoolSize() == 0) {
            throw new IllegalArgumentException("CorePoolSize must be > 0 when using a capacity queue");
        }
        BlockingQueue queue;
        if (config.getQueueSize() == 0) {
            queue = new SynchronousQueue();
        } else if (config.getQueueSize() < 0 || config.getQueueSize() == Integer.MAX_VALUE) {
            queue = new LinkedBlockingQueue();
        } else {
View Full Code Here

TOP

Related Classes of edu.emory.mathcs.backport.java.util.concurrent.BlockingQueue

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.