|
@@ -1,15 +1,11 @@ |
|
|
package com.telpo.iotgateway.listener; |
|
|
package com.telpo.iotgateway.listener; |
|
|
|
|
|
|
|
|
import com.google.common.base.Stopwatch; |
|
|
|
|
|
import com.google.common.util.concurrent.ThreadFactoryBuilder; |
|
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import org.apache.commons.lang3.concurrent.BasicThreadFactory; |
|
|
import org.apache.commons.lang3.concurrent.BasicThreadFactory; |
|
|
import org.springframework.scheduling.annotation.Scheduled; |
|
|
|
|
|
import org.springframework.stereotype.Component; |
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
|
import javax.jms.Message; |
|
|
import javax.jms.Message; |
|
|
import javax.jms.MessageListener; |
|
|
import javax.jms.MessageListener; |
|
|
import javax.validation.constraints.Positive; |
|
|
|
|
|
import java.util.concurrent.*; |
|
|
import java.util.concurrent.*; |
|
|
import java.util.concurrent.atomic.AtomicInteger; |
|
|
import java.util.concurrent.atomic.AtomicInteger; |
|
|
|
|
|
|
|
@@ -37,7 +33,6 @@ public class IotMessageListener implements MessageListener { |
|
|
// task to run goes here |
|
|
// task to run goes here |
|
|
log.warn("约1分钟处理 {} 个请求",count); |
|
|
log.warn("约1分钟处理 {} 个请求",count); |
|
|
count.getAndSet(0); |
|
|
count.getAndSet(0); |
|
|
//System.out.println("Hello, stranger"); |
|
|
|
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
@@ -48,7 +43,7 @@ public class IotMessageListener implements MessageListener { |
|
|
// 第二个参数为首次执行的延时时间,第三个参数为定时执行的间隔时间 |
|
|
// 第二个参数为首次执行的延时时间,第三个参数为定时执行的间隔时间 |
|
|
// 10:秒 5:秒 |
|
|
// 10:秒 5:秒 |
|
|
// 第一次执行的时间为10秒,然后每隔五秒执行一次 |
|
|
// 第一次执行的时间为10秒,然后每隔五秒执行一次 |
|
|
service.scheduleAtFixedRate(runnable, 60, 60, TimeUnit.SECONDS); |
|
|
|
|
|
|
|
|
service.scheduleAtFixedRate(runnable, 120, 60, TimeUnit.SECONDS); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private ExecutorService executorService; |
|
|
private ExecutorService executorService; |
|
@@ -80,10 +75,10 @@ public class IotMessageListener implements MessageListener { |
|
|
String content = new String(body); |
|
|
String content = new String(body); |
|
|
String topic = message.getStringProperty("topic"); |
|
|
String topic = message.getStringProperty("topic"); |
|
|
String messageId = message.getStringProperty("messageId"); |
|
|
String messageId = message.getStringProperty("messageId"); |
|
|
log.info("receive message" |
|
|
|
|
|
+ ", topic = " + topic |
|
|
|
|
|
+ ", messageId = " + messageId |
|
|
|
|
|
+ ", content = " + content); |
|
|
|
|
|
|
|
|
// log.info("receive message" |
|
|
|
|
|
// + ", topic = " + topic |
|
|
|
|
|
// + ", messageId = " + messageId |
|
|
|
|
|
// + ", content = " + content); |
|
|
count.getAndIncrement(); |
|
|
count.getAndIncrement(); |
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|