提交 mq 配置

This commit is contained in:
qiurunze 2019-01-10 18:56:01 +08:00
parent 6e6088a7f5
commit 97247a23d5
3 changed files with 17 additions and 9 deletions

View File

@ -16,7 +16,13 @@ public interface MiaoShaMessageDao {
public List<MiaoShaMessage> listMiaoShaMessage(@Param("messageId") String messageId);
@Select("<script>select * from miaosha_message_user where 1=1 <if test=\"messageId !=null \">and messageId = #{messageId} </if></script>")
public List<MiaoShaMessageUser> listMiaoShaMessageUser(@Param("messageId") String messageId);
// @Insert("insert into miaosha_user (id , nickname ,password , salt ,head,register_date,last_login_date)value (#{id},#{nickname},#{password},#{salt},#{head},#{registerDate},#{lastLoginDate}) ")
// @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
// public void insertMiaoShaUser(MiaoshaUser miaoshaUser);
@Insert("insert into miaosha_message (id , messageid ,content , create_time ,status,over_time,message_type ,send_type , goodname , price)" +
"value (#{id},#{messageId},#{content},#{createTime},#{status},#{overTime},#{messageType},#{sendType},#{goodName},#{price}) ")
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
public void insertMiaoShaMessage(MiaoShaMessage miaoShaMessage);
@Insert("insert into miaosha_message_user (id , userid ,messageid , goodid ,orderid)" +
"value (#{id},#{userId},#{messageId},#{goodId},#{orderId}) ")
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
public void insertMiaoShaMessageUser(MiaoShaMessageUser miaoShaMessageUser);
}

View File

@ -9,6 +9,7 @@ import com.geekq.miaosha.service.OrderService;
import com.geekq.miaosha.vo.GoodsVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -36,7 +37,7 @@ public class MQReceiver {
MiaoshaMessage mm = RedisService.stringToBean(message, MiaoshaMessage.class);
MiaoshaUser user = mm.getUser();
long goodsId = mm.getGoodsId();
GoodsVo goods = goodsService.getGoodsVoByGoodsId(goodsId);
int stock = goods.getStockCount();
if(stock <= 0) {
@ -54,8 +55,9 @@ public class MQReceiver {
@RabbitListener(queues=MQConfig.MIAOSHA_MESSAGE)
public void receiveMiaoShaMessage(String message) {
@RabbitHandler
public void receiveMiaoShaMessage(Object message) {
System.out.println(111111);
System.out.println(message);
}
}

View File

@ -25,10 +25,10 @@ spring.datasource.driver-class-name=com.mysql.jdbc.Driver
#druid
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
spring.datasource.filters=stat
spring.datasource.maxActive=1000
spring.datasource.maxActive=100
spring.datasource.initialSize=100
spring.datasource.maxWait=60000
spring.datasource.minIdle=500
spring.datasource.maxWait=600
spring.datasource.minIdle=50
spring.datasource.timeBetweenEvictionRunsMillis=60000
spring.datasource.minEvictableIdleTimeMillis=300000
spring.datasource.validationQuery=select 'x'