// "application/logplex-1" does not conform to RFC5424.
// It leaves out STRUCTURED-DATA but does not replace it with
// a NILVALUE. To workaround this, we inject empty STRUCTURED-DATA.
@RequestMapping(value = "/logs", method = RequestMethod.POST)
  @ResponseBody
  public String logs(@RequestBody String body) throws IOException {
    // "application/logplex-1" does not conform to RFC5424.
    // It leaves out STRUCTURED-DATA but does not replace it with
    // a NILVALUE. To workaround this, we inject empty STRUCTURED-DATA.
    String[] parts = body.split("router - ");
    String log = parts[0] + "router - [] " + (parts.length > 1 ? parts[1] : "");
    RFC6587SyslogDeserializer parser = new RFC6587SyslogDeserializer();
    InputStream is = new ByteArrayInputStream(log.getBytes());
    Map<String, ?> messages = parser.deserialize(is);
    ObjectMapper mapper = new ObjectMapper();
    MessageChannel toKafka = context.getBean("toKafka", MessageChannel.class);
    String json = mapper.writeValueAsString(messages);
    toKafka.send(new GenericMessage<>(json));
    return "ok";
  }
@ResponseBody
public String logs(@RequestBody String body) throws IOException {
// "application/logplex-1" does not conform to RFC5424.
// It leaves out STRUCTURED-DATA but does not replace it with
// a NILVALUE. To workaround this, we inject empty STRUCTURED-DATA.
String[] parts = body.split("router - ");
String log = parts[0] + "router - [] " + (parts.length > 1 ? parts[1] : "");
@RequestMapping(value = "/logs", method = RequestMethod.POST)
@ResponseBody
public String logs(@RequestBody String body) throws IOException {
// "application/logplex-1" does not conform to RFC5424.
// It leaves out STRUCTURED-DATA but does not replace it with
// a NILVALUE. To workaround this, we inject empty STRUCTURED-DATA.
String[] parts = body.split("router - ");
String log = parts[0] + "router - [] " + (parts.length > 1 ? parts[1] : "");
RFC6587SyslogDeserializer parser = new RFC6587SyslogDeserializer();
InputStream is = new ByteArrayInputStream(log.getBytes());
Map<String, ?> messages = parser.deserialize(is);
ObjectMapper mapper = new ObjectMapper();
MessageChannel toKafka = context.getBean("toKafka", MessageChannel.class);
String json = mapper.writeValueAsString(messages);
toKafka.send(new GenericMessage<>(json));
return "ok";
@RequestMapping(value = "/logs", method = RequestMethod.POST)
@ResponseBody
public String logs(@RequestBody String body) throws IOException {
// "application/logplex-1" does not conform to RFC5424.
// It leaves out STRUCTURED-DATA but does not replace it with
// a NILVALUE. To workaround this, we inject empty STRUCTURED-DATA.
String[] parts = body.split("router - ");
String log = parts[0] + "router - [] " + (parts.length > 1 ? parts[1] : "");
RFC6587SyslogDeserializer parser = new RFC6587SyslogDeserializer();
InputStream is = new ByteArrayInputStream(log.getBytes());
Map<String, ?> messages = parser.deserialize(is);
ObjectMapper mapper = new ObjectMapper();
MessageChannel toKafka = context.getBean("toKafka", MessageChannel.class);
String json = mapper.writeValueAsString(messages);
toKafka.send(new GenericMessage<>(json));
return "ok";
}