基本信息
源码名称:使用ActiveMQ队列进行邮件推送
源码大小:82.85M
文件格式:.rar
开发语言:Java
更新时间:2018-03-12
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300

本次赞助数额为: 1 元 
   源码介绍
里面包括ActiveMQ队列,直接启动即可

package com.ggbd.active.controller;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import com.alibaba.fastjson.JSONObject;
import com.ggbd.active.entity.Mail;
import com.ggbd.active.service.SendMail;


/**
 * 监听队列消息
 * 将队列的消息发送给指定邮箱
 * @author Administrator
 *
 */

@Controller
public class TopicMessageListener implements MessageListener {
	
	@Autowired
	private SendMail sendMail;
	
	public void onMessage(Message message) {
		TextMessage tm = (TextMessage) message;
		
		try {
			
			sendMail.send(JSONObject.parseObject(tm.getText(), Mail.class));
			
		} catch (JMSException e1) {
			
			e1.printStackTrace();
		}
		
	}

}