@MotechListener(subjects = FormSubmissionEvent.SUBJECT)
 public void submitForms(MotechEvent event) {
   List<FormSubmissionDTO> formSubmissions =
       new Gson()
           .fromJson(
               (String) event.getParameters().get("data"),
               new TypeToken<List<FormSubmissionDTO>>() {}.getType());
   logger.info("Submitting Forms");
   formSubmissionService.submit(formSubmissions);
 }
  @MotechListener(subjects = DrishtiFormScheduler.SUBJECT)
  public void fetchForms(MotechEvent event) {
    if (!lock.tryLock()) {
      logger.warn("Not fetching forms from Message Queue. It is already in progress.");
      return;
    }
    try {
      logger.info("Fetching Forms");
      long version = getVersion();

      List<FormSubmissionDTO> formSubmissionDTOs = formSubmissionService.fetch(version);
      if (formSubmissionDTOs.isEmpty()) {
        logger.info("No new forms found. Export token: " + version);
        return;
      }

      logger.info(
          format(
              "Fetched {0} new forms found. Export token: {1}",
              formSubmissionDTOs.size(), version));
      List<FormSubmission> formSubmissions =
          with(formSubmissionDTOs)
              .convert(
                  new Converter<FormSubmissionDTO, FormSubmission>() {
                    @Override
                    public FormSubmission convert(FormSubmissionDTO submission) {
                      return FormSubmissionConverter.toFormSubmissionWithVersion(submission);
                    }
                  });
      formEntityService.process(formSubmissions);
    } catch (Exception e) {
      logger.error(
          MessageFormat.format(
              "{0} occurred while trying to fetch forms. Message: {1} with stack trace {2}",
              e.toString(), e.getMessage(), getFullStackTrace(e)));
    } finally {
      lock.unlock();
    }
  }