Java Code Examples for org.springframework.cloud.stream.messaging.Sink

The following examples show how to use org.springframework.cloud.stream.messaging.Sink. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: flowing-retail   Source File: MessageListener.java    License: Apache License 2.0 6 votes vote down vote up
@StreamListener(target = Sink.INPUT, 
    condition="(headers['type']?:'')=='FetchGoodsCommand'")
@Transactional
public void retrievePaymentCommandReceived(String messageJson) throws JsonParseException, JsonMappingException, IOException {
  Message<FetchGoodsCommandPayload> message = objectMapper.readValue(messageJson, new TypeReference<Message<FetchGoodsCommandPayload>>(){});
  
  FetchGoodsCommandPayload fetchGoodsCommand = message.getData();    
  String pickId = inventoryService.pickItems( // 
      fetchGoodsCommand.getItems(), fetchGoodsCommand.getReason(), fetchGoodsCommand.getRefId());
  
  messageSender.send( //
      new Message<GoodsFetchedEventPayload>( //
          "GoodsFetchedEvent", //
          message.getTraceid(), //
          new GoodsFetchedEventPayload() //
            .setRefId(fetchGoodsCommand.getRefId())
            .setPickId(pickId))
      .setCorrelationid(message.getCorrelationid()));
}
 
Example 2
Source Project: service-block-samples   Source File: EventProcessor.java    License: Apache License 2.0 6 votes vote down vote up
@StreamListener(value = Sink.INPUT)
public void handle(Message<ProjectEvent> message) {
    ProjectEvent projectEvent = message.getPayload();
    log.info("Received new event: " + "{ projectId " + projectEvent.getProjectId() + " -> " +
            projectEvent.getType() + " }");

    if (projectEvent.getType() == ProjectEventType.CREATED_EVENT) {
        try {
            commitProcessor.importCommits(projectEvent);
        } catch (IOException e) {
            throw new RuntimeException("Could not import GitHub project", e);
        }
    }

    if (projectEvent.getType() == ProjectEventType.COMMIT_EVENT) {
        // Update query models
        LambdaResponse<Map<String, Object>> response =
                projectQueries.getTightCoupling().apply(projectEvent);
    }
}
 
Example 3
Source Project: flowing-retail   Source File: MessageListener.java    License: Apache License 2.0 6 votes vote down vote up
@StreamListener(target = Sink.INPUT, 
    condition="(headers['type']?:'')=='RetrievePaymentCommand'")
@Transactional
public void retrievePaymentCommandReceived(String messageJson) throws JsonParseException, JsonMappingException, IOException {
  Message<RetrievePaymentCommandPayload> message = objectMapper.readValue(messageJson, new TypeReference<Message<RetrievePaymentCommandPayload>>(){});
  RetrievePaymentCommandPayload retrievePaymentCommand = message.getData();    
  
  System.out.println("Retrieve payment: " + retrievePaymentCommand.getAmount() + " for " + retrievePaymentCommand.getRefId());
  
  messageSender.send( //
      new Message<PaymentReceivedEventPayload>( //
          "PaymentReceivedEvent", //
          message.getTraceid(), //
          new PaymentReceivedEventPayload() //
            .setRefId(retrievePaymentCommand.getRefId()))
      .setCorrelationid(message.getCorrelationid()));

}
 
Example 4
Source Project: flowing-retail   Source File: MessageListener.java    License: Apache License 2.0 6 votes vote down vote up
@StreamListener(target = Sink.INPUT, 
    condition="(headers['type']?:'')=='RetrievePaymentCommand'")
@Transactional
public void retrievePaymentCommandReceived(String messageJson) throws JsonParseException, JsonMappingException, IOException {
  Message<RetrievePaymentCommandPayload> message = objectMapper.readValue(messageJson, new TypeReference<Message<RetrievePaymentCommandPayload>>(){});
  RetrievePaymentCommandPayload retrievePaymentCommand = message.getData();    
  
  System.out.println("Retrieve payment: " + retrievePaymentCommand.getAmount() + " for " + retrievePaymentCommand.getRefId());
  
  camunda.getRuntimeService().createMessageCorrelation(message.getType()) //
    .processInstanceBusinessKey(message.getTraceid())
    .setVariable("amount", retrievePaymentCommand.getAmount()) //
    .setVariable("remainingAmount", retrievePaymentCommand.getAmount()) //
    .setVariable("refId", retrievePaymentCommand.getRefId()) //
    .setVariable("correlationId", message.getCorrelationid()) //
    .correlateWithResult();    
}
 
