我正在尝试使用logging-channel-adapter记录入站消息。我有以下spring集成配置
<int:gateway service-interface="com.kipstor.events.EventGateway" default-request-channel="loggerChannel" />
<int:channel id="loggerChannel">
<int:interceptors>
<int:wire-tap channel="logger" />
</int:interceptors>
</int:channel>
<int:logging-channel-adapter id="logger" logger-name="kipstorLog" level="INFO" log-full-message="true" />
我的log4j文件配置如下
log4j.appender.kipstorLog=org.apache.log4j.DailyRollingFileAppender
log4j.appender.kipstorLog.File=${catalina.home}/logs/kipstor.log
log4j.appender.kipstorLog.DatePattern='.'yyyy-MM-dd
log4j.appender.kipstorLog.MaxFileSize=5MB
log4j.appender.kipstorLog.MaxBackupIndex=10
log4j.appender.kipstorLog.layout=com.kipstor.kpp.util.CustomLogLayout
log4j.appender.kipstorLog.layout.ConversionPattern=%-5p %d{yyyy-MM-dd HH:mm:ss} %C{1}:%L - %m%n
但是,在发生异常后调用服务接口时
2018-02-23 11:17:17 ERROR SimpleAsyncUncaughtExceptionHandler:37 - Unexpected error occurred invoking async method 'public void com.kipstor.events.EventService.setEvent(java.lang.String,int,java.lang.String,java.lang.String[])'.
org.springframework.messaging.MessageDeliveryException: Dispatcher has no subscribers for channel 'org.springframework.web.context.WebApplicationContext:/KipstorRestApi.loggerChannel'.; nested exception is org.springframework.integration.MessageDispatchingException: Dispatcher has no subscribers
at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:81)
at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:442)
at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:392)
at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:115)
at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:45)
at org.springframework.messaging.core.AbstractMessageSendingTemplate.send(AbstractMessageSendingTemplate.java:105)
at org.springframework.messaging.core.AbstractMessageSendingTemplate.convertAndSend(AbstractMessageSendingTemplate.java:143)
at org.springframework.messaging.core.AbstractMessageSendingTemplate.convertAndSend(AbstractMessageSendingTemplate.java:135)
at org.springframework.integration.gateway.MessagingGatewaySupport.send(MessagingGatewaySupport.java:364)
at org.springframework.integration.gateway.GatewayProxyFactoryBean.invokeGatewayMethod(GatewayProxyFactoryBean.java:425)
at org.springframework.integration.gateway.GatewayProxyFactoryBean.doInvoke(GatewayProxyFactoryBean.java:382)
at org.springframework.integration.gateway.GatewayProxyFactoryBean.invoke(GatewayProxyFactoryBean.java:373)
at org.springframework.integration.gateway.GatewayCompletableFutureProxyFactoryBean.invoke(GatewayCompletableFutureProxyFactoryBean.java:64)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:208)
at com.sun.proxy.$Proxy125.publishEvent(Unknown Source)
at com.kipstor.events.EventService.setEvent(EventService.java:33)
at com.kipstor.events.EventService$$FastClassBySpringCGLIB$$6aec3e8b.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:720)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.aop.interceptor.AsyncExecutionInterceptor$1.call(AsyncExecutionInterceptor.java:108)
at org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler$DelegatingErrorHandlingCallable.call(ThreadPoolTaskScheduler.java:386)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.springframework.integration.MessageDispatchingException: Dispatcher has no subscribers
at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:153)
at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:120)
at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:77)
... 28 more
知道出了什么问题吗?
答案 0 :(得分:0)
记录此消息后,将不再需要
所以,你根本不需要<wire-tap>
。
这就足够了:
<int:gateway service-interface="com.kipstor.events.EventGateway" default-request-channel="logger" />
<int:logging-channel-adapter id="logger" logger-name="kipstorLog" level="INFO" log-full-message="true" />
我的意思是您的网关应该只向logger
频道发送消息。
另一个你的问题值得一个单独的问题。它与这一主题无关。