36 lines
1.1 KiB
Java
36 lines
1.1 KiB
Java
package com.mobai.mq.rabbitmq;
|
|
|
|
import com.rabbitmq.client.Channel;
|
|
import org.springframework.amqp.core.ExchangeTypes;
|
|
import org.springframework.amqp.core.Message;
|
|
import org.springframework.amqp.rabbit.annotation.Exchange;
|
|
import org.springframework.amqp.rabbit.annotation.Queue;
|
|
import org.springframework.amqp.rabbit.annotation.QueueBinding;
|
|
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
import java.io.IOException;
|
|
|
|
/**
|
|
* @ClassName Custom
|
|
* @Description 描述
|
|
* @Author SaiSai.Liu
|
|
* @Date 2024/5/26 15:25
|
|
*/
|
|
@Component
|
|
public class Custom {
|
|
|
|
@RabbitListener(bindings = @QueueBinding(value = @Queue(value = "send_sms_queue"),
|
|
exchange = @Exchange(value = "null",type = ExchangeTypes.DIRECT)))
|
|
public void mqCustom(Object data, Message message, Channel channel){
|
|
System.out.println(data.toString());
|
|
try {
|
|
channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
|
|
} catch (IOException e) {
|
|
throw new RuntimeException(e);
|
|
}
|
|
|
|
}
|
|
|
|
}
|