This commit is contained in:
lixiangrong 2016-07-12 14:15:58 +08:00
parent 25439fbe07
commit 9d0a00d1e9
20 changed files with 1112 additions and 367 deletions

97
pom.xml
View File

@ -11,7 +11,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spring.version>4.2.4.RELEASE</spring.version>
<spring.version>4.0.2.RELEASE</spring.version>
<servlet.version>2.5</servlet.version>
<mybatis.version>3.2.7</mybatis.version>
<mybatis.spring.version>1.1.1</mybatis.spring.version>
@ -26,72 +26,112 @@
<artifactId>jsch</artifactId>
<version>0.1.53</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk16</artifactId>
<version>1.46</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<!-- <scope>test</scope> -->
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.3</version>
</dependency>
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-core</artifactId>
<version>1.2.2</version>
</dependency>
<!-- spring begin-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-oxm</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jms</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
<version>${spring.version}</version>
</dependency>
<!-- spring end-->
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
@ -110,16 +150,19 @@
<artifactId>hessian</artifactId>
<version>4.0.38</version>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>2.8.0</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.38</version>
</dependency>
<!-- servlet -->
<dependency>
<groupId>javax.servlet</groupId>
@ -134,42 +177,62 @@
<artifactId>mybatis</artifactId>
<version>${mybatis.version}</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>${mybatis.spring.version}</version>
</dependency>
<dependency>
<groupId>com.github.loafer</groupId>
<artifactId>mybatis-paging</artifactId>
<version>${mybatis.paging.version}</version>
</dependency>
<dependency>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-core</artifactId>
<version>${mybatis.generator.core.version}</version>
</dependency>
<dependency>
<groupId>c3p0</groupId>
<artifactId>c3p0</artifactId>
<version>0.9.1.2</version>
</dependency>
<!-- mybatis end -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.2</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>3.1.6</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>3.1.6</version>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-all</artifactId>
<version>5.13.3</version>
</dependency>
<dependency>
<groupId>org.apache.xbean</groupId>
<artifactId>xbean-spring</artifactId>
<version>4.5</version>
</dependency>
</dependencies>
<build>
<finalName>useful-code</finalName>
@ -233,6 +296,38 @@
<value>${productionMode}</value> </systemProperty> </systemProperties> -->
</configuration>
</plugin>
<!-- 生成javadoc文档包的插件 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.2</version>
<configuration>
<aggregate>true</aggregate>
</configuration>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- 生成sources源码包的插件 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.1.2</version>
<executions>
<execution>
<id>attach-sources</id>
<phase>verify</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
<defaultGoal>compile</defaultGoal>

View File

@ -1,34 +0,0 @@
package com.pxene.dsp.archer.dao;
import com.pxene.dsp.archer.model.AdGroupAppTargetFilterModel;
import com.pxene.dsp.archer.model.AdGroupAppTargetFilterModelExample;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
public interface AdGroupAppTargetFilterDao {
int countByExample(AdGroupAppTargetFilterModelExample example);
int deleteByExample(AdGroupAppTargetFilterModelExample example);
int deleteByPrimaryKey(String id);
int insert(AdGroupAppTargetFilterModel record);
int insertSelective(AdGroupAppTargetFilterModel record);
List<AdGroupAppTargetFilterModel> selectByExample(AdGroupAppTargetFilterModelExample example);
AdGroupAppTargetFilterModel selectByPrimaryKey(String id);
int updateByExampleSelective(@Param("record") AdGroupAppTargetFilterModel record, @Param("example") AdGroupAppTargetFilterModelExample example);
int updateByExample(@Param("record") AdGroupAppTargetFilterModel record, @Param("example") AdGroupAppTargetFilterModelExample example);
int updateByPrimaryKeySelective(AdGroupAppTargetFilterModel record);
int updateByPrimaryKey(AdGroupAppTargetFilterModel record);
public List<Map<String,String>> selectAdxByAppParentCode(String parentcode);
}

View File

