package org.herrdommel.messaging;

import org.herrdommel.batch.PersonItemProcessor;
import org.herrdommel.model.Book;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Component;

/**
 * @author <a href="mailto:dominik.mohr@adesso.de">Dominik Mohr</a>
 * @since 29.07.2017
 */
@Component
public class MessagingReceiver {

    public static final String BOOK_LOGGER_REQUEST_DESTINATION = "book-view-request-logger";
    public static final String BOOK_LOGGER_DISPLAY_DESTINATION = "book-view-display-logger";

    private static final Logger LOGGER = LoggerFactory.getLogger(PersonItemProcessor.class);

    @JmsListener(destination = BOOK_LOGGER_DISPLAY_DESTINATION)
    public void logReceivedBookDisplay(Book book) {
        LOGGER.info("Displaying book with isbn " + book.getIsbn() + " and id " + book.getId());
    }

    @JmsListener(destination = BOOK_LOGGER_REQUEST_DESTINATION)
    public void logReceivedBookRequest(String isbn) {
        LOGGER.info("Viewed book details for book with isbn " + isbn);
    }

}
