- 浏览: 309138 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (118)
- oracle (16)
- java (13)
- jquery (16)
- hibernate (2)
- spring (14)
- struts (2)
- eclipse (1)
- birt (5)
- integrated skill (13)
- linux (9)
- css+html (5)
- redis (1)
- jqgrid (4)
- mybatis (2)
- multithreading (3)
- jvm (1)
- mvn (3)
- php (2)
- jms (2)
- photoshop (1)
- springmvc (3)
- cluster (1)
- cache (1)
- jquery-ui (2)
- 英语词根 (0)
- svn (0)
- ide (1)
- mysql (3)
- rich-text (1)
- golang (8)
- mac 10 (1)
- android (1)
- react (0)
- bootstrap (2)
- css (2)
- 1 (0)
- beego (1)
- pictures (1)
- java小生转战 (0)
- 转站通知 (0)
- 转站通知,,,啊啊啊 (1)
- threeperson (1)
- unity (1)
最新评论
-
zld406504302:
aaaddddddd
java小生转站threeperson博客 -
zld406504302:
aaaaaddd
java小生转站threeperson博客 -
zld406504302:
aaaaaaaaaaaa
java小生转站threeperson博客 -
乌发舞天:
UEditor 实例 -
van_2013:
请问这是订阅模式的配置吗?
SPRING JMS 整合ACTIVEMQ
SPRING INTERCEPTOR 监控 JMS 发送接受性能
将spring aspectj 和 jms 整合了一下,用spring interceptor 监控jms 发送接受方法。通过方法注解 标记执行总次数,拦截器在指定的方法执行到目标执行次数后,将性能跟踪信息记录日志。
aop-conf.xml
log4j.properties 开启监控interceptor race 日志功能
applicationContext.xml
MethodMonitorCount 注解接口
JmsMessageHanderMonitor 性能监控的aspect
console 信息如下
aop-conf.xml
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:oxm="http://www.springframework.org/schema/oxm" xmlns:cache="http://www.springframework.org/schema/cache" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm-3.2.xsd http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd"> <bean id="jmsMessageHanderMonitor" class="com.cn.ld.modules.jms.monitor.JmsMessageHanderMonitor"> <property name="useDynamicLogger" value="false" /> <constructor-arg index="0"> <value>1</value> </constructor-arg> </bean> <aop:config> <aop:pointcut id="allServiceMethods" expression="execution(* com.cn.ld.modules.jms.worker..*(..))" /> <aop:advisor pointcut-ref="allServiceMethods" advice-ref="jmsMessageHanderMonitor" order="2" /> </aop:config> </beans>
log4j.properties 开启监控interceptor race 日志功能
log4j.logger.com.cn.ld.modules.jms.monitor.JmsMessageHanderMonitor=TRACE
applicationContext.xml
<!-- aop source --> <import resource="aop-config.xml" />
MethodMonitorCount 注解接口
package com.cn.ld.modules.annotation; import java.lang.annotation.Retention; import java.lang.annotation.Target; import java.lang.annotation.ElementType; import java.lang.annotation.RetentionPolicy; @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) public @interface MethodMonitorCount { int value() default 1; }
JmsMessageHanderMonitor 性能监控的aspect
package com.cn.ld.modules.jms.monitor; import java.lang.annotation.Annotation; import java.lang.reflect.Method; import java.text.MessageFormat; import java.util.concurrent.ConcurrentHashMap; import org.aopalliance.intercept.MethodInvocation; import org.apache.commons.logging.Log; import org.springframework.aop.framework.ReflectiveMethodInvocation; import org.springframework.aop.interceptor.AbstractMonitoringInterceptor; import org.springframework.util.StopWatch; import com.cn.ld.modules.annotation.MethodMonitorCount; public class JmsMessageHanderMonitor extends AbstractMonitoringInterceptor { private static final long serialVersionUID = 1L; private ConcurrentHashMap<java.lang.reflect.Method, PerformanceSampl> methodPerfSampl = new ConcurrentHashMap<java.lang.reflect.Method, PerformanceSampl>(); private int monitorCount = 1; public JmsMessageHanderMonitor(int monitorCount) { this.monitorCount = monitorCount; } public JmsMessageHanderMonitor(boolean useDynamicLogger) { setUseDynamicLogger(useDynamicLogger); } @Override protected Object invokeUnderTrace(MethodInvocation methodinvocation, Log logger) throws Throwable { ReflectiveMethodInvocation reflectMethod = (ReflectiveMethodInvocation) methodinvocation; Method m = reflectMethod.getMethod(); Annotation[] annotations = m.getAnnotations(); if (null == annotations || annotations.length == 0) { return methodinvocation.proceed(); } PerformanceSampl sampl = null; // 将追踪的目标方法作为key缓存,如果已经存在,直接获取该方法的跟踪内容对象PerformanceSampl if (methodPerfSampl.containsKey(m)) { sampl = methodPerfSampl.get(m); } else { sampl = new PerformanceSampl(); methodPerfSampl.put(m, sampl); } String target = m.toString(); // 首次目标对象调用,初始化跟踪信息 if (sampl.getReceNo() == 0) { StopWatch sw = new StopWatch(target); sampl.setStopWatch(sw); MethodMonitorCount mmc = (MethodMonitorCount) annotations[0]; sampl.setMaxReceNo(mmc.value()); sw.start(m.getName()); } // 目标方法执行 Object obj = methodinvocation.proceed(); // 每次调用累加调用次数 sampl.setReceNo(sampl.getReceNo() + 1); // 目标方法调用次数等于目标最大调用次数时,统计目标方法执行性能指标 if (sampl.getReceNo() == sampl.getMaxReceNo()) { sampl.getStopWatch().stop(); // 记录日志 showTraceInfo(logger, sampl, target); // 追踪结束,将该方法的cache信息清空 methodPerfSampl.remove(m); } return obj; } private void showTraceInfo(Log logger, PerformanceSampl sampl, String target) { String formatStr = "monitor target method:{0} ; expect execute times:{1};actual execute times:{2};execution Speed:{3}/s"; MessageFormat paramMf = new MessageFormat(formatStr); long costTime = (sampl.getStopWatch().getTotalTimeMillis() / 1000); int executeTimes = sampl.getReceNo(); costTime = costTime == 0 ? costTime : (executeTimes / costTime); logger.trace(paramMf.format(new Object[] { target, sampl.getMaxReceNo(), executeTimes, costTime })); } /* *性能信息 */ private static class PerformanceSampl { private StopWatch stopWatch; private int maxReceNo; // 接受数量 private int receNo; public void setReceNo(int receNo) { this.receNo = receNo; } public StopWatch getStopWatch() { return stopWatch; } public void setStopWatch(StopWatch stopWatch) { this.stopWatch = stopWatch; } public int getMaxReceNo() { return maxReceNo; } public void setMaxReceNo(int maxReceNo) { this.maxReceNo = maxReceNo; } public int getReceNo() { return receNo; } } public int getMonitorCount() { return monitorCount; } public void setMonitorCount(int monitorCount) { this.monitorCount = monitorCount; } }
console 信息如下
[2013-07-18 17:12:00,645][TRACE]<main>(JmsMessageHanderMonitor.java:87) - monitor target method:public void com.cn.ld.modules.jms.worker.JmsSender.sendSingle(java.lang.String,javax.jms.Destination) ; expect execute times:10,000;actual execute times:10,000;execution Speed:10,000/s [2013-07-18 17:12:00,784][TRACE]<jmsContainer-1>(JmsMessageHanderMonitor.java:87) - monitor target method:public abstract void com.cn.ld.modules.jms.handler.MessageHandler.handleMessage(java.lang.String) ; expect execute times:10,000;actual execute times:10,000;execution Speed:10,000/s
发表评论
-
spring jdbcTemplate 批量插入返回自增id
2016-03-22 00:24 1971项目中一个业务场景包含两个相互依赖的批量插入,第二次批量插入 ... -
mvn assembly package jar 无法运行
2015-04-27 20:04 742项目中要跑了一个jar工程,每天做一次数据结 ... -
SPRING JMS 发送 接受 性能监控
2013-07-18 17:13 0将spring aspectj 和 jms 整合了一下, ... -
SPRING JMS 整合ACTIVEMQ
2013-07-18 16:47 13057近日用spring3.2 jms 与activemq5.8 ... -
SLF4J jar包冲突的迷惑
2013-07-14 12:42 1463Running com.cn.ld.modules.jms.J ... -
SLF4J jar包冲突的迷惑
2013-07-14 12:42 0Running com.cn.ld.modules.jms.J ... -
tomcat 集群下ehcache 整合spring cache-annotation
2013-07-02 12:44 6167系统环境:win7 部署环境:apache2.2 tomcat ... -
springmvc 整合apache tiles
2013-06-15 23:36 9070最近把springmvc3.2.0 和 apache t ... -
springmvc3.2 demo
2013-06-15 23:28 107061:mvn 构建一个web工程 [img] [/img] r ... -
spring jms 异步接受消息
2013-05-22 21:46 24spring jms 的监听器是可配置的,而且通常会交 ... -
SPRING JMS + ACTIVEMQ 实例
2013-05-15 13:21 48工作需要,对spring jms 和消息服务器 amq 做 ... -
用enum替换Static final 常量
2013-03-27 16:10 2210一个task 需要对对8个元件页面显示字段的值进行格式 ... -
jar包方式发布项目
2013-03-26 15:20 42项目组新来了一个外包美工,做css+div+js特效。 ... -
velocity 实例
2013-03-18 22:26 1979通过velocity对字符串进行格式化输出 packag ... -
Spring Multipart上传
2013-03-18 11:53 11251:在application.xml中初始化CommonsM ... -
@Value 注解
2013-03-13 15:43 1321:在application。xml文件中配置属性文件加载be ... -
多线程同步写入,单线程读出
2013-02-19 16:40 2238把项目中一个大文件对比进行了简单了模拟,多线程将大文件下的多个 ... -
spring 事务隔离 与 传播
2012-07-15 21:18 9721) PROPAGATION_REQUIRED ,默认的spr ... -
Jsoup 解析html
2012-06-04 15:42 1415Jsoup 遍历html 是很便捷的,查看api 发现他的很多 ... -
AXIS2 与SSH 集成 事物代理不可用
2012-05-28 18:42 20562012-5-28 18:17: ...
相关推荐
常用拦截 拦截器HandlerInterceptor 拦截器MethodInterceptor 添加依赖 创建启动类 创建拦截器类 创建控制器 监控control请求耗时,提高性能
本篇文章主要介绍了Spring MVC Interceptor 实现性能监控的功能代码,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
spring boot jwt 和 interceptor的例子。 其中jwt的例子网上有很多,但是都是要数据库支持,这个只是用假数据模拟,不需要数据库支持。另外还有一个拦截器的简单例子。已经在sts 4 测试通过。
SpringAOP与SpringMVC拦截器两种方式实现权限管控,前台xml读取配置根据登录用户判断button是否enable
主要介绍了spring boot加入拦截器Interceptor过程解析,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
postman interceptor
InterCeptor
详细介绍struts2 interceptor
Postman-Interceptor下载
通过代理和反射实现一个Interceptor框架
springmvc中关于拦截器的使用
Chrome Postman和Postman Interceptor 插件比较版本匹配才能正常使用,否则send时会一直提示loading状态
Postman Interceptor:通过Postman发送请求,get,post.
弹簧方法拦截器 该示例显示了一个HandlerInterceptor来拦截Web调用并注销注释值。 此示例使用启动2,唯一的区别是您将使用WebMvcConfigurer注册拦截器。
spring+springmvc+Interceptor+jwt+redis实现sso单点登录.zip
spring mvc annotation interceptor
NULL 博文链接:https://yuwuxia.iteye.com/blog/2246781
postman 和 postman interceptor。亲测可用,里边有说明博客