package click.kamil.examples.enterprise.messaging;

import click.kamil.examples.enterprise.constants.OrderEvents;
import lombok.RequiredArgsConstructor;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.statemachine.StateMachine;
import org.springframework.stereotype.Component;

@Component
@RequiredArgsConstructor
public class ReturnsRabbitListener {

    private final StateMachine<String, String> stateMachine;

    @RabbitListener(queues = "returns.queue")
    public void onReturn(String orderId) {
        stateMachine.sendEvent(OrderEvents.RETURN);
    }
}