Example 5
Source Project: flowing-retail   Source File: MessageListener.java    License: Apache License 2.0 6 votes vote down vote up
@StreamListener(target = Sink.INPUT, 
    condition="(headers['type']?:'')=='ShipGoodsCommand'")
@Transactional
public void shipGoodsCommandReceived(String messageJson) throws Exception {
  Message<ShipGoodsCommandPayload> message = objectMapper.readValue(messageJson, new TypeReference<Message<ShipGoodsCommandPayload>>(){});

  String shipmentId = shippingService.createShipment( //
      message.getData().getPickId(), //
      message.getData().getRecipientName(), //
      message.getData().getRecipientAddress(), //
      message.getData().getLogisticsProvider());
      
  messageSender.send( //
      new Message<GoodsShippedEventPayload>( //
          "GoodsShippedEvent", //
          message.getTraceid(), //
          new GoodsShippedEventPayload() //
            .setRefId(message.getData().getRefId())
            .setShipmentId(shipmentId))
      .setCorrelationid(message.getCorrelationid()));
}
 
Example 6
/**
 * Log the change event received from the organization service and update 
 * the Redis cache.
 * 
 * @param  orgChange
 *         The organization change event.
 */
@StreamListener(Sink.INPUT)
public void loggerSink(OrganizationChangeModel orgChange) {
	logger.info("Received an event for organization id {}", orgChange.getOrganizationId());
	        
    switch(orgChange.getAction()){
        case "GET":
            logger.debug("Received a GET event from the organization service for organization id {}", orgChange.getOrganizationId());
            break;
        case "SAVE":
            logger.debug("Received a SAVE event from the organization service for organization id {}", orgChange.getOrganizationId());
            break;
        case "UPDATE":
            logger.debug("Received a UPDATE event from the organization service for organization id {}", orgChange.getOrganizationId());
            organizationRedisRepository.deleteOrganization(orgChange.getOrganizationId());
            break;
        case "DELETE":
            logger.debug("Received a DELETE event from the organization service for organization id {}", orgChange.getOrganizationId());
            organizationRedisRepository.deleteOrganization(orgChange.getOrganizationId());
            break;
        default:
            logger.error("Received an UNKNOWN event from the organization service of type {}", orgChange.getType());
            break;
    }
}
 
Example 7
Source Project: flowing-retail   Source File: MessageListener.java    License: Apache License 2.0 6 votes vote down vote up
@StreamListener(target = Sink.INPUT, condition = "(headers['type']?:'')=='OrderPlacedEvent'")
public void orderPlacedReceived(String messageJson) throws JsonParseException, JsonMappingException, IOException {
  // read data
  Message<Order> message = objectMapper.readValue(messageJson, new TypeReference<Message<Order>>() {});
  Order order = message.getData();
  
  // persist domain entity
  // (if we want to do this "transactional" this could be a step in the workflow)
  repository.save(order);

  // prepare data for workflow
  OrderFlowContext context = new OrderFlowContext();
  context.setOrderId(order.getId());
  context.setTraceId(message.getTraceid());

  // and kick of a new flow instance
  System.out.println("New order placed, start flow with " + context);
  zeebe.newCreateInstanceCommand() //
      .bpmnProcessId("order-kafka") //
      .latestVersion() // 
      .variables(context.asMap()) //
      .send().join();
}
 
Example 8
Source Project: flowing-retail   Source File: MessageListener.java    License: Apache License 2.0 6 votes vote down vote up
@StreamListener(target = Sink.INPUT, 
    condition="(headers['type']?:'')=='PaymentReceivedEvent'")
@Transactional
public void paymentReceived(String messageJson) throws JsonParseException, JsonMappingException, IOException {
  Message<JsonNode> message = objectMapper.readValue(messageJson, new TypeReference<Message<JsonNode>>(){});
  
  ObjectNode payload = (ObjectNode) message.getData();
  Item[] items = objectMapper.treeToValue(payload.get("items"), Item[].class);
  
  String pickId = inventoryService.pickItems( // 
      Arrays.asList(items), "order", payload.get("orderId").asText());
  
  // as in payment - we have to keep the whole order in the payload 
  // as the data flows through this service
  
  payload.put("pickId", pickId);
  
  messageSender.send( //
      new Message<JsonNode>( //
          "GoodsFetchedEvent", //
          message.getTraceid(), //
          payload));
}
 
