-
-
Save tacsio/a9099a77e71ecc4484e2171ab73f024e to your computer and use it in GitHub Desktop.
Sample Listener if you don't have __TypeID__ but have other header (for example : type)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.slf4j.Logger; | |
import org.slf4j.LoggerFactory; | |
import org.springframework.amqp.core.Message; | |
import org.springframework.amqp.rabbit.annotation.RabbitHandler; | |
import org.springframework.amqp.rabbit.annotation.RabbitListener; | |
import org.springframework.stereotype.Service; | |
import com.course.finance.message.invoice.InvoiceCreatedMessage; | |
import com.course.finance.message.invoice.InvoicePaidMessage; | |
@Service | |
@RabbitListener(queues = "q.invoice") | |
public class InvoiceListener { | |
private static final Logger log = LoggerFactory.getLogger(InvoiceListener.class); | |
@RabbitHandler | |
public void listenInvoiceCreated(InvoiceCreatedMessage message) { | |
log.info("Listening invoice created : {}", message); | |
} | |
@RabbitHandler | |
public void listenInvoicePaid(InvoicePaidMessage message) { | |
log.info("Listening invoice paid : {}", message); | |
} | |
@RabbitHandler(isDefault = true) | |
public void listenDefault(Message message) { | |
log.info("Default invoice listener : {}", message.getMessageProperties().getHeaders()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment