class AbstractAMQPProcessor extends AbstractProcessor {

    @Override
    public final void onTrigger(final ProcessContext context, final ProcessSession session) throws ProcessException {
        AMQPResource<T> resource = resourceQueue.poll();
        if (resource == null) {
            resource = createResource(context);
        }

        try {
            processResource(resource.getConnection(), resource.getWorker(), context, session);
            resourceQueue.offer(resource);
        } catch (final Exception e) {
            try {
                resource.close();
            } catch (final Exception e2) {
                e.addSuppressed(e2);
            }

            throw e;
        }
    }

}