Example 9
Source Project: flowing-retail   Source File: MessageListener.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Handles incoming OrderPlacedEvents. 
 * 
 *  Using the conditional {@link StreamListener} from 
 * https://github.com/spring-cloud/spring-cloud-stream/blob/master/spring-cloud-stream-core-docs/src/main/asciidoc/spring-cloud-stream-overview.adoc
 * in a way close to what Axion
 *  would do (see e.g. https://dturanski.wordpress.com/2017/03/26/spring-cloud-stream-for-event-driven-architectures/)
 */
@StreamListener(target = Sink.INPUT, 
    condition="(headers['type']?:'')=='OrderPlacedEvent'")
@Transactional
public void orderPlacedReceived(Message<Order> message) throws JsonParseException, JsonMappingException, IOException {
  Order order = message.getData();
  
  System.out.println("New order placed, start flow. " + order);
  
  // persist domain entity
  repository.save(order);    
  
  // and kick of a new flow instance
  camunda.getRuntimeService().createMessageCorrelation(message.getType())
    .processInstanceBusinessKey(message.getTraceid())
    .setVariable("orderId", order.getId())
    .correlateWithResult();
}
 
Example 10
Source Project: functional-eventsourcing   Source File: Application.java    License: Apache License 2.0 5 votes vote down vote up
@StreamListener(Sink.INPUT)
public void commandStream(Command command) {
    log.info("Received command {}", command);
    if (command instanceof MarkPaymentTimeout) {
        shopItems.markPaymentTimeout((MarkPaymentTimeout) command);
    } else if (command instanceof Order) {
        shopItems.order((Order) command);
    } else if (command instanceof Pay) {
        shopItems.pay((Pay) command);
    }
}
 
Example 11
@StreamListener(Sink.INPUT)
public void receiveOrderlyMsg(String receiveMsg) {
	if (count.getAndIncrement() <= 5) {
           throw new RuntimeException("Oops: " + receiveMsg);
	}
	else {
		log.info("receiveOrderlyMsg: " + receiveMsg);
	}
}
 
Example 12
@StreamListener(Sink.INPUT)
public void receiveOrderlyMsg(String receiveMsg) {
    log.info("invoke: " + count.get());
	if (count.getAndIncrement() <= 6) {
           throw new RuntimeException("Oops: " + receiveMsg);
	}
	else {
		log.info("receiveOrderlyMsg: " + receiveMsg);
	}
}
 
Example 13
Source Project: rocketmq-binder-demo   Source File: SendToService.java    License: Apache License 2.0 5 votes vote down vote up
/**
    * @SendTo is useful with @StreamListener
    */

@StreamListener(Sink.INPUT)
@SendTo(SendToApplication.TEMP_INPUT)
public String receive(String receiveMsg) {
	System.out.println("receive: " + receiveMsg);
	return "handle by SendTo(" + receiveMsg + ")";
}
 
Example 14
@StreamListener(Sink.INPUT)
public void receiveConcurrentlyMsg(String receiveMsg) {
    log.info("invoke: " + count.get());
	if (count.getAndIncrement() <= 5) {
           throw new RuntimeException("Oops: " + receiveMsg);
	}
	else {
		log.info("receiveOrderlyMsg: " + receiveMsg);
	}
}
 
Example 15
Source Project: rocketmq-binder-demo   Source File: FilterService.java    License: Apache License 2.0 5 votes vote down vote up
@Filter(inputChannel = Sink.INPUT, discardChannel = FilterApplication.DISCARD_INPUT, outputChannel = FilterApplication.SUCCESS_INPUT)
public boolean receiveByFilter(String receiveMsg) {
	String[] msgInfo = receiveMsg.split("-");
	if (Integer.parseInt(msgInfo[1]) % 2 == 0) {
		return true;
	}
	return false;
}
 
Example 16
Source Project: flowing-retail   Source File: MessageListener.java    License: Apache License 2.0 5 votes vote down vote up
@StreamListener(target = Sink.INPUT, condition = "(headers['type']?:'')=='GoodsFetchedEvent'")
@Transactional
public void goodsFetchedReceived(String messageJson) throws Exception {
  Message<GoodsFetchedEventPayload> message = objectMapper.readValue(messageJson, new TypeReference<Message<GoodsFetchedEventPayload>>() {});

  String pickId = message.getData().getPickId();     

  zeebe.newPublishMessageCommand() //
      .messageName(message.getType()) //
      .correlationKey(message.getCorrelationid()) // 
      .variables(Collections.singletonMap("pickId", pickId)) //
      .send().join();

  System.out.println("Correlated " + message );
}
 
Example 17
@StreamListener(target = Sink.INPUT)
public void process(Event<Integer, Review> event) {

    LOG.info("Process message created at {}...", event.getEventCreatedAt());

    switch (event.getEventType()) {

    case CREATE:
        Review review = event.getData();
        LOG.info("Create review with ID: {}/{}", review.getProductId(), review.getReviewId());
        reviewService.createReview(review);
        break;

    case DELETE:
        int productId = event.getKey();
        LOG.info("Delete reviews with ProductID: {}", productId);
        reviewService.deleteReviews(productId);
        break;

    default:
        String errorMessage = "Incorrect event type: " + event.getEventType() + ", expected a CREATE or DELETE event";
        LOG.warn(errorMessage);
        throw new EventProcessingException(errorMessage);
    }

    LOG.info("Message processing done!");
}
 
Example 18
@StreamListener(target = Sink.INPUT)
public void process(Event<Integer, Product> event) {

    LOG.info("Process message created at {}...", event.getEventCreatedAt());

    switch (event.getEventType()) {

    case CREATE:
        Product product = event.getData();
        LOG.info("Create product with ID: {}", product.getProductId());
        productService.createProduct(product);
        break;

    case DELETE:
        int productId = event.getKey();
        LOG.info("Delete recommendations with ProductID: {}", productId);
        productService.deleteProduct(productId);
        break;

    default:
        String errorMessage = "Incorrect event type: " + event.getEventType() + ", expected a CREATE or DELETE event";
        LOG.warn(errorMessage);
        throw new EventProcessingException(errorMessage);
    }

    LOG.info("Message processing done!");
}
 
Example 19
@StreamListener(target = Sink.INPUT)
public void process(Event<Integer, Recommendation> event) {

    LOG.info("Process message created at {}...", event.getEventCreatedAt());

    switch (event.getEventType()) {

    case CREATE:
        Recommendation recommendation = event.getData();
        LOG.info("Create recommendation with ID: {}/{}", recommendation.getProductId(), recommendation.getRecommendationId());
        recommendationService.createRecommendation(recommendation);
        break;

    case DELETE:
        int productId = event.getKey();
        LOG.info("Delete recommendations with ProductID: {}", productId);
        recommendationService.deleteRecommendations(productId);
        break;

    default:
        String errorMessage = "Incorrect event type: " + event.getEventType() + ", expected a CREATE or DELETE event";
        LOG.warn(errorMessage);
        throw new EventProcessingException(errorMessage);
    }

    LOG.info("Message processing done!");
}
 
Example 20
@StreamListener(target = Sink.INPUT)
public void process(Event<Integer, Review> event) {

    LOG.info("Process message created at {}...", event.getEventCreatedAt());

    switch (event.getEventType()) {

    case CREATE:
        Review review = event.getData();
        LOG.info("Create review with ID: {}/{}", review.getProductId(), review.getReviewId());
        reviewService.createReview(review);
        break;

    case DELETE:
        int productId = event.getKey();
        LOG.info("Delete reviews with ProductID: {}", productId);
        reviewService.deleteReviews(productId);
        break;

    default:
        String errorMessage = "Incorrect event type: " + event.getEventType() + ", expected a CREATE or DELETE event";
        LOG.warn(errorMessage);
        throw new EventProcessingException(errorMessage);
    }

    LOG.info("Message processing done!");
}
 
Example 21
@StreamListener(target = Sink.INPUT)
public void process(Event<Integer, Product> event) {

    LOG.info("Process message created at {}...", event.getEventCreatedAt());

    switch (event.getEventType()) {

    case CREATE:
        Product product = event.getData();
        LOG.info("Create product with ID: {}", product.getProductId());
        productService.createProduct(product);
        break;

    case DELETE:
        int productId = event.getKey();
        LOG.info("Delete recommendations with ProductID: {}", productId);
        productService.deleteProduct(productId);
        break;

    default:
        String errorMessage = "Incorrect event type: " + event.getEventType() + ", expected a CREATE or DELETE event";
        LOG.warn(errorMessage);
        throw new EventProcessingException(errorMessage);
    }

    LOG.info("Message processing done!");
}
 
Example 22
@StreamListener(target = Sink.INPUT)
public void process(Event<Integer, Recommendation> event) {

    LOG.info("Process message created at {}...", event.getEventCreatedAt());

    switch (event.getEventType()) {

    case CREATE:
        Recommendation recommendation = event.getData();
        LOG.info("Create recommendation with ID: {}/{}", recommendation.getProductId(), recommendation.getRecommendationId());
        recommendationService.createRecommendation(recommendation);
        break;

    case DELETE:
        int productId = event.getKey();
        LOG.info("Delete recommendations with ProductID: {}", productId);
        recommendationService.deleteRecommendations(productId);
        break;

    default:
        String errorMessage = "Incorrect event type: " + event.getEventType() + ", expected a CREATE or DELETE event";
        LOG.warn(errorMessage);
        throw new EventProcessingException(errorMessage);
    }

    LOG.info("Message processing done!");
}
 
Example 23
@StreamListener(target = Sink.INPUT)
public void process(Event<Integer, Review> event) {

    LOG.info("Process message created at {}...", event.getEventCreatedAt());

    switch (event.getEventType()) {

    case CREATE:
        Review review = event.getData();
        LOG.info("Create review with ID: {}/{}", review.getProductId(), review.getReviewId());
        reviewService.createReview(review);
        break;

    case DELETE:
        int productId = event.getKey();
        LOG.info("Delete reviews with ProductID: {}", productId);
        reviewService.deleteReviews(productId);
        break;

    default:
        String errorMessage = "Incorrect event type: " + event.getEventType() + ", expected a CREATE or DELETE event";
        LOG.warn(errorMessage);
        throw new EventProcessingException(errorMessage);
    }

    LOG.info("Message processing done!");
}
 
Example 24
Source Project: flowing-retail   Source File: MessageListener.java    License: Apache License 2.0 5 votes vote down vote up
@StreamListener(target = Sink.INPUT, 
    condition="(headers['type']?:'')=='GoodsFetchedEvent'")
@Transactional
public void shipGoodsCommandReceived(String messageJson) throws Exception {
  Message<JsonNode> message = objectMapper.readValue(messageJson, new TypeReference<Message<JsonNode>>(){});
  ObjectNode payload = (ObjectNode) message.getData();
  GoodsFetchedEventPayload payloadEvent = objectMapper //
      .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) //
      .treeToValue(payload, GoodsFetchedEventPayload.class);

  String shipmentId = shippingService.createShipment( //
      payloadEvent.getPickId(), //
      payloadEvent.getCustomer().getName(), //
      payloadEvent.getCustomer().getAddress(), //
      "DHL");
  
  payload.put("shipmentId", shipmentId);
      
  messageSender.send( //
      new Message<JsonNode>( //
          "GoodsShippedEvent", //
          message.getTraceid(), //
          payload));
  // as nobody else can send an order completed event I will issue it here
  // Bad smell (order context is missing)
  messageSender.send( //
      new Message<JsonNode>( //
          "OrderCompletedEvent", //
          message.getTraceid(), //
          payload));
}
 