@ -0,0 +1,30 @@
package com.pxene.dsp.archer.dao;
import com.pxene.dsp.archer.model.GroupTargetAuditModel;
import com.pxene.dsp.archer.model.GroupTargetAuditModelExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface GroupTargetAuditDao {
int countByExample(GroupTargetAuditModelExample example);
int deleteByExample(GroupTargetAuditModelExample example);
int deleteByPrimaryKey(String id);
int insert(GroupTargetAuditModel record);
int insertSelective(GroupTargetAuditModel record);
List<GroupTargetAuditModel> selectByExample(GroupTargetAuditModelExample example);
GroupTargetAuditModel selectByPrimaryKey(String id);
int updateByExampleSelective(@Param("record") GroupTargetAuditModel record, @Param("example") GroupTargetAuditModelExample example);
int updateByExample(@Param("record") GroupTargetAuditModel record, @Param("example") GroupTargetAuditModelExample example);
int updateByPrimaryKeySelective(GroupTargetAuditModel record);
int updateByPrimaryKey(GroupTargetAuditModel record);
}

View File

@ -1,14 +1,13 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.pxene.dsp.archer.dao.AdGroupAppTargetFilterDao" >
<resultMap id="BaseResultMap" type="com.pxene.dsp.archer.model.AdGroupAppTargetFilterModel" >
<mapper namespace="com.pxene.dsp.archer.dao.GroupTargetAuditDao" >
<resultMap id="BaseResultMap" type="com.pxene.dsp.archer.model.GroupTargetAuditModel" >
<id column="id" property="id" jdbcType="VARCHAR" />
<result column="groupid" property="groupid" jdbcType="VARCHAR" />
<result column="appcategory" property="appcategory" jdbcType="VARCHAR" />
<result column="keyword" property="keyword" jdbcType="VARCHAR" />
<result column="filterValLi" property="filtervalli" jdbcType="VARCHAR" />
<result column="searchValLi" property="searchvalli" jdbcType="VARCHAR" />
<result column="adxid" property="adxid" jdbcType="VARCHAR" />
<result column="result" property="result" jdbcType="VARCHAR" />
<result column="reason" property="reason" jdbcType="VARCHAR" />
<result column="remark" property="remark" jdbcType="VARCHAR" />
<result column="createtime" property="createtime" jdbcType="TIMESTAMP" />
</resultMap>
<sql id="Example_Where_Clause" >
<where >
@ -69,16 +68,16 @@
</where>
</sql>
<sql id="Base_Column_List" >
id, groupid, appcategory, keyword, filterValLi, searchValLi, adxid
id, groupid, result, reason, remark, createtime
</sql>
<select id="selectByExample" resultMap="BaseResultMap" parameterType="com.pxene.dsp.archer.model.AdGroupAppTargetFilterModelExample" >
<select id="selectByExample" resultMap="BaseResultMap" parameterType="com.pxene.dsp.archer.model.GroupTargetAuditModelExample" >
select
<if test="distinct" >
distinct
</if>
'true' as QUERYID,
<include refid="Base_Column_List" />
from dsp_t_ad_group_apptarget_filter
from dsp_t_group_target_audit
<if test="_parameter != null" >
<include refid="Example_Where_Clause" />
</if>
@ -89,29 +88,29 @@
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
select
<include refid="Base_Column_List" />
from dsp_t_ad_group_apptarget_filter
from dsp_t_group_target_audit
where id = #{id,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
delete from dsp_t_ad_group_apptarget_filter
delete from dsp_t_group_target_audit
where id = #{id,jdbcType=VARCHAR}
</delete>
<delete id="deleteByExample" parameterType="com.pxene.dsp.archer.model.AdGroupAppTargetFilterModelExample" >
delete from dsp_t_ad_group_apptarget_filter
<delete id="deleteByExample" parameterType="com.pxene.dsp.archer.model.GroupTargetAuditModelExample" >
delete from dsp_t_group_target_audit
<if test="_parameter != null" >
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="com.pxene.dsp.archer.model.AdGroupAppTargetFilterModel" >
insert into dsp_t_ad_group_apptarget_filter (id, groupid, appcategory,
keyword, filterValLi, searchValLi,
adxid)
values (#{id,jdbcType=VARCHAR}, #{groupid,jdbcType=VARCHAR}, #{appcategory,jdbcType=VARCHAR},
#{keyword,jdbcType=VARCHAR}, #{filtervalli,jdbcType=VARCHAR}, #{searchvalli,jdbcType=VARCHAR},
#{adxid,jdbcType=VARCHAR})
<insert id="insert" parameterType="com.pxene.dsp.archer.model.GroupTargetAuditModel" >
insert into dsp_t_group_target_audit (id, groupid, result,
reason, remark, createtime
)
values (#{id,jdbcType=VARCHAR}, #{groupid,jdbcType=VARCHAR}, #{result,jdbcType=VARCHAR},
#{reason,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR}, #{createtime,jdbcType=TIMESTAMP}
)
</insert>
<insert id="insertSelective" parameterType="com.pxene.dsp.archer.model.AdGroupAppTargetFilterModel" >
insert into dsp_t_ad_group_apptarget_filter
<insert id="insertSelective" parameterType="com.pxene.dsp.archer.model.GroupTargetAuditModel" >
insert into dsp_t_group_target_audit
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
@ -119,20 +118,17 @@
<if test="groupid != null" >
groupid,
</if>
<if test="appcategory != null" >
appcategory,
<if test="result != null" >
result,
</if>
<if test="keyword != null" >
keyword,
<if test="reason != null" >
reason,
</if>
<if test="filtervalli != null" >
filterValLi,
<if test="remark != null" >
remark,
</if>
<if test="searchvalli != null" >
searchValLi,
</if>
<if test="adxid != null" >
adxid,
<if test="createtime != null" >
createtime,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
@ -142,31 +138,28 @@
<if test="groupid != null" >
#{groupid,jdbcType=VARCHAR},
</if>
<if test="appcategory != null" >
#{appcategory,jdbcType=VARCHAR},
<if test="result != null" >
#{result,jdbcType=VARCHAR},
</if>
<if test="keyword != null" >
#{keyword,jdbcType=VARCHAR},
<if test="reason != null" >
#{reason,jdbcType=VARCHAR},
</if>
<if test="filtervalli != null" >
#{filtervalli,jdbcType=VARCHAR},
<if test="remark != null" >
#{remark,jdbcType=VARCHAR},
</if>
<if test="searchvalli != null" >
#{searchvalli,jdbcType=VARCHAR},
</if>
<if test="adxid != null" >
#{adxid,jdbcType=VARCHAR},
<if test="createtime != null" >
#{createtime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.pxene.dsp.archer.model.AdGroupAppTargetFilterModelExample" resultType="java.lang.Integer" >
select count(*) from dsp_t_ad_group_apptarget_filter
<select id="countByExample" parameterType="com.pxene.dsp.archer.model.GroupTargetAuditModelExample" resultType="java.lang.Integer" >
select count(*) from dsp_t_group_target_audit
<if test="_parameter != null" >
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map" >
update dsp_t_ad_group_apptarget_filter
update dsp_t_group_target_audit
<set >
<if test="record.id != null" >
id = #{record.id,jdbcType=VARCHAR},
@ -174,20 +167,17 @@
<if test="record.groupid != null" >
groupid = #{record.groupid,jdbcType=VARCHAR},
</if>
<if test="record.appcategory != null" >
appcategory = #{record.appcategory,jdbcType=VARCHAR},
<if test="record.result != null" >
result = #{record.result,jdbcType=VARCHAR},
</if>
<if test="record.keyword != null" >
keyword = #{record.keyword,jdbcType=VARCHAR},
<if test="record.reason != null" >
reason = #{record.reason,jdbcType=VARCHAR},
</if>
<if test="record.filtervalli != null" >
filterValLi = #{record.filtervalli,jdbcType=VARCHAR},
<if test="record.remark != null" >
remark = #{record.remark,jdbcType=VARCHAR},
</if>
<if test="record.searchvalli != null" >
searchValLi = #{record.searchvalli,jdbcType=VARCHAR},
</if>
<if test="record.adxid != null" >
adxid = #{record.adxid,jdbcType=VARCHAR},
<if test="record.createtime != null" >
createtime = #{record.createtime,jdbcType=TIMESTAMP},
</if>
</set>
<if test="_parameter != null" >
@ -195,60 +185,45 @@
</if>
</update>
<update id="updateByExample" parameterType="map" >
update dsp_t_ad_group_apptarget_filter
update dsp_t_group_target_audit
set id = #{record.id,jdbcType=VARCHAR},
groupid = #{record.groupid,jdbcType=VARCHAR},
appcategory = #{record.appcategory,jdbcType=VARCHAR},
keyword = #{record.keyword,jdbcType=VARCHAR},
filterValLi = #{record.filtervalli,jdbcType=VARCHAR},
searchValLi = #{record.searchvalli,jdbcType=VARCHAR},
adxid = #{record.adxid,jdbcType=VARCHAR}
result = #{record.result,jdbcType=VARCHAR},
reason = #{record.reason,jdbcType=VARCHAR},
remark = #{record.remark,jdbcType=VARCHAR},
createtime = #{record.createtime,jdbcType=TIMESTAMP}
<if test="_parameter != null" >
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="com.pxene.dsp.archer.model.AdGroupAppTargetFilterModel" >
update dsp_t_ad_group_apptarget_filter
<update id="updateByPrimaryKeySelective" parameterType="com.pxene.dsp.archer.model.GroupTargetAuditModel" >
update dsp_t_group_target_audit
<set >
<if test="groupid != null" >
groupid = #{groupid,jdbcType=VARCHAR},
</if>
<if test="appcategory != null" >
appcategory = #{appcategory,jdbcType=VARCHAR},
<if test="result != null" >
result = #{result,jdbcType=VARCHAR},
</if>
<if test="keyword != null" >
keyword = #{keyword,jdbcType=VARCHAR},
<if test="reason != null" >
reason = #{reason,jdbcType=VARCHAR},
</if>
<if test="filtervalli != null" >
filterValLi = #{filtervalli,jdbcType=VARCHAR},
<if test="remark != null" >
remark = #{remark,jdbcType=VARCHAR},
</if>
<if test="searchvalli != null" >
searchValLi = #{searchvalli,jdbcType=VARCHAR},
</if>
<if test="adxid != null" >
adxid = #{adxid,jdbcType=VARCHAR},
<if test="createtime != null" >
createtime = #{createtime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="com.pxene.dsp.archer.model.AdGroupAppTargetFilterModel" >
update dsp_t_ad_group_apptarget_filter
<update id="updateByPrimaryKey" parameterType="com.pxene.dsp.archer.model.GroupTargetAuditModel" >
update dsp_t_group_target_audit
set groupid = #{groupid,jdbcType=VARCHAR},
appcategory = #{appcategory,jdbcType=VARCHAR},
keyword = #{keyword,jdbcType=VARCHAR},
filterValLi = #{filtervalli,jdbcType=VARCHAR},
searchValLi = #{searchvalli,jdbcType=VARCHAR},
adxid = #{adxid,jdbcType=VARCHAR}
result = #{result,jdbcType=VARCHAR},
reason = #{reason,jdbcType=VARCHAR},
remark = #{remark,jdbcType=VARCHAR},
createtime = #{createtime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=VARCHAR}
</update>
<select id="selectAdxByAppParentCode" parameterType="java.lang.String" resultType="java.util.Map">
SELECT DISTINCT
t0.adxtype,
t1.id adxid
FROM
dsp_t_syn_app_adx t0
LEFT JOIN dsp_t_adx t1 ON t0.adxtype = t1.`value`
WHERE
t0.parentcode = #{parentcode,jdbcType=VARCHAR}
</select>
</mapper>

View File

@ -0,0 +1,90 @@
package osc.git.eh3.activemq;
import org.apache.activemq.ActiveMQConnection;
import org.apache.activemq.ActiveMQConnectionFactory;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.TextMessage;
/**
* 消息的生产者发送者
* Created by lixiangrong on 2016-07-11.
*/
public class JMSProducer {
//默认连接用户名
private static final String USERNAME = ActiveMQConnection.DEFAULT_USER;
//默认连接密码
private static final String PASSWORD = ActiveMQConnection.DEFAULT_PASSWORD;
//默认连接地址
private static final String BROKEURL = ActiveMQConnection.DEFAULT_BROKER_URL;
//发送的消息数量
private static final int SENDNUM = 10;
public static void main(String[] args) {
//连接工厂
ConnectionFactory connectionFactory;
//连接
Connection connection = null;
//会话 接受或者发送消息的线程
Session session;
//消息的目的地
Destination destination;
//消息生产者
MessageProducer messageProducer;
//实例化连接工厂
connectionFactory = new ActiveMQConnectionFactory(JMSProducer.USERNAME, JMSProducer.PASSWORD, JMSProducer.BROKEURL);
try {
//通过连接工厂获取连接
connection = connectionFactory.createConnection();
//启动连接
connection.start();
//创建session
session = connection.createSession(true, javax.jms.Session.AUTO_ACKNOWLEDGE);
//创建一个名称为HelloWorld的消息队列
destination = session.createQueue("HelloWorld");
//创建消息生产者
messageProducer = session.createProducer(destination);
//发送消息
sendMessage(session, messageProducer);
session.commit();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (connection != null) {
try {
connection.close();
} catch (JMSException e) {
e.printStackTrace();
}
}
}
}
/**
* 发送消息
*
* @param session
* @param messageProducer 消息生产者
* @throws Exception
*/
public static void sendMessage(Session session, MessageProducer messageProducer) throws Exception {
for (int i = 0; i < JMSProducer.SENDNUM; i++) {
//创建一条文本消息
TextMessage message = session.createTextMessage("ActiveMQ 发送消息" + i);
System.out.println("发送消息Activemq 发送消息" + i);
//通过消息生产者发出消息
messageProducer.send(message);
}
}
}

View File

@ -0,0 +1,65 @@
package osc.git.eh3.springamq.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import osc.git.eh3.springamq.mq.producer.queue.QueueSender;
import osc.git.eh3.springamq.mq.producer.topic.TopicSender;
import javax.annotation.Resource;
/**
*
* @author liang
* @description controller测试
*/
@Controller
@RequestMapping("/activemq")
public class ActivemqController {
@Resource
QueueSender queueSender;
@Resource
TopicSender topicSender;
/**
* 发送消息到队列
* Queue队列仅有一个订阅者会收到消息消息一旦被处理就不会存在队列中
* @param message
* @return String
*/
@ResponseBody
@RequestMapping("queueSender")
public String queueSender(@RequestParam("message")String message){
String opt="";
try {
queueSender.send("test.queue", message);
opt = "suc";
} catch (Exception e) {
opt = e.getCause().toString();
}
return opt;
}
/**
* 发送消息到主题
* Topic主题 放入一个消息所有订阅者都会收到
* 这个是主题目的地是一对多的
* @param message
* @return String
*/
@ResponseBody
@RequestMapping("topicSender")
public String topicSender(@RequestParam("message")String message){
String opt = "";
try {
topicSender.send("test.topic", message);
opt = "suc";
} catch (Exception e) {
opt = e.getCause().toString();
}
return opt;
}
}

View File

@ -0,0 +1,28 @@
package osc.git.eh3.springamq.mq.consumer.queue;
import org.springframework.stereotype.Component;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;
/**
*
* @author liang
* @description 队列消息监听器
*
*/
@Component
public class QueueReceiver1 implements MessageListener {
@Override
public void onMessage(Message message) {
try {
System.out.println("QueueReceiver1接收到消息:"+((TextMessage)message).getText());
} catch (JMSException e) {
e.printStackTrace();
}
}
}

View File

@ -0,0 +1,29 @@
package osc.git.eh3.springamq.mq.consumer.queue;
import org.springframework.stereotype.Component;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;
/**
*
* @author liang
* @description 队列消息监听器
*
*/
@Component
public class QueueReceiver2 implements MessageListener {
@Override
public void onMessage(Message message) {
try {
System.out.println("QueueReceiver2接收到消息:"+((TextMessage)message).getText());
} catch (JMSException e) {
e.printStackTrace();
}
}
}

View File

@ -0,0 +1,30 @@
package osc.git.eh3.springamq.mq.consumer.topic;
import org.springframework.stereotype.Component;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;
/**
*
* @author liang
* @description Topic消息监听器
*
*/
@Component
public class TopicReceiver1 implements MessageListener{
@Override
public void onMessage(Message message) {
try {
System.out.println("TopicReceiver1接收到消息:"+((TextMessage)message).getText());
} catch (JMSException e) {
e.printStackTrace();
}
}
}

View File

@ -0,0 +1,29 @@
package osc.git.eh3.springamq.mq.consumer.topic;
import org.springframework.stereotype.Component;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;
/**
*
* @author liang
* @description Topic消息监听器
*
*/
@Component
public class TopicReceiver2 implements MessageListener{
@Override
public void onMessage(Message message) {
try {
System.out.println("TopicReceiver2接收到消息:"+((TextMessage)message).getText());
} catch (JMSException e) {
e.printStackTrace();
}
}
}

View File

@ -0,0 +1,40 @@
package osc.git.eh3.springamq.mq.producer.queue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.jms.core.MessageCreator;
import org.springframework.stereotype.Component;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.Session;
/**
*
* @author liang
* @description 队列消息生产者发送消息到队列
*
*/
@Component("queueSender")
public class QueueSender {
@Autowired
@Qualifier("jmsQueueTemplate")
private JmsTemplate jmsTemplate;//通过@Qualifier修饰符来注入对应的bean
/**
* 发送一条消息到指定的队列目标
* @param queueName 队列名称
* @param message 消息内容
*/
public void send(String queueName,final String message){
jmsTemplate.send(queueName, new MessageCreator() {
@Override
public Message createMessage(Session session) throws JMSException {
return session.createTextMessage(message);
}
});
}
}

View File

@ -0,0 +1,41 @@
package osc.git.eh3.springamq.mq.producer.topic;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.jms.core.MessageCreator;
import org.springframework.stereotype.Component;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.Session;
/**
*
* @author liang
* @description Topic生产者发送消息到Topic
*
*/
@Component("topicSender")
public class TopicSender {
@Autowired
@Qualifier("jmsTopicTemplate")
private JmsTemplate jmsTemplate;
/**
* 发送一条消息到指定的队列目标
* @param topicName 队列名称
* @param message 消息内容
*/
public void send(String topicName,final String message){
jmsTemplate.send(topicName, new MessageCreator() {
@Override
public Message createMessage(Session session) throws JMSException {
return session.createTextMessage(message);
}
});
}
}

View File

@ -0,0 +1,68 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:amq="http://activemq.apache.org/schema/core"
xmlns:jms="http://www.springframework.org/schema/jms"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/jms
http://www.springframework.org/schema/jms/spring-jms-4.0.xsd
http://activemq.apache.org/schema/core
http://activemq.apache.org/schema/core/activemq-core-5.8.0.xsd">
<!-- ActiveMQ 连接工厂 -->
<!-- 真正可以产生Connection的ConnectionFactory由对应的 JMS服务厂商提供-->
<!-- 如果连接网络tcp://ip:61616未连接网络tcp://localhost:61616 以及用户名,密码-->
<amq:connectionFactory id="amqConnectionFactory"
brokerURL="tcp://192.168.1.251:61616" userName="admin" password="admin" />
<!-- Spring Caching连接工厂 -->
<!-- Spring用于管理真正的ConnectionFactory的ConnectionFactory -->
<bean id="connectionFactory" class="org.springframework.jms.connection.CachingConnectionFactory">
<!-- 目标ConnectionFactory对应真实的可以产生JMS Connection的ConnectionFactory -->
<property name="targetConnectionFactory" ref="amqConnectionFactory"></property>
<!-- 同上,同理 -->
<!-- <constructor-arg ref="amqConnectionFactory" /> -->
<!-- Session缓存数量 -->
<property name="sessionCacheSize" value="100" />
</bean>
<!-- Spring JmsTemplate 的消息生产者 start-->
<!-- 定义JmsTemplate的Queue类型 -->
<bean id="jmsQueueTemplate" class="org.springframework.jms.core.JmsTemplate">
<!-- 这个connectionFactory对应的是我们定义的Spring提供的那个ConnectionFactory对象 -->
<constructor-arg ref="connectionFactory" />
<!-- 非pub/sub模型发布/订阅),即队列模式 -->
<property name="pubSubDomain" value="false" />
</bean>
<!-- 定义JmsTemplate的Topic类型 -->
<bean id="jmsTopicTemplate" class="org.springframework.jms.core.JmsTemplate">
<!-- 这个connectionFactory对应的是我们定义的Spring提供的那个ConnectionFactory对象 -->
<constructor-arg ref="connectionFactory" />
<!-- pub/sub模型发布/订阅) -->
<property name="pubSubDomain" value="true" />
</bean>
<!--Spring JmsTemplate 的消息生产者 end-->
<!-- 消息消费者 start-->
<!-- 定义Queue监听器 -->
<jms:listener-container destination-type="queue" container-type="default" connection-factory="connectionFactory" acknowledge="auto">
<jms:listener destination="test.queue" ref="queueReceiver1"/>
<jms:listener destination="test.queue" ref="queueReceiver2"/>
</jms:listener-container>
<!-- 定义Topic监听器 -->
<jms:listener-container destination-type="topic" container-type="default" connection-factory="connectionFactory" acknowledge="auto">
<jms:listener destination="test.topic" ref="topicReceiver1"/>
<jms:listener destination="test.topic" ref="topicReceiver2"/>
</jms:listener-container>
<!-- 消息消费者 end -->
</beans>

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- 查找最新的schemaLocation 访问 http://www.springframework.org/schema/ -->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:amq="http://activemq.apache.org/schema/core"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://activemq.apache.org/schema/core
http://activemq.apache.org/schema/core/activemq-core-5.9.0.xsd">
<bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor"/>
<!-- 配置扫描路径 -->
<context:component-scan base-package="osc.git.eh3.springamq">
<!-- 只扫描Service也可以添加Repostory但是要把Controller排除在外Controller由spring-mvc.xml去加载 -->
<!-- <context:include-filter type="annotation" expression="org.springframework.stereotype.Service" /> -->
<!-- <context:include-filter type="annotation" expression="org.springframework.stereotype.Repository" /> -->
<!-- <context:include-filter type="annotation" expression="org.springframework.stereotype.Component" /> -->
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
</beans>

