// Path: src/main/java/com/hubrick/vertx/kafka/producer/model/ByteKafkaMessage.java
// @DataObject(generateConverter = true)
// public class ByteKafkaMessage extends AbstractKafkaMessage {
// 
//     private Buffer payload;
// 
//     public ByteKafkaMessage() {
//     }
// 
//     public ByteKafkaMessage(Buffer payload) {
//         checkNotNull(payload, "payload must not be null");
// 
//         this.payload = payload;
//     }
// 
//     public ByteKafkaMessage(Buffer payload, String partKey) {
//         super(partKey);
//         checkNotNull(payload, "payload must not be null");
// 
//         this.payload = payload;
//     }
// 
//     public ByteKafkaMessage(ByteKafkaMessage byteKafkaMessage) {
//         super(byteKafkaMessage.getPartKey());
//         checkNotNull(payload, "payload must not be null");
// 
//         this.payload = byteKafkaMessage.getPayload();
//     }
// 
//     public ByteKafkaMessage(JsonObject jsonObject) {
//         super(jsonObject.getString(PART_KEY));
//         this.payload = jsonObject.getBinary(PAYLOAD) != null ? Buffer.buffer(jsonObject.getBinary(PAYLOAD)) : null;
//     }
// 
//     public Buffer getPayload() {
//         return payload;
//     }
// 
//     public void setPayload(Buffer payload) {
//         this.payload = payload;
//     }
// 
//     public JsonObject toJson() {
//         final JsonObject jsonObject = super.asJson();
//         if (getPayload() != null) {
//             jsonObject.put(PAYLOAD, payload != null ? payload.getBytes() : null);
//         }
//         return jsonObject;
//     }
// }
// 
// Path: src/main/java/com/hubrick/vertx/kafka/producer/property/KafkaProducerProperties.java
// public final class KafkaProducerProperties {
// 
//     /* Non-instantiable class */
//     private KafkaProducerProperties() {}
// 
//     public static final String ADDRESS = "address";
//     public static final String BOOTSTRAP_SERVERS = "bootstrapServers";
//     public static final String ACKS = "acks";
//     public static final String DEFAULT_TOPIC = "defaultTopic";
//     public static final String TYPE = "type";
//     public static final String MAX_RETRIES = "maxRetries";
//     public static final String RETRY_BACKOFF_MS = "retryBackoffMs";
//     public static final String BUFFERING_MAX_MS = "bufferingMaxMs";
//     public static final String BUFFERING_MAX_MESSAGES = "bufferingMaxMessages";
//     public static final String ENQUEUE_TIMEOUT = "enqueueTimeout";
//     public static final String BATCH_MESSAGE_NUM = "batchMessageNum";
//     public static final String RETRIES = "retries";
//     public static final String REQUEST_TIMEOUT_MS = "requestTimeoutMs";
//     public static final String MAX_BLOCK_MS = "maxBlockMs";
//     public static final String STATSD = "statsD";
//     public static final String METRIC_CONSUMER_CLASSES = "metricConsumerClasses";
//     public static final String METRIC_DROPWIZARD_REGISTRY_NAME = "metricDropwizardRegistryName";
// 
//     public static final String BOOTSTRAP_SERVERS_DEFAULT = "localhost:9092";
//     public static final String ACKS_DEFAULT = "1";
// 
//     public static final int RETRIES_DEFAULT = 0;
//     public static final int REQUEST_TIMEOUT_MS_DEFAULT = 30000;
//     public static final int MAX_BLOCK_MS_DEFAULT = 60000;
// 
// }


import com.hubrick.vertx.kafka.producer.model.ByteKafkaMessage;
import com.hubrick.vertx.kafka.producer.property.KafkaProducerProperties;
import io.vertx.core.DeploymentOptions;
import io.vertx.core.Vertx;
import io.vertx.core.buffer.Buffer;
import io.vertx.core.json.JsonObject;
/**
 * Copyright (C) 2016 Etaia AS (oss@hubrick.com)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.hubrick.vertx.kafka.producer;


/**
 * @author Emir Dizdarevic
 * @since 1.0.0
 */
public class ManualTest {