Example 25
@StreamListener(target = Sink.INPUT)
public void process(Event<Integer, Review> event) {

    LOG.info("Process message created at {}...", event.getEventCreatedAt());

    switch (event.getEventType()) {

    case CREATE:
        Review review = event.getData();
        LOG.info("Create review with ID: {}/{}", review.getProductId(), review.getReviewId());
        reviewService.createReview(review);
        break;

    case DELETE:
        int productId = event.getKey();
        LOG.info("Delete reviews with ProductID: {}", productId);
        reviewService.deleteReviews(productId);
        break;

    default:
        String errorMessage = "Incorrect event type: " + event.getEventType() + ", expected a CREATE or DELETE event";
        LOG.warn(errorMessage);
        throw new EventProcessingException(errorMessage);
    }

    LOG.info("Message processing done!");
}
 
Example 26
@StreamListener(target = Sink.INPUT)
public void process(Event<Integer, Product> event) {

    LOG.info("Process message created at {}...", event.getEventCreatedAt());

    switch (event.getEventType()) {

    case CREATE:
        Product product = event.getData();
        LOG.info("Create product with ID: {}", product.getProductId());
        productService.createProduct(product);
        break;

    case DELETE:
        int productId = event.getKey();
        LOG.info("Delete recommendations with ProductID: {}", productId);
        productService.deleteProduct(productId);
        break;

    default:
        String errorMessage = "Incorrect event type: " + event.getEventType() + ", expected a CREATE or DELETE event";
        LOG.warn(errorMessage);
        throw new EventProcessingException(errorMessage);
    }

    LOG.info("Message processing done!");
}
 
Example 27
@StreamListener(target = Sink.INPUT)
public void process(Event<Integer, Recommendation> event) {

    LOG.info("Process message created at {}...", event.getEventCreatedAt());

    switch (event.getEventType()) {

    case CREATE:
        Recommendation recommendation = event.getData();
        LOG.info("Create recommendation with ID: {}/{}", recommendation.getProductId(), recommendation.getRecommendationId());
        recommendationService.createRecommendation(recommendation);
        break;

    case DELETE:
        int productId = event.getKey();
        LOG.info("Delete recommendations with ProductID: {}", productId);
        recommendationService.deleteRecommendations(productId);
        break;

    default:
        String errorMessage = "Incorrect event type: " + event.getEventType() + ", expected a CREATE or DELETE event";
        LOG.warn(errorMessage);
        throw new EventProcessingException(errorMessage);
    }

    LOG.info("Message processing done!");
}
 
Example 28
@StreamListener(target = Sink.INPUT)
public void process(Event<Integer, Review> event) {

    LOG.info("Process message created at {}...", event.getEventCreatedAt());

    switch (event.getEventType()) {

    case CREATE:
        Review review = event.getData();
        LOG.info("Create review with ID: {}/{}", review.getProductId(), review.getReviewId());
        reviewService.createReview(review);
        break;

    case DELETE:
        int productId = event.getKey();
        LOG.info("Delete reviews with ProductID: {}", productId);
        reviewService.deleteReviews(productId);
        break;

    default:
        String errorMessage = "Incorrect event type: " + event.getEventType() + ", expected a CREATE or DELETE event";
        LOG.warn(errorMessage);
        throw new EventProcessingException(errorMessage);
    }

    LOG.info("Message processing done!");
}
 
Example 29
@StreamListener(target = Sink.INPUT)
public void process(Event<Integer, Product> event) {

    LOG.info("Process message created at {}...", event.getEventCreatedAt());

    switch (event.getEventType()) {

    case CREATE:
        Product product = event.getData();
        LOG.info("Create product with ID: {}", product.getProductId());
        productService.createProduct(product);
        break;

    case DELETE:
        int productId = event.getKey();
        LOG.info("Delete recommendations with ProductID: {}", productId);
        productService.deleteProduct(productId);
        break;

    default:
        String errorMessage = "Incorrect event type: " + event.getEventType() + ", expected a CREATE or DELETE event";
        LOG.warn(errorMessage);
        throw new EventProcessingException(errorMessage);
    }

    LOG.info("Message processing done!");
}
 
Example 30
@StreamListener(target = Sink.INPUT)
public void process(Event<Integer, Recommendation> event) {

    LOG.info("Process message created at {}...", event.getEventCreatedAt());

    switch (event.getEventType()) {

    case CREATE:
        Recommendation recommendation = event.getData();
        LOG.info("Create recommendation with ID: {}/{}", recommendation.getProductId(), recommendation.getRecommendationId());
        recommendationService.createRecommendation(recommendation);
        break;

    case DELETE:
        int productId = event.getKey();
        LOG.info("Delete recommendations with ProductID: {}", productId);
        recommendationService.deleteRecommendations(productId);
        break;

    default:
        String errorMessage = "Incorrect event type: " + event.getEventType() + ", expected a CREATE or DELETE event";
        LOG.warn(errorMessage);
        throw new EventProcessingException(errorMessage);
    }

    LOG.info("Message processing done!");
}