package com.ifish.socketNew; import com.alibaba.fastjson.JSONObject; import com.ifish.entity.event.QueueEventBody; import com.ifish.entity.event.QueueEventEntity; import com.ifish.util.IfishUtil; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; //import org.springframework.jms.core.JmsTemplate; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; //import javax.jms.Destination; //import javax.jms.Session; import java.util.Date; /** * @author: yan.y * @Description: 测试队列消息发送 * @Date: Created in 16:20 2019-04-10 * @Modified by: */ //@RunWith(SpringJUnit4ClassRunner.class) //@ContextConfiguration(locations="classpath:application-context.xml") public class SomeServerQueueTest { // @Autowired // private JmsTemplate jmsTemplate; // // @Autowired // private Destination ifish7DataQueueDestination; // @Autowired // private Destination ifish7PushQueueDestination; // // @Test // public void testDataMessageSend(){ // String json = "this's a test message"; // JSONObject data = new JSONObject(); // data.put("heaterMacAddress","12345"); // data.put("heaterWaterTemperature","130"); // data.put("heaterPh","1200"); // data.put("heaterGatheringDate", IfishUtil.format1(new Date())); // data.put("heaterGatheringTime","17"); // // QueueEventEntity eventEntity = new QueueEventEntity(); // eventEntity.setEventName("com.ifish7.mq.queues.event.IntelligentHeatingRodEvent"); // eventEntity.setEventProcess("intelligentHeatingRodSaveOrUpdate"); // QueueEventBody eventBody = new QueueEventBody("com.ifish7.mq.business.device.entity.TblDeviceHeater",data); // eventEntity.setEventBody(eventBody); // // String eventEntityStr = JSONObject.toJSONString(eventEntity); // //jmsTemplate.send(ifish7DataQueueDestination,(Session session) -> session.createTextMessage(eventEntityStr)); // } // // @Test // public void testPushMessageSend(){ // String json = "this's a test message"; // JSONObject data = new JSONObject(); // data.put("heaterMacAddress","12345"); // data.put("heaterWaterTemperature","130"); // data.put("heaterPh","1200"); // data.put("heaterGatheringDate", IfishUtil.format1(new Date())); // data.put("heaterGatheringTime","17"); // // QueueEventEntity eventEntity = new QueueEventEntity(); // eventEntity.setEventName("com.ifish7.mq.queues.event.IntelligentHeatingRodEvent"); // eventEntity.setEventProcess("intelligentHeatingRodSaveOrUpdate"); // QueueEventBody eventBody = new QueueEventBody("com.ifish7.mq.business.device.entity.TblDeviceHeater",data); // eventEntity.setEventBody(eventBody); // // String eventEntityStr = JSONObject.toJSONString(eventEntity); // //智能加热棒数据更新及保存 // //jmsTemplate.send(ifish7PushQueueDestination,(Session session) -> session.createTextMessage(eventEntityStr)); // } }