class AMQPProducerProcessor extends Processor {

    protected final Logger logger = Logger.getLogger(getClass().getName());

    {
        setAmqpUri("amqp://guest:guest@localhost:5672/%2f");
    }
    public String getAmqpUri() {
        return (String) kp.get("amqpUri");
    }
    public void setAmqpUri(String uri) {
        kp.put("amqpUri", uri);
    }

    public String getExchange() {
        return (String) kp.get("exchange");
    }
    public void setExchange(String exchange) {
        kp.put("exchange", exchange);
    }

    public String getRoutingKey() {
        return (String) kp.get("routingKey");
    }
    public void setRoutingKey(String routingKey) {
        kp.put("routingKey", routingKey);
    }

    transient protected AMQPProducer amqpProducer;

    protected AMQPProducer amqpProducer() {<FILL_FUNCTION_BODY>}

    @Override
    synchronized public void stop() {
        if (!isRunning) {
            return;
        }

        super.stop();

        if (amqpProducer != null) {
            amqpProducer.stop();
        }
    }

    @Override
    protected ProcessResult innerProcessResult(CrawlURI curi)
            throws InterruptedException {
        byte[] message = null;
        BasicProperties props = null;

        message = buildMessage(curi);
        props = amqpMessageProperties();
        try {
            amqpProducer().publishMessage(message, props);
            success(curi, message, props);
        } catch (IOException e) {
            fail(curi, message, props, e);
        }

        return ProcessResult.PROCEED;
    }

    protected BasicProperties amqpMessageProperties() {
        return null;
    }

    @Override
    protected void innerProcess(CrawlURI uri) throws InterruptedException {
        throw new RuntimeException("should never be called");
    }

    abstract protected byte[] buildMessage(CrawlURI curi);

    protected void success(CrawlURI curi, byte[] message, BasicProperties props) {
        if (logger.isLoggable(Level.FINE)) {
            try {
                logger.fine("sent to amqp exchange=" + getExchange()
                        + " routingKey=" + getRoutingKey() + ": " + new String(message, "UTF-8"));
            } catch (UnsupportedEncodingException e) {
                logger.fine("sent to amqp exchange=" + getExchange()
                        + " routingKey=" + getRoutingKey() + ": " + message + " (" + message.length + " bytes)");
            }
        }
    }

    protected void fail(CrawlURI curi, byte[] message, BasicProperties props, Throwable e) {
        logger.log(Level.SEVERE, "failed to send message to amqp for URI " + curi, e);
    }
}

        if (amqpProducer == null) {
            amqpProducer = new AMQPProducer(getAmqpUri(), getExchange(), getRoutingKey());
        }
        return amqpProducer;
    
<methods>public non-sealed void <init>() ,public void doCheckpoint(org.archive.checkpointing.Checkpoint) throws java.io.IOException,public void finishCheckpoint(org.archive.checkpointing.Checkpoint) ,public static java.lang.String flattenVia(org.archive.modules.CrawlURI) ,public java.lang.String getBeanName() ,public boolean getEnabled() ,public org.archive.spring.KeyedProperties getKeyedProperties() ,public static long getRecordedSize(org.archive.modules.CrawlURI) ,public org.archive.modules.deciderules.DecideRule getShouldProcessRule() ,public long getURICount() ,public static boolean hasHttpAuthenticationCredential(org.archive.modules.CrawlURI) ,public boolean isRunning() ,public static boolean isSuccess(org.archive.modules.CrawlURI) ,public org.archive.modules.ProcessResult process(org.archive.modules.CrawlURI) throws java.lang.InterruptedException,public java.lang.String report() ,public void setBeanName(java.lang.String) ,public void setEnabled(boolean) ,public void setRecoveryCheckpoint(org.archive.checkpointing.Checkpoint) ,public void setShouldProcessRule(org.archive.modules.deciderules.DecideRule) ,public void start() ,public void startCheckpoint(org.archive.checkpointing.Checkpoint) ,public void stop() <variables>protected java.lang.String beanName,protected boolean isRunning,protected org.archive.spring.KeyedProperties kp,protected org.archive.checkpointing.Checkpoint recoveryCheckpoint,protected java.util.concurrent.atomic.AtomicLong uriCount