package click.kamil.examples.enterprise.messaging;

import click.kamil.examples.enterprise.constants.OrderEvents;
import lombok.RequiredArgsConstructor;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.statemachine.StateMachine;
import org.springframework.stereotype.Component;

@Component
@RequiredArgsConstructor
public class ShippingJmsListener {

    private final StateMachine<String, String> stateMachine;

    @JmsListener(destination = "shipping.queue")
    public void onShippingReady(String orderId) {
        stateMachine.sendEvent(OrderEvents.SHIP);
    }
}