View File

@ -23,7 +23,7 @@
<javaClientGenerator type="XMLMAPPER" targetPackage="com.pxene.dsp.archer.dao" targetProject="src/main/java">
<property name="enableSubPackages" value="true"/>
</javaClientGenerator>
<table tableName="dsp_t_ad_group_apptarget_filter" domainObjectName="AdGroupAppTargetFilterModel" enableCountByExample="true" enableUpdateByExample="true" enableDeleteByExample="true" enableSelectByExample="true" selectByExampleQueryId="true" />
<table tableName="dsp_t_group_target_audit" domainObjectName="GroupTargetAuditModel" enableCountByExample="true" enableUpdateByExample="true" enableDeleteByExample="true" enableSelectByExample="true" selectByExampleQueryId="true" />
<!--
<table tableName="dsp_t_advertiser" domainObjectName="AdvertiserModel" enableCountByExample="true" enableUpdateByExample="true" enableDeleteByExample="true" enableSelectByExample="true" selectByExampleQueryId="true" />
<table tableName="dsp_t_open_request_data" domainObjectName="OpenRequestDataModel" enableCountByExample="true" enableUpdateByExample="true" enableDeleteByExample="true" enableSelectByExample="true" selectByExampleQueryId="true"></table>

View File

@ -0,0 +1,27 @@
### direct log messages to stdout and logFile###
log4j.rootCategory=INFO, stdout,logFile
# OpenSymphony Stuff
log4j.logger.com.opensymphony=INFO
log4j.logger.org.apache.struts2=INFO
log4j.logger.org.apache.commons=INFO
# Spring Stuff
log4j.logger.org.springframework=INFO
log4j.logger.org.springframework.oxm=INFO
# Hibernate Stuff
log4j.logger.org.hibernate=INFO
log4j.logger.org.hibernate.type=INFO
log4j.logger.org.hibernate.tool.hbm2ddl=INFO
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=[%p] %-d{yyyy-MM-dd HH\:mm\:ss} [%t] [%c.%M\:%L] %m%n
log4j.appender.logFile=org.apache.log4j.RollingFileAppender
log4j.appender.logFile.File=${webapp.root}/logs/amq.log
log4j.appender.logFile.layout=org.apache.log4j.PatternLayout
log4j.appender.logFile.layout.ConversionPattern=[%p] %-d{yyyy-MM-dd HH\:mm\:ss} [%t] [%c.%M\:%L] %m%n
log4j.appender.logFile.MaxFileSize = 5MB
log4j.appender.logFile.MaxBackupIndex =3

