Created
October 27, 2019 03:39
-
-
Save timpamungkasudemy/f927f2d00de77ffd3a192d57d4467667 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 hidden or 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
public class ListenerSample { | |
// Adjust the header name if required, on @Header parameter | |
@RabbitListener(queues = "q.finance.invoice") | |
public void listenInvoiceCreated(@Payload String message, @Header(AmqpHeaders.DELIVERY_TAG) long tag, | |
@Header("type") String type) throws IOException { | |
if (StringUtils.equalsIgnoreCase(type, "invoice.paid")) { | |
log.info("Delegate to invoice paid handler"); | |
} else if (StringUtils.equalsIgnoreCase(type, "invoice.created")) { | |
log.info("Delegate to invoice created handler"); | |
} else { | |
log.info("Delegate to default handler"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment