Code example for BlockingQueue

Methods: offer

0
        if (SEDAQueueProducerPolicy.ADD.equals(action)) {
            queue.add(messageContext);
        } else if (SEDAQueueProducerPolicy.OFFER.equals(action)) {
            long timeout = queueProducerPolicy.getTimeoutOnInsert();
            if (timeout < 0) {
                if (!queue.offer(messageContext)) {
                    log.warn("Error while offering the message to the queue");    
                } 
            } else { 
                try { 
                    queue.offer(messageContext, timeout, TimeUnit.MILLISECONDS);
                } catch (InterruptedException e) {
                    log.debug("Ignored InterruptedException when ocuured calling queue.offer");
                } 
            } 
        } else if (SEDAQueueProducerPolicy.PUT.equals(action)) {
            try { 
                queue.put(messageContext);
            } catch (InterruptedException e) {
                log.debug("Ignored InterruptedException when ocuured calling queue.put");
            }