View File

@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- 查找最新的schemaLocation 访问 http://www.springframework.org/schema/ -->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.0.xsd">
<!-- 启用MVC注解 -->
<mvc:annotation-driven />
<!-- 静态资源文件不会被Spring MVC拦截 -->
<mvc:resources location="/resources/" mapping="/resources/**"/>
<!-- 指定Sping组件扫描的基本包路径 -->
<context:component-scan base-package="osc.git.eh3.springamq" >
<!-- 这里只扫描Controller不可重复加载Service -->
<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
<!-- JSP视图解析器-->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/views/" />
<property name="suffix" value=".jsp" />
<!-- 定义其解析视图的order顺序为1 -->
<property name="order" value="1" />
</bean>
</beans>

View File

@ -1,7 +1,71 @@
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<display-name>ActiveMQSpringDemo</display-name>
<!-- Log4J Start -->
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>classpath:log4j.properties</param-value>
</context-param>
<context-param>
<param-name>log4jRefreshInterval</param-name>
<param-value>6000</param-value>
</context-param>
<!-- Spring Log4J config -->
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
<!-- Log4J End -->
<!-- Spring 编码过滤器 start -->
<filter>
<filter-name>characterEncoding</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>characterEncoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- Spring 编码过滤器 End -->
<!-- Spring Application Context Listener Start -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:applicationContext.xml,classpath*:ActiveMQ.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- Spring Application Context Listener End -->
<!-- Spring MVC Config Start -->
<servlet>
<servlet-name>SpringMVC</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring-mvc.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>SpringMVC</servlet-name>
<!-- Filter all resources -->
<url-pattern>/</url-pattern>
</servlet-mapping>
<!-- Spring MVC Config End -->
<web-app>
<display-name>Archetype Created Web Application</display-name>
</web-app>

