/** @param args the command line arguments 1) kafka broker */
  public static void main(String[] args) {
    Properties props = new Properties();
    if (args.length >= 1) {
      props.put("metadata.broker.list", args[0]);
    } else {
      props.put("metadata.broker.list", "192.168.47.129:9093");
    }
    props.put("serializer.class", "eu.europeana.cloud.service.dps.storm.kafka.JsonEncoder");
    props.put("request.required.acks", "1");

    ProducerConfig config = new ProducerConfig(props);
    Producer<String, DpsTask> producer = new Producer<>(config);

    DpsTask msg = new DpsTask();

    msg.setTaskName(PluginParameterKeys.NEW_ANNOTATION_MESSAGE);

    msg.addParameter(PluginParameterKeys.INDEX_DATA, "True");
    IndexerInformations ii =
        new IndexerInformations(indexers[0], "index_mlt_4", "mlt4", "192.168.47.129:9300");
    msg.addParameter(PluginParameterKeys.INDEXER, ii.toTaskString());
    msg.addParameter(PluginParameterKeys.FILE_URL, "url to annotation");

    KeyedMessage<String, DpsTask> data =
        new KeyedMessage<>(IndexerConstants.KAFKA_INPUT_TOPIC, msg);
    producer.send(data);
    producer.close();
  }
  private String buildTaskUrl(UriInfo uriInfo, DpsTask task, String topologyName) {

    StringBuilder taskUrl =
        new StringBuilder()
            .append(uriInfo.getBaseUri().toString())
            .append("topologies/")
            .append(topologyName)
            .append("/tasks/")
            .append(task.getTaskId());

    return taskUrl.toString();
  }
  /**
   * Submits a Task for execution. Each Task execution is associated with a specific plugin.
   *
   * <p><strong>Write permissions required</strong>.
   *
   * @summary Submit Task
   * @param task <strong>REQUIRED</strong> Task to be executed. Should contain links to input data,
   *     either in form of cloud-records or cloud-datasets.
   * @param topologyName <strong>REQUIRED</strong> Name of the topology where the task is submitted.
   * @return URI with information about the submitted task execution.
   */
  @POST
  @Consumes({MediaType.APPLICATION_JSON})
  @PreAuthorize("hasPermission(#topologyName,'" + TOPOLOGY_PREFIX + "', write)")
  @Path("/")
  public Response submitTask(
      DpsTask task, @PathParam("topologyName") String topologyName, @Context UriInfo uriInfo) {

    LOGGER.info("Submiting task");

    if (task != null) {
      submitService.submitTask(task, topologyName);
      grantPermissionsForTask(task.getTaskId() + "");
      String createdTaskUrl = buildTaskUrl(uriInfo, task, topologyName);
      try {
        LOGGER.info("Task submitted succesfully");
        return Response.created(new URI(createdTaskUrl)).build();
      } catch (URISyntaxException e) {
        LOGGER.error("Task submition failed");
        e.printStackTrace();
        return Response.serverError().build();
      }
    }
    return Response.notModified().build();
  }