class RabbitProducer {
    private RabbitConfig config;
    private Channel channel;
    private AMQP.BasicProperties eventPropsDefault;

    public RabbitProducer(RabbitConfig config, Channel channel) {
        this.config = config;
        this.channel = channel;
        this.eventPropsDefault = newEventProps().build();
    }

    public AMQP.BasicProperties.Builder newEventProps() {
        return new AMQP.BasicProperties().builder()
                .deliveryMode(2)
                .contentEncoding("UTF-8")
                .contentType("application/json");
    }

    public boolean publish(Event event, String topic, long delay) throws Exception {
        byte[] event_data = ONode.stringify(event).getBytes(StandardCharsets.UTF_8);

        AMQP.BasicProperties props;
        if (delay > 0) {
            props = newEventProps().expiration(String.valueOf(delay)).build();
        } else {
            props = eventPropsDefault;
        }

        channel.basicPublish(config.exchangeName, topic, config.mandatory, props, event_data);

        if (config.publishTimeout > 0) {
            return channel.waitForConfirms(config.publishTimeout);
        } else {
            return true;
        }
    }

    /**
     * 发布事件
     */
    public boolean publish(Event event, String topic) throws Exception {<FILL_FUNCTION_BODY>}
}

        long delay = 0;
        if (event.scheduled() != null) {
            delay = event.scheduled().getTime() - System.currentTimeMillis();
        }

        if (delay > 0) {
            return publish(event, config.queue_ready, delay);
        } else {
            if (config.exchangeType == BuiltinExchangeType.FANOUT) {
                return publish(event, "", 0);
            } else {
                return publish(event, topic, 0);
            }
        }
    
<no_super_class>