View File

@ -1,5 +1,104 @@
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
System.out.println(path);
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
System.out.println(basePath);
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>ActiveMQ Demo程序</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<script type="text/javascript" src="resources/jquery-1.11.0.min.js"></script>
<style type="text/css">
.h1 {
margin: 0 auto;
}
#producer{
width: 48%;
border: 1px solid blue;
height: 80%;
align:center;
margin:0 auto;
}
body{
text-align :center;
}
div {
text-align :center;
}
textarea{
width:80%;
height:100px;
border:1px solid gray;
}
button{
background-color: rgb(62, 156, 66);
border: none;
font-weight: bold;
color: white;
height:30px;
}
</style>
<script type="text/javascript">
function send(controller){
if($("#message").val()==""){
$("#message").css("border","1px solid red");
return;
}else{
$("#message").css("border","1px solid gray");
}
$.ajax({
type: 'post',
url:'<%=basePath%>activemq/'+controller,
dataType:'text',
data:{"message":$("#message").val()},
success:function(data){
if(data=="suc"){
$("#status").html("<font color=green>发送成功</font>");
setTimeout(clear,1000);
}else{
$("#status").html("<font color=red>"+data+"</font>");
setTimeout(clear,5000);
}
},
error:function(data){
$("#status").html("<font color=red>ERROR:"+data["status"]+","+data["statusText"]+"</font>");
setTimeout(clear,5000);
}
});
}
function clear(){
$("#status").html("");
}
</script>
</head>
<body>
<h2>Hello World!</h2>
<h1>Hello ActiveMQ</h1>
<div id="producer">
<h2>Producer</h2>
<textarea id="message"></textarea>
<br>
<button onclick="send('queueSender')">发送Queue消息</button>
<button onclick="send('topicSender')">发送Topic消息</button>
<br>
<span id="status"></span>
</div>
</body>
</html>

File diff suppressed because one or more lines are too long