July 2018
Intermediate to advanced
336 pages
9h 23m
English
The Image Resize Request Consumer is responsible for listening for messages coming from Apache Kafka topic and doing the actual resizing of the images. Consider the following code:
@SpringBootApplicationpublic class SpringBootAsyncConsumerApplication { ... @KafkaListener(id="server", topics = "asyncRequests") @SendTo public String listen(String input) { try { ImageResizeRequest imageResizeRequest = objectMapper().readValue(input, ImageResizeRequest.class); File imageFile = new File(imageResizeRequest.getInputFile()); String[] nameParts = imageFile.getName().split("\\."); BufferedImage image = ImageIO.read(imageFile); ImageIO.write(resize(image, imageResizeRequest.getWidth(), imageResizeRequest.getHeight()) ...
Read now
Unlock full access