1
注釈を使用してinboundChannelAdapterを定義しました。 MyConfig.javaバネ統合コマンドバスを使用して、注釈で定義されたAbstractEndpointsを開始/停止します
@Bean
@InboundChannelAdapter(value = "inputChannel", poller = @Poller(fixedRate = "5000"),
autoStartup = "true")
public MessageSource<File> input() {
final FileReadingMessageSource result = new FileReadingMessageSource();
result.setDirectory(new File("src/main/java/test"));
return result;
}
私はそれを停止しようとした:
MessageChannel controlChannel = ctx.getBean("controlBusChannel", MessageChannel.class);
AbstractPollingEndpoint endpoint = ctx.getBean("myConfig.input.inboundChannelAdapter", AbstractPollingEndpoint.class);
if(endpoint.isRunning()){
controlChannel.send(new GenericMessage<String>("@"+endpoint.getComponentName()+".stop()"));
}
しかし、私はこの例外を取得:
Exception in thread "main" org.springframework.messaging.MessageHandlingException: error occurred in message handler [ServiceActivator for [org.spring[email protected]11b2519] (controlBus)]; nested exception is org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 10): Property or field 'input' cannot be found on object of type 'test.commandbus.MyConfig$$EnhancerBySpringCGLIB$$11f6b4ee' - maybe not public?
at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:139)
at org.springframework.integration.dispatcher.AbstractDispatcher.tryOptimizedDispatch(AbstractDispatcher.java:116)
at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:147)
at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:120)
at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:77)
at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:442)
at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:392)
at test.commandbus.Main.main(Main.java:32)
Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 10): Property or field 'input' cannot be found on object of type 'test.commandbus.MyConfig$$EnhancerBySpringCGLIB$$11f6b4ee' - maybe not public?
at org.springframework.expression.spel.ast.PropertyOrFieldReference.readProperty(PropertyOrFieldReference.java:224)
at org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:94)
at org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:81)
at org.springframework.expression.spel.ast.CompoundExpression.getValueRef(CompoundExpression.java:57)
at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:87)
at org.springframework.expression.spel.ast.SpelNodeImpl.getTypedValue(SpelNodeImpl.java:131)
at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:330)
at org.springframework.integration.util.AbstractExpressionEvaluator.evaluateExpression(AbstractExpressionEvaluator.java:150)
at org.springframework.integration.util.AbstractExpressionEvaluator.evaluateExpression(AbstractExpressionEvaluator.java:145)
at org.springframework.integration.handler.ExpressionCommandMessageProcessor.processMessage(ExpressionCommandMessageProcessor.java:73)
at org.springframework.integration.handler.ServiceActivatingHandler.handleRequestMessage(ServiceActivatingHandler.java:89)
at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:99)
at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:127)
... 7 more
は定義することなく、アダプターを停止する方法はありますそのための特定の@Bean?
あなたは 'input'という名前の春の豆を持っていますが、SPELはプロパティやフィールドの 'input'を探しています。 – popalka
FileReadingMessagSourceをLifecycle(MessageSourceではなく)として公開して、開始メソッドと停止メソッドを提供してください。 – popalka