class GridTransactionalCacheQueueImpl<T> extends GridCacheQueueAdapter<T> {
    /**
     * @param queueName Queue name.
     * @param hdr Queue header.
     * @param cctx Cache context.
     */
    public GridTransactionalCacheQueueImpl(String queueName, GridCacheQueueHeader hdr, GridCacheContext<?, ?> cctx) {
        super(queueName, hdr, cctx);
    }

    /** {@inheritDoc} */
    @SuppressWarnings("unchecked")
    @Override public boolean offer(final T item) throws IgniteException {
        A.notNull(item, "item");

        try {
            return retryTopologySafe(new Callable<Boolean>() {
                @Override public Boolean call() throws Exception {<FILL_FUNCTION_BODY>}
            });
        }
        catch (IgniteCheckedException e) {
            throw U.convertException(e);
        }
        catch (RuntimeException e) {
            throw e;
        }
        catch (Exception e) {
            throw new IgniteException(e.getMessage(), e);
        }
    }

    /** {@inheritDoc} */
    @SuppressWarnings("unchecked")
    @Nullable @Override public T poll() throws IgniteException {
        try {
            return retryTopologySafe(new Callable<T>() {
                @Override public T call() throws Exception {
                    T retVal;

                    while (true) {
                        try (GridNearTxLocal tx = cache.txStartEx(PESSIMISTIC, REPEATABLE_READ)) {
                            Long idx = (Long)cache.invoke(queueKey, new PollProcessor(id)).get();

                            if (idx != null) {
                                checkRemoved(idx);

                                retVal = (T)cache.getAndRemove(itemKey(idx));

                                if (retVal == null) { // Possible if data was lost.
                                    tx.commit();

                                    continue;
                                }
                            }
                            else
                                retVal = null;

                            tx.commit();

                            return retVal;
                        }
                    }
                }
            });
        }
        catch (IgniteCheckedException e) {
            throw U.convertException(e);
        }
        catch (RuntimeException e) {
            throw e;
        }
        catch (Exception e) {
            throw new IgniteException(e.getMessage(), e);
        }
    }

    /** {@inheritDoc} */
    @SuppressWarnings("unchecked")
    @Override public boolean addAll(final Collection<? extends T> items) {
        A.notNull(items, "items");

        try {
            return retryTopologySafe(new Callable<Boolean>() {
                @Override public Boolean call() throws Exception {
                    boolean retVal;

                    try (GridNearTxLocal tx = cache.txStartEx(PESSIMISTIC, REPEATABLE_READ)) {
                        Long idx = (Long)cache.invoke(queueKey, new AddProcessor(id, items.size())).get();

                        if (idx != null) {
                            checkRemoved(idx);

                            Map<QueueItemKey, T> putMap = new HashMap<>();

                            for (T item : items) {
                                putMap.put(itemKey(idx), item);

                                idx++;
                            }

                            cache.putAll(putMap);

                            retVal = true;
                        }
                        else
                            retVal = false;

                        tx.commit();

                        return retVal;
                    }
                }
            });
        }
        catch (IgniteCheckedException e) {
            throw U.convertException(e);
        }
        catch (RuntimeException e) {
            throw e;
        }
        catch (Exception e) {
            throw new IgniteException(e.getMessage(), e);
        }
    }

    /** {@inheritDoc} */
    @SuppressWarnings("unchecked")
    @Override protected void removeItem(final long rmvIdx) throws IgniteCheckedException {
        try {
            retryTopologySafe(new Callable<Object>() {
                @Override public Object call() throws Exception {
                    try (GridNearTxLocal tx = cache.txStartEx(PESSIMISTIC, REPEATABLE_READ)) {
                        Long idx = (Long)cache.invoke(queueKey, new RemoveProcessor(id, rmvIdx)).get();

                        if (idx != null) {
                            checkRemoved(idx);

                            cache.remove(itemKey(idx));
                        }

                        tx.commit();
                    }

                    return null;
                }
            });
        }
        catch (RuntimeException e) {
            throw e;
        }
        catch (Exception e) {
            throw new IgniteCheckedException(e);
        }
    }
}

                    boolean retVal;

                    try (GridNearTxLocal tx = cache.txStartEx(PESSIMISTIC, REPEATABLE_READ)) {
                        Long idx = (Long)cache.invoke(queueKey, new AddProcessor(id, 1)).get();

                        if (idx != null) {
                            checkRemoved(idx);

                            cache.getAndPut(itemKey(idx), item);

                            retVal = true;
                        }
                        else
                            retVal = false;

                        tx.commit();

                        return retVal;
                    }
                
<methods>public boolean add(T) ,public R affinityCall(IgniteCallable<R>) ,public void affinityRun(org.apache.ignite.lang.IgniteRunnable) ,public boolean bounded() ,public int capacity() ,public void clear() ,public void clear(int) throws org.apache.ignite.IgniteException,public void close() ,public boolean collocated() ,public int drainTo(Collection<? super T>) ,public int drainTo(Collection<? super T>, int) ,public T element() ,public boolean equals(java.lang.Object) ,public int hashCode() ,public org.apache.ignite.lang.IgniteUuid id() ,public Iterator<T> iterator() ,public java.lang.String name() ,public boolean offer(T, long, java.util.concurrent.TimeUnit) throws org.apache.ignite.IgniteException,public void onClientDisconnected() ,public void onHeaderChanged(org.apache.ignite.internal.processors.datastructures.GridCacheQueueHeader) ,public void onKernalStop() ,public void onRemoved(boolean) ,public T peek() throws org.apache.ignite.IgniteException,public T poll(long, java.util.concurrent.TimeUnit) throws org.apache.ignite.IgniteException,public void put(T) throws org.apache.ignite.IgniteException,public int remainingCapacity() ,public T remove() ,public boolean removed() ,public int size() ,public T take() throws org.apache.ignite.IgniteException,public java.lang.String toString() ,public IgniteQueue<V1> withKeepBinary() <variables>private static final int DFLT_CLEAR_BATCH_SIZE,protected static final long QUEUE_REMOVED_IDX,protected final non-sealed GridCacheAdapter#RAW cache,private final non-sealed int cap,protected final non-sealed GridCacheContext<?,?> cctx,private final non-sealed boolean collocated,private final non-sealed org.apache.ignite.IgniteCompute compute,protected final non-sealed org.apache.ignite.lang.IgniteUuid id,protected final non-sealed org.apache.ignite.IgniteLogger log,protected final non-sealed org.apache.ignite.internal.processors.datastructures.GridCacheQueueHeaderKey queueKey,protected final non-sealed java.lang.String queueName,private final non-sealed java.util.concurrent.Semaphore readSem,private volatile boolean rmvd,private final non-sealed java.util.concurrent.Semaphore writeSem