20 Aralık 2022 Salı

SpringIntegration@MessagingGateway Anotasyonu

Giriş
Şu satırı dahil ederiz 
import org.springframework.integration.annotation.MessagingGateway;
Örnek
Şöyle yaparız
@MessagingGateway
public interface OrderSubmissionGateway {

  @Gateway(requestChannel = MessageChannels.ORDER_SUBMISSION_OUTPUT)
  void submitOrder(Order order);
}

@RestController
@RequestMapping("/orders")
public class OrderRestController {

  @Autowired
  private OrderSubmissionGateway orderSubmissionGateway;

  @PostMapping()
  public ResponseEntity<Order> submitOrder(@RequestBody @Valid Order order) {
    Order orderToBeSubmitted = ...
    orderSubmissionGateway.submitOrder(orderToBeSubmitted);
    return ResponseEntity.ok(orderToBeSubmitted);
  }
}


Hiç yorum yok:

Yorum Gönder