私はSpring Boot + Axon Frameworkの開発デモに取り組んでいます: https://www.youtube.com/watch?v=Jp-rW-XOYzA&list=PLgGXSWYM2FpOa_FTla-x5Wd10dpmgrRC4&index=54 . この例では、最新の依存関係のみを使用しており、他のものはそのまま保持しています。
コードを単純に実行すると、以下のエラーが発生し、すでに行に何か問題があります。私を案内してください。
エラー:-
java.lang.Error: Unresolved compilation problem:
Exception Exception is not compatible with throws clause in SpringAMQPMessageSource.onMessage(Message, Channel)
at com.example.DemoComplaintsStatsApplication$1.onMessage(DemoComplaintsStatsApplication.java:54) ~[classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_151]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_151]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_151]
at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_151]
at org.springframework.messaging.handler.invocation.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:181) ~[spring-messaging-5.0.10.RELEASE.jar:5.0.10.RELEASE]
at org.springframework.messaging.handler.invocation.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:114) ~[spring-messaging-5.0.10.RELEASE.jar:5.0.10.RELEASE]
at org.springframework.amqp.rabbit.listener.adapter.HandlerAdapter.invoke(HandlerAdapter.java:51) ~[spring-rabbit-2.0.8.RELEASE.jar:2.0.8.RELEASE]
at org.springframework.amqp.rabbit.listener.adapter.MessagingMessageListenerAdapter.invokeHandler(MessagingMessageListenerAdapter.java:188) ~[spring-rabbit-2.0.8.RELEASE.jar:2.0.8.RELEASE]
at org.springframework.amqp.rabbit.listener.adapter.MessagingMessageListenerAdapter.onMessage(MessagingMessageListenerAdapter.java:126) ~[spring-rabbit-2.0.8.RELEASE.jar:2.0.8.RELEASE]
at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:1414) ~[spring-rabbit-2.0.8.RELEASE.jar:2.0.8.RELEASE]
at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.actualInvokeListener(AbstractMessageListenerContainer.java:1337) ~[spring-rabbit-2.0.8.RELEASE.jar:2.0.8.RELEASE]
at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:1324) ~[spring-rabbit-2.0.8.RELEASE.jar:2.0.8.RELEASE]
at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.executeListener(AbstractMessageListenerContainer.java:1303) ~[spring-rabbit-2.0.8.RELEASE.jar:2.0.8.RELEASE]
at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.doReceiveAndExecute(SimpleMessageListenerContainer.java:817) ~[spring-rabbit-2.0.8.RELEASE.jar:2.0.8.RELEASE]
at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.receiveAndExecute(SimpleMessageListenerContainer.java:801) ~[spring-rabbit-2.0.8.RELEASE.jar:2.0.8.RELEASE]
at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.access$700(SimpleMessageListenerContainer.java:77) ~[spring-rabbit-2.0.8.RELEASE.jar:2.0.8.RELEASE]
at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.run(SimpleMessageListenerContainer.java:1042) ~[spring-rabbit-2.0.8.RELEASE.jar:2.0.8.RELEASE]
at java.lang.Thread.run(Unknown Source) [na:1.8.0_151]
DemoComplaintsStatsApplication.java
@SpringBootApplication
public class DemoComplaintsStatsApplication {
public static void main(String[] args) {
SpringApplication.run(DemoComplaintsStatsApplication.class, args);
}
@ProcessingGroup("amqpEvents")
@RestController
public static class ComplaintStatisticsAPI {
private ConcurrentMap<String, AtomicLong> staticstics = new ConcurrentHashMap<>();
@EventHandler
public void on(ComplaintFileEvent event) {
staticstics.computeIfAbsent(event.getCompany(), k -> new AtomicLong()).incrementAndGet();
}
@GetMapping
public Map<String, AtomicLong> getStatistics(){
return staticstics;
}
}
@Bean
public SpringAMQPMessageSource complaintEvents(Serializer serializer) {
return new SpringAMQPMessageSource(new DefaultAMQPMessageConverter(serializer)) {
@RabbitListener(queues = "ComplaintEvents")
@Override
public void onMessage(Message message, Channel channel) throws Exception {
super.onMessage(message, channel);
}
};
}
}