echo 'Hallo Welt!' | http -v :8080/peter
echo peter | http -v :8080/
+http -v PUT :8080/peter
dd if=/dev/zero bs=1024 count=1024 | http -v :8080/fehler
http -v :8081/seen
props.put("value.serializer", JsonSerializer.class.getName());
props.put(JsonSerializer.TYPE_MAPPINGS,
"message:" + ClientMessage.class.getName() + "," +
+ "foo:" + FooMessage.class.getName() + "," +
"greeting:" + Greeting.class.getName());
this.producer = new KafkaProducer<>(props);
return send(record);
}
+ @PutMapping(path = "{key}")
+ public DeferredResult<ProduceResult> message(@PathVariable String key)
+ {
+ key = key.trim();
+ final ProducerRecord<String, Object> record = new ProducerRecord<>(
+ topic, // Topic
+ key, // Key
+ new FooMessage(key, System.currentTimeMillis()) // Value
+ );
+
+ return send(record);
+ }
+
@PostMapping(path = "/")
public DeferredResult<ProduceResult> greeting(
@RequestBody String name)
.until(() -> consumer.received.size() == 1);
}
+ @Test
+ void testSendFooMessage() throws Exception
+ {
+ mockMvc
+ .perform(put("/peter"))
+ .andExpect(status().isOk());
+ await("Message was send")
+ .atMost(Duration.ofSeconds(5))
+ .until(() -> consumer.received.size() == 1);
+ }
+
@Test
void testSendGreeting() throws Exception
{