Skip to content

Instantly share code, notes, and snippets.

@tacsio
tacsio / ListenerSample.java
Created August 21, 2022 15:34 — forked from timpamungkasudemy/ListenerSample.java
Sample Listener if you don't have __TypeID__ but have other header (for example : type)
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");
@tacsio
tacsio / InvoiceListener.java
Created August 21, 2022 15:34 — forked from timpamungkasudemy/InvoiceListener.java
Sample Listener if you don't have __TypeID__ but have other header (for example : type)
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;
@tacsio
tacsio / RabbitmqConfig.java
Created August 21, 2022 15:34 — forked from timpamungkasudemy/RabbitmqConfig.java
Sample RabbitmqConfig if you don't have __TypeID__ but have other header (for example : type)
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessagePostProcessor;
import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.boot.autoconfigure.amqp.SimpleRabbitListenerContainerFactoryConfigurer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@tacsio
tacsio / links.textile
Created May 24, 2012 07:12 — forked from lucashungaro/links.textile
Links de referência utilizados em minha palestra