RabbitMQ with Spring Boot
spring-boot-starter-amqp, se, Spring, Boot, applications, RabbitMQ, ke, saath, INTEGRATE, ho, sakti, HAIN — RabbitTemplate, MESSAGES, SEND, karne, ke, liye, aur, @RabbitListener, RECEIVE, karne, ke, liye, USE, hote, HAIN.
RabbitMQ, Kafka, se, DIFFERENT, USE-CASE, ke, liye, BETTER, SUITED, hai — COMPLEX, ROUTING, LOGIC, (jaise, EXCHANGE, TYPES, — direct, topic, fanout) aur, GUARANTEED, DELIVERY, ORDER, ke, liye.
@Service
public class NotificationService {
@Autowired
private RabbitTemplate rabbitTemplate;
public void sendNotification(String message) {
rabbitTemplate.convertAndSend("notification-exchange", "routing.key", message);
}
}
@RabbitListener(queues = "notification-queue")
public void receiveNotification(String message) {
// Send, email/SMS
}- RabbitMQ = traditional, message, queue — spring-boot-starter-amqp
- RabbitTemplate (send) + @RabbitListener (receive)
- Kafka, high-throughput, streaming, ke, liye, RabbitMQ, complex, routing, ke, liye, BETTER
Direct, exchange, EK, EXACT, routing, key, match, PAR, route, karta hai. Topic, exchange, PATTERN-BASED, routing, allow, karta hai. Fanout, exchange, SAARI, bound, queues, ko, message, BROADCAST, karta hai — HAR, EK, ALAG, use-case, ke, liye.
@Bean
public TopicExchange orderExchange() {
return new TopicExchange("order-exchange");
}Dead, letter, queue, (DLQ), un, messages, ke, liye, hai, JO, PROCESS, nahi, ho, paaye, (max, retries, exceed, karne, ke, baad) — failed, messages, ko, LOSE, karne, ke, BAJAYE, EK, SEPARATE, queue, mein, RAKHA, jaata hai, MANUAL, investigation, ke, liye.