Ria Choi
← Portfolio

LogiBox

An event-driven logistics backend where I worked on making the order-to-delivery handoff recoverable and traceable.

LogiBox

When an order is accepted but delivery creation fails, the customer needs a clear status and the stock needs to return to inventory. That handoff was the most important part of LogiBox for me. My work covered orders, delivery features, RabbitMQ integration, and traces across the service boundary.

LogiBox project brief and service architecture, captured from Notion.
LogiBox project brief and service architecture, captured from Notion.

Giving each service ownership of its state

LogiBox keeps order, catalog, and logistics logic in separate services. The catalog owns stock, the order service owns order history, and logistics owns deliveries. RabbitMQ carries changes across those boundaries. A Redis lock coordinates concurrent inventory work and stores an owner token. Its compare-and-delete release only removes the lock when that token still matches.

Java
    private static final String UNLOCK_SCRIPT = """
            if redis.call("get", KEYS[1]) == ARGV[1] then
                return redis.call("del", KEYS[1])
            else
                return 0
            end
            """;

    public boolean tryLock(String key, String value, Duration ttl) {
        Boolean result = redisTemplate.opsForValue().setIfAbsent(key, value, ttl);
        return Boolean.TRUE.equals(result);
    }

Compensating when delivery creation fails

Successful delivery creation associates the delivery ID with the order and moves it to waiting for delivery. A failed creation after stock deduction calls the catalog service to restore the quantity, then marks the order failed and records the reason. The history entry and Slack notification provide a trail that can be followed across services.

Java
    public void handleDeliveryFailed(UUID orderId, String reason) {

        Order order = orderRepository.findById(orderId)
                .orElseThrow();

        catalogClient.restoreStock(
                order.getProductId(),
                order.getQuantity()
        );

        order.fail();

        saveHistory(
                orderId,
                OrderStatus.PENDING,
                OrderStatus.FAILED,
                reason
        );

Following a message across the broker

I enabled observation for both the RabbitMQ producer and listener. This provides tracing context on the publishing and consuming sides for Zipkin. It helps identify whether work stopped before publishing or after the consumer picked up the message.

Java
@Bean
public SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory(
        ConnectionFactory connectionFactory,
        MessageConverter messageConverter
) {
    SimpleRabbitListenerContainerFactory factory =
            new SimpleRabbitListenerContainerFactory();

    factory.setConnectionFactory(connectionFactory);
    factory.setMessageConverter(messageConverter);

    // Consumer Trace 전파 활성화
    factory.setObservationEnabled(true);

    return factory;
}

What I learned

An asynchronous boundary needs a defined outcome when the next step fails. Making the compensation and order history explicit mattered as much as carrying the success event through the broker.

Related articles

B2B AI logistics Systemic Backend Design

Saga Patterns