    public static void main(String[] args) {
        JsonObject config = new JsonObject();
        config.put(KafkaProducerProperties.ADDRESS, "test-address");
        config.put(KafkaProducerProperties.BOOTSTRAP_SERVERS, KafkaProducerProperties.BOOTSTRAP_SERVERS_DEFAULT);
        config.put(KafkaProducerProperties.DEFAULT_TOPIC, "test-topic");
        config.put(KafkaProducerProperties.ACKS, KafkaProducerProperties.ACKS_DEFAULT);

        final Vertx vertx = Vertx.vertx();
        final DeploymentOptions deploymentOptions = new DeploymentOptions();
        deploymentOptions.setConfig(config);
        vertx.deployVerticle("service:com.hubrick.services.kafka-producer", deploymentOptions, result -> {
            System.out.println(result.result());

            JsonObject jsonObject = new JsonObject();
            jsonObject.put("payload", "your message goes here".getBytes());

            final KafkaProducerService kafkaProducerService = KafkaProducerService.createProxy(vertx, "test-address");
// Path: src/main/java/com/hubrick/vertx/kafka/producer/model/ByteKafkaMessage.java
// @DataObject(generateConverter = true)
// public class ByteKafkaMessage extends AbstractKafkaMessage {
// 
//     private Buffer payload;
// 
//     public ByteKafkaMessage() {
//     }
// 
//     public ByteKafkaMessage(Buffer payload) {
//         checkNotNull(payload, "payload must not be null");
// 
//         this.payload = payload;
//     }
// 
//     public ByteKafkaMessage(Buffer payload, String partKey) {
//         super(partKey);
//         checkNotNull(payload, "payload must not be null");
// 
//         this.payload = payload;
//     }
// 
//     public ByteKafkaMessage(ByteKafkaMessage byteKafkaMessage) {
//         super(byteKafkaMessage.getPartKey());
//         checkNotNull(payload, "payload must not be null");
// 
//         this.payload = byteKafkaMessage.getPayload();
//     }
// 
//     public ByteKafkaMessage(JsonObject jsonObject) {
//         super(jsonObject.getString(PART_KEY));
//         this.payload = jsonObject.getBinary(PAYLOAD) != null ? Buffer.buffer(jsonObject.getBinary(PAYLOAD)) : null;
//     }
// 
//     public Buffer getPayload() {
//         return payload;
//     }
// 
//     public void setPayload(Buffer payload) {
//         this.payload = payload;
//     }
// 
//     public JsonObject toJson() {
//         final JsonObject jsonObject = super.asJson();
//         if (getPayload() != null) {
//             jsonObject.put(PAYLOAD, payload != null ? payload.getBytes() : null);
//         }
//         return jsonObject;
//     }
// }
// 
// Path: src/main/java/com/hubrick/vertx/kafka/producer/property/KafkaProducerProperties.java
// public final class KafkaProducerProperties {
// 
//     /* Non-instantiable class */
//     private KafkaProducerProperties() {}
// 
//     public static final String ADDRESS = "address";
//     public static final String BOOTSTRAP_SERVERS = "bootstrapServers";
//     public static final String ACKS = "acks";
//     public static final String DEFAULT_TOPIC = "defaultTopic";
//     public static final String TYPE = "type";
//     public static final String MAX_RETRIES = "maxRetries";
//     public static final String RETRY_BACKOFF_MS = "retryBackoffMs";
//     public static final String BUFFERING_MAX_MS = "bufferingMaxMs";
//     public static final String BUFFERING_MAX_MESSAGES = "bufferingMaxMessages";
//     public static final String ENQUEUE_TIMEOUT = "enqueueTimeout";
//     public static final String BATCH_MESSAGE_NUM = "batchMessageNum";
//     public static final String RETRIES = "retries";
//     public static final String REQUEST_TIMEOUT_MS = "requestTimeoutMs";
//     public static final String MAX_BLOCK_MS = "maxBlockMs";
//     public static final String STATSD = "statsD";
//     public static final String METRIC_CONSUMER_CLASSES = "metricConsumerClasses";
//     public static final String METRIC_DROPWIZARD_REGISTRY_NAME = "metricDropwizardRegistryName";
// 
//     public static final String BOOTSTRAP_SERVERS_DEFAULT = "localhost:9092";
//     public static final String ACKS_DEFAULT = "1";
// 
//     public static final int RETRIES_DEFAULT = 0;
//     public static final int REQUEST_TIMEOUT_MS_DEFAULT = 30000;
//     public static final int MAX_BLOCK_MS_DEFAULT = 60000;
// 
// }


// Path: src/test/java/com/hubrick/vertx/kafka/producer/ManualTest.java
import com.hubrick.vertx.kafka.producer.model.ByteKafkaMessage;
import com.hubrick.vertx.kafka.producer.property.KafkaProducerProperties;
import io.vertx.core.DeploymentOptions;
import io.vertx.core.Vertx;
import io.vertx.core.buffer.Buffer;
import io.vertx.core.json.JsonObject;

/**
 * Copyright (C) 2016 Etaia AS (oss@hubrick.com)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.hubrick.vertx.kafka.producer;


/**
 * @author Emir Dizdarevic
 * @since 1.0.0
 */
public class ManualTest {

    public static void main(String[] args) {
        JsonObject config = new JsonObject();
        config.put(KafkaProducerProperties.ADDRESS, "test-address");
        config.put(KafkaProducerProperties.BOOTSTRAP_SERVERS, KafkaProducerProperties.BOOTSTRAP_SERVERS_DEFAULT);
        config.put(KafkaProducerProperties.DEFAULT_TOPIC, "test-topic");
        config.put(KafkaProducerProperties.ACKS, KafkaProducerProperties.ACKS_DEFAULT);

        final Vertx vertx = Vertx.vertx();
        final DeploymentOptions deploymentOptions = new DeploymentOptions();
        deploymentOptions.setConfig(config);
        vertx.deployVerticle("service:com.hubrick.services.kafka-producer", deploymentOptions, result -> {
            System.out.println(result.result());

            JsonObject jsonObject = new JsonObject();
            jsonObject.put("payload", "your message goes here".getBytes());

            final KafkaProducerService kafkaProducerService = KafkaProducerService.createProxy(vertx, "test-address");
            kafkaProducerService.sendBytes(new ByteKafkaMessage(Buffer.buffer("your message goes here".getBytes()), "test-partition"), response -> {