├── .gitignore ├── .mvn └── jvm.config ├── .travis.yml ├── CONTRIBUTING.md ├── LICENSE.md ├── README.md ├── axon-spring-boot-starter-clustering-eventbus ├── pom.xml └── src │ ├── main │ ├── java │ │ └── hm │ │ │ └── binkley │ │ │ └── spring │ │ │ └── axon │ │ │ ├── AxonClusterAutoConfiguration.java │ │ │ ├── EventProcessingMonitorAutomation.java │ │ │ └── SimpleEventBusTerminal.java │ └── resources │ │ └── META-INF │ │ └── spring.factories │ └── test │ ├── java │ └── hm │ │ └── binkley │ │ └── spring │ │ └── axon │ │ ├── audit │ │ ├── MonitoringIT.java │ │ ├── MonitoringTestConfiguration.java │ │ └── TestEventProcessingMonitor.java │ │ └── query │ │ ├── ClusterIT.java │ │ ├── ClusterIWithCustomT.java │ │ ├── ClusterTestConfiguration.java │ │ └── ClusterWithCustomTestConfiguration.java │ └── resources │ └── application.yml ├── axon-spring-boot-starter-distributed-commandbus ├── pom.xml └── src │ ├── main │ ├── java │ │ └── hm │ │ │ └── binkley │ │ │ └── spring │ │ │ └── axon │ │ │ └── AxonDistributedCommandBusAutoConfiguration.java │ └── resources │ │ └── META-INF │ │ └── spring.factories │ └── test │ ├── java │ └── hm │ │ └── binkley │ │ └── spring │ │ └── axon │ │ └── jgroups │ │ ├── DistributedIT.java │ │ └── DistributedTestConfiguration.java │ └── resources │ ├── application.yml │ └── jgroups-config.xml ├── axon-spring-boot-starter-monitoring ├── pom.xml └── src │ ├── main │ ├── java │ │ └── hm │ │ │ └── binkley │ │ │ └── spring │ │ │ └── axon │ │ │ ├── AxonAuditEvent.java │ │ │ ├── AxonCommandAuditEvent.java │ │ │ ├── AxonEventAuditEvent.java │ │ │ ├── AxonMonitoringAutoConfiguration.java │ │ │ ├── CorrelationDataCommandDispatchInterceptor.java │ │ │ ├── DuplicateAuditKeyException.java │ │ │ ├── MessageAuditDataProvider.java │ │ │ ├── MessageMetaDataProvider.java │ │ │ └── SpringBootAuditLogger.java │ └── resources │ │ └── META-INF │ │ └── spring.factories │ └── test │ ├── java │ └── hm │ │ └── binkley │ │ └── spring │ │ └── axon │ │ ├── audit │ │ ├── AuditIT.java │ │ ├── AuditTestConfiguration.java │ │ ├── FailedCommand.java │ │ ├── FailedCommandHandler.java │ │ ├── FailedEvent.java │ │ ├── FailedEventHandler.java │ │ ├── FailedException.java │ │ ├── SuccessfulCommand.java │ │ ├── SuccessfulCommandHandler.java │ │ ├── SuccessfulEvent.java │ │ └── SuccessfulEventHandler.java │ │ ├── flow │ │ ├── FlowIT.java │ │ ├── FlowTestConfiguration.java │ │ ├── InitialAggregateRoot.java │ │ ├── InitialCommand.java │ │ ├── InitialEvent.java │ │ ├── InitialEventHandler.java │ │ ├── TerminalCommand.java │ │ └── TerminalCommandHandler.java │ │ ├── metadata │ │ ├── FailedAggregateRoot.java │ │ ├── FailedCommand.java │ │ ├── FailedEvent.java │ │ ├── FailedEventHandler.java │ │ ├── FailedException.java │ │ ├── MetaDataIT.java │ │ ├── MetaDataTestConfiguration.java │ │ ├── SuccessfulAggregateRoot.java │ │ ├── SuccessfulCommand.java │ │ ├── SuccessfulEvent.java │ │ └── SuccessfulEventHandler.java │ │ └── shared │ │ └── TestAuditEventRepository.java │ └── resources │ └── application.yaml ├── axon-spring-boot-starter-query ├── pom.xml └── src │ ├── main │ ├── java │ │ └── hm │ │ │ └── binkley │ │ │ └── spring │ │ │ └── axon │ │ │ └── AxonQueryAutoConfiguration.java │ └── resources │ │ └── META-INF │ │ └── spring.factories │ └── test │ └── java │ └── hm │ └── binkley │ └── spring │ └── axon │ └── query │ ├── QueryIT.java │ ├── QueryIWithCustomT.java │ ├── QueryTestConfiguration.java │ └── QueryWithCustomTestConfiguration.java ├── axon-spring-boot-starter-springmessaging ├── pom.xml └── src │ ├── main │ ├── java │ │ └── hm │ │ │ └── binkley │ │ │ └── spring │ │ │ └── axon │ │ │ └── AxonSpringMessagingAutoConfiguration.java │ └── resources │ │ └── META-INF │ │ └── spring.factories │ └── test │ └── java │ └── hm │ └── binkley │ └── spring │ └── axon │ └── jms │ ├── JmsIT.java │ ├── JmsTestConfiguration.java │ └── TestSubscribableChannel.java ├── axon-spring-boot-starter ├── pom.xml └── src │ ├── main │ ├── java │ │ └── hm │ │ │ └── binkley │ │ │ └── spring │ │ │ └── axon │ │ │ ├── AxonAutoConfiguration.java │ │ │ ├── CommandDispatchInterceptorAutomation.java │ │ │ ├── CommandHandlerInterceptorAutomation.java │ │ │ └── EventSourcingRepositoryRegistrar.java │ └── resources │ │ └── META-INF │ │ └── spring.factories │ └── test │ └── java │ └── hm │ └── binkley │ └── spring │ └── axon │ ├── handlers │ ├── HandlersIT.java │ ├── HandlersTest.java │ ├── HandlersTestAggregateRoot.java │ ├── HandlersTestCommand.java │ ├── HandlersTestConfiguration.java │ └── HandlersTestEvent.java │ ├── interceptors │ ├── DispatchInterceptorsIT.java │ ├── DispatchInterceptorsTestConfiguration.java │ ├── HandlerInterceptorsIT.java │ ├── HandlerInterceptorsTestConfiguration.java │ └── TestCommand.java │ ├── query │ ├── BasicIT.java │ ├── BasicIWithCustomT.java │ ├── BasicTestConfiguration.java │ └── BasicWithCustomTestConfiguration.java │ └── repositories │ ├── RepositoriesIT.java │ ├── RepositoriesTestAggregateRoot.java │ └── RepositoriesTestConfiguration.java ├── axon-spring-boot-testing ├── pom.xml └── src │ └── main │ ├── java │ └── hm │ │ └── binkley │ │ └── spring │ │ └── axon │ │ ├── WorkAroundJavadoc.java │ │ └── package-info.java │ └── resources │ ├── application.yml │ └── logback-test.xml ├── maven-version-rules.xml └── pom.xml /.gitignore: -------------------------------------------------------------------------------- 1 | /.idea 2 | /*.out 3 | target 4 | *.iml 5 | -------------------------------------------------------------------------------- /.mvn/jvm.config: -------------------------------------------------------------------------------- 1 | -Dorg.slf4j.simpleLogger.defaultLogLevel=warn 2 | -Dmaven.logging.root.level=warn 3 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | # Force newer JDK - compiler busted in _31 -- see - https://github.com/travis-ci/travis-ci/issues/3259 3 | addons: 4 | apt: 5 | packages: 6 | - oracle-java8-installer 7 | language: java 8 | jdk: 9 | - oraclejdk8 10 | # TODO: Gross until Travis support setting maven version or upgrades to 3.3 11 | before_install: 12 | - wget http://www.us.apache.org/dist/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz 13 | - tar zxvf apache-maven-3.3.9-bin.tar.gz 14 | - chmod +x apache-maven-3.3.9/bin/mvn 15 | - export M2_HOME=$PWD/apache-maven-3.3.9 16 | - export PATH=$PWD/apache-maven-3.3.9/bin:${PATH} 17 | - hash -r 18 | install: mvn install -Dmaven.javadoc.skip=true -DskipTests=true -DskipITs=true -Dgpg.skip=true 19 | before_script: 20 | - export M2_HOME=$PWD/apache-maven-3.3.9 21 | - export PATH=$PWD/apache-maven-3.3.9/bin:${PATH} 22 | - hash -r 23 | script: mvn verify -Dgpg.skip=true 24 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to Contribute 2 | 3 | ## Getting Started 4 | 5 | * Make sure you have a [GitHub account](https://github.com/signup/free). 6 | * Submit a ticket for your issue, assuming one does not already exist. 7 | * Clearly describe the issue including steps to reproduce when it is a bug. 8 | * Make sure you fill in the earliest version that you know has the issue. 9 | * Fork the repository on GitHub. 10 | * Add yourself to the `` block in `pom.xml` with the role, 11 | "contributor". 12 | * Use of gitflow is encouraged. 13 | 14 | ## Making Changes 15 | 16 | * All commits must be releasable, always. Avoid partial commits of your tree. 17 | Send patches to others rather than push a non-releasable commit. 18 | * Work on the `master` branch. Exceptions: 19 | * Use release branches if the fix applies there. Always cherry pick fixes 20 | to `master` if relevant. 21 | * Do not push local feature branches into the repo without group consensus. 22 | * When possible reference a Github Issue in your commit message. 23 | * Close issues in Github using [a commit 24 | message](https://help.github.com/articles/closing-issues-via-commit-messages/) 25 | (NB--"Fixes #1", not "Fixed #1"). 26 | 27 | ## Code Style 28 | 29 | * Lines are 80 characters maximum. Exceptions: 30 | * Long import lines are OK to avoid awkward wrapping. 31 | * Ensure all changes use UNIX file endings and UTF-8 encoding, and that only 32 | scripts have an execute bit (source files are not executable). 33 | * Use [standard Java code 34 | style](http://www.oracle.com/technetwork/java/codeconvtoc-136057.html). 35 | You know it when you see it. Exceptions: 36 | * For empty classes and methods, it is OK to collapse the curly braces 37 | rather than put them on separate lines. 38 | * For block syntax, it is OK to leave out optional curly braces if the 39 | meaning of the code does not change, such as in a for-each loop with a 40 | single line of action on the current iteration element. 41 | * For `extends` and `implements`, it is OK to break the line early. If you 42 | do so, indent is 8 characters, ala standard Java style. 43 | * Check for unnecessary whitespace with `git diff --check` before committing. 44 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # License # 2 | 3 | This is free and unencumbered software released into the public domain. 4 | 5 | Anyone is free to copy, modify, publish, use, compile, sell, or 6 | distribute this software, either in source code form or as a compiled 7 | binary, for any purpose, commercial or non-commercial, and by any 8 | means. 9 | 10 | In jurisdictions that recognize copyright laws, the author or authors 11 | of this software dedicate any and all copyright interest in the 12 | software to the public domain. We make this dedication for the benefit 13 | of the public at large and to the detriment of our heirs and 14 | successors. We intend this dedication to be an overt act of 15 | relinquishment in perpetuity of all present and future rights to this 16 | software under copyright law. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 21 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 22 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 23 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 24 | OTHER DEALINGS IN THE SOFTWARE. 25 | 26 | For more information, please refer to . 27 | 28 | The source code is available at: . 29 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Spring Boot Starter for Axon Framework 2 | 3 | This software is in the Public Domain. Please see [LICENSE.md](LICENSE.md). 4 | 5 | [![License](https://img.shields.io/badge/license-PD-blue.svg)](http://unlicense.org) 6 | [![Build Status](https://img.shields.io/travis/binkley/spring-boot-starter-axon.svg)](https://travis-ci.org/binkley/spring-boot-starter-axon) 7 | [![Issues](https://img.shields.io/github/issues/binkley/spring-boot-starter-axon.svg)](https://github.com/binkley/spring-boot-starter-axon/issues) 8 | [![maven-central](https://img.shields.io/maven-central/v/hm.binkley/spring-boot-starter-axon.svg)](https://search.maven.org/#search%7Cga%7C1%7Cg%3A%22hm.binkley%22%20AND%20a%3A%22spring-boot-starter-axon%22) 9 | 10 | I no longer maintain this repo but keep it for reference for other. 11 | 12 | ## Acknowledgment 13 | 14 | This project is heavily indebted to: 15 | 16 | * [Lieven Doclo](https://github.com/lievendoclo/axon-spring-boot) 17 | * [Christopher Elkins](https://github.com/esha/spring-boot-starter-axon) 18 | * [Tom Soete](https://github.com/tomsoete/spring-boot-starter-axon) 19 | 20 | ## Features 21 | 22 | * Autoconfiguration driven with [standard `@EnableAutoConfiguration` and 23 | `META-INF/spring.factories`](https://docs.spring.io/spring-boot/docs/current/reference/html/using-boot-auto-configuration.html). 24 | Include the jar in your classpath and add the annotation to a 25 | configuration class. 26 | * Autoconfigure `CommandBus` and `EventBus` with default 27 | implementations. In particular, your configuration must define a bean 28 | for `EventStore`: there are too many strategies for event stores for 29 | autoconfiguration to pick a default one for you. 30 | * Autoconfigure aggregate root repositories marked with 31 | `@MetaInfServices`. The matching repository bean is the aggregate 32 | bean name appended with "Repository" ("fooRoot" becomes 33 | "fooRootRepository"). These generate entries in 34 | `/META-INF/services/org.axonframework.eventsourcing.annotation.AbstractAnnotatedAggregateRoot`. 35 | Note you *must* annotate injected repository fields with 36 | `@Qualified(name-of-repostiroy)` because of limitations in Spring's 37 | support for generics. 38 | * Autoconfiguration for event bus clusters. 39 | * Autoconfiguration for JGroups distributed command bus. 40 | * Autoconfiguration for event processing monitors. 41 | * Autoconfiguration for Spring Messaging event cluster. 42 | * Autoconfiguration for command dispatch and handler interceptors. 43 | * Autoconfiguration for audit and monitoring. 44 | 45 | ## Minimal Example 46 | 47 | ### Read-side configuration 48 | 49 | Include `axon-spring-boot-starter-query` in your dependencies. 50 | 51 | ``` 52 | @Configuration 53 | @EnableAutoConfiguration 54 | public class AConfiguration {} 55 | ``` 56 | 57 | ### Write-side configuration 58 | 59 | Include `axon-spring-boot-starter` in your dependencies. 60 | 61 | ``` 62 | @Configuration 63 | @EnableAutoConfiguration 64 | public class AConfiguration { 65 | @Bean 66 | public EventStore eventStore() { 67 | return ...; 68 | } 69 | } 70 | ``` 71 | 72 | ### Aggregate root and repository 73 | 74 | Include `axon-spring-boot-starter` in your dependencies. 75 | 76 | ``` 77 | @MetaInfServices 78 | public class SomeAggregateRoot 79 | extends AbstractAnnotatedAggregateRoot { 80 | @AggregateIdentifier 81 | private SomeIDType id; 82 | } 83 | ``` 84 | 85 | ``` 86 | @Component 87 | public final class SomeClassUsingRespository { 88 | @Autowired 89 | @Qualifier("someAggregateRootRepository") 90 | private Repository repository; 91 | } 92 | ``` 93 | 94 | ### JGroups command bus 95 | 96 | Include `axon-spring-boot-starter-distributed-commandbus` in your 97 | dependencies. 98 | 99 | ``` 100 | @Configuration 101 | @EnableAutoConfiguration 102 | public class AConfiguration { 103 | @Bean 104 | public EventStore eventStore() { 105 | return ...; 106 | } 107 | } 108 | ``` 109 | 110 | In your `application.yaml`: 111 | 112 | ``` 113 | axon: 114 | jgroups: 115 | cluster-name: TEST 116 | ``` 117 | 118 | And include a suitable `jgroups-config.xml` in your classpath. 119 | 120 | ### Command dispatch interceptors 121 | 122 | ``` 123 | @Order(1) 124 | public class ADispatchInterceptor implements CommandDispatchInterceptor { 125 | // ... 126 | } 127 | ``` 128 | 129 | Exposed as a bean, such interceptors are invoked in order. 130 | 131 | ### Command handler interceptors 132 | 133 | ``` 134 | @Order(1) 135 | public class AHandlerInterceptor implements CommandHandlerInterceptor { 136 | // ... 137 | } 138 | ``` 139 | 140 | Exposed as a bean, such interceptors are invoked in order. 141 | 142 | ### Event processing monitor 143 | 144 | Include `axon-spring-boot-starter-clustering-eventbus` in your dependencies. 145 | 146 | _Note_: all monitors subscribe to all clusters in the Spring context. 147 | 148 | ``` 149 | @Component 150 | public final class SomeEventProcessingMonitor 151 | implements EventProcessingMonitor { 152 | @Override 153 | public void onEventProcessingCompleted( 154 | final List eventMessages) { 155 | } 156 | 157 | @Override 158 | public void onEventProcessingFailed( 159 | final List eventMessages, 160 | final Throwable cause) { 161 | } 162 | } 163 | ``` 164 | 165 | ### Spring messaging 166 | 167 | Include `axon-spring-boot-start-springmessaging` in your dependencies. 168 | 169 | ``` 170 | @Configuration 171 | @EnableAutoConfiguration 172 | public class AConfiguration { 173 | @Bean 174 | public SubscribableChannel subscribableChannel() { 175 | return ...; 176 | } 177 | } 178 | ``` 179 | 180 | A typical implementation uses JMS (`spring-jms` dependency). 181 | 182 | ### Spring Boot auditing 183 | 184 | ``` 185 | @Configuration 186 | @EnableAutoConfiguration 187 | public class AConfiguration { 188 | @Bean 189 | public AuditEventRepository auditEventRepository() { 190 | return ...; 191 | } 192 | } 193 | ``` 194 | 195 | Include `axon-spring-boot-start-monitoring` in your dependencies. Both 196 | commands and events are audited through Spring Boot. 197 | 198 | ## Releases 199 | 200 | ### 5 201 | 202 | * Autoconfiguration of command dispatch and handler interceptors 203 | * Flow of metadata from initial command through consequences 204 | 205 | ### 4 206 | 207 | * Event processing monitor automation. 208 | * Spring Messaging support. 209 | 210 | ### 3 211 | 212 | * Read-side (query) uses autoconfiguration as well as write-side. 213 | * Clustering event bus starter. 214 | 215 | ### 2 216 | 217 | * Renamed project and modules to meet Spring Boot 3rd-party naming 218 | guidelines. So spring-boot-axon-starter becomes 219 | axon-spring-boot-starter. Apologies committers and cloners. Better 220 | now than later. 221 | 222 | ### 1 223 | 224 | * Break project into multi-module reactor build. Separate axon starters 225 | in separate modules. 226 | * Support JGroups distriuted command bus. 227 | 228 | ### 0 229 | 230 | * Basic functionality, single project, simple defaults for Axon 231 | components 232 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-clustering-eventbus/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | 6 | hm.binkley 7 | axon-spring-boot-starter-parent 8 | 5 9 | 10 | 11 | axon-spring-boot-starter-clustering-eventbus 12 | 13 | Spring Boot/Axon Starter - Clustered Event Bus 14 | 15 | 16 | 17 | ${project.groupId} 18 | axon-spring-boot-starter-query 19 | 20 | 21 | org.springframework.boot 22 | spring-boot-configuration-processor 23 | 24 | 25 | ${project.groupId} 26 | axon-spring-boot-testing 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-clustering-eventbus/src/main/java/hm/binkley/spring/axon/AxonClusterAutoConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free and unencumbered software released into the public domain. 3 | * 4 | * Anyone is free to copy, modify, publish, use, compile, sell, or 5 | * distribute this software, either in source code form or as a compiled 6 | * binary, for any purpose, commercial or non-commercial, and by any 7 | * means. 8 | * 9 | * In jurisdictions that recognize copyright laws, the author or authors 10 | * of this software dedicate any and all copyright interest in the 11 | * software to the public domain. We make this dedication for the benefit 12 | * of the public at large and to the detriment of our heirs and 13 | * successors. We intend this dedication to be an overt act of 14 | * relinquishment in perpetuity of all present and future rights to this 15 | * software under copyright law. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | * 25 | * For more information, please refer to . 26 | */ 27 | 28 | package hm.binkley.spring.axon; 29 | 30 | import hm.binkley.spring.axon.AxonClusterAutoConfiguration 31 | .AxonClusterProperties; 32 | import lombok.Data; 33 | import org.axonframework.eventhandling.Cluster; 34 | import org.axonframework.eventhandling.ClusterSelector; 35 | import org.axonframework.eventhandling.ClusteringEventBus; 36 | import org.axonframework.eventhandling.DefaultClusterSelector; 37 | import org.axonframework.eventhandling.EventBus; 38 | import org.axonframework.eventhandling.EventBusTerminal; 39 | import org.axonframework.eventhandling.OrderResolver; 40 | import org.axonframework.eventhandling.SimpleCluster; 41 | import org.axonframework.eventhandling.SpringAnnotationOrderResolver; 42 | import org.springframework.beans.factory.annotation.Autowired; 43 | import org.springframework.boot.autoconfigure.AutoConfigureBefore; 44 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 45 | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; 46 | import org.springframework.boot.autoconfigure.condition 47 | .ConditionalOnMissingBean; 48 | import org.springframework.boot.context.properties.ConfigurationProperties; 49 | import org.springframework.boot.context.properties 50 | .EnableConfigurationProperties; 51 | import org.springframework.context.annotation.Bean; 52 | import org.springframework.context.annotation.Configuration; 53 | 54 | /** 55 | * {@code AxonClusterAutoConfiguration} autoconfigures Axon Framework for 56 | * Spring Boot to use event bus clustering. Use {@link 57 | * EnableAutoConfiguration} on your configuration class. 58 | *

59 | * A minimal configuration is:

   @Configuration
 60 |  * @EnableAutoConfiguration
 61 |  * public class AConfiguration {}
In other classes inject Axon types 62 | * normally with {@code @Autowired}. 63 | *

64 | * Configure the cluster name with the axon.cluster.name 65 | * property or in YAML:

    axon:
 66 |  *   cluster:
 67 |  *     name: TEST
68 | * 69 | * @author B. K. Oxley (binkley) 70 | */ 71 | @AutoConfigureBefore(AxonQueryAutoConfiguration.class) 72 | @ConditionalOnClass(Cluster.class) 73 | @Configuration 74 | @EnableConfigurationProperties(AxonClusterProperties.class) 75 | public class AxonClusterAutoConfiguration { 76 | @Autowired 77 | private AxonClusterProperties properties; 78 | 79 | @Bean 80 | @ConditionalOnMissingBean 81 | public OrderResolver orderResolver() { 82 | return new SpringAnnotationOrderResolver(); 83 | } 84 | 85 | @Bean 86 | @ConditionalOnMissingBean 87 | public Cluster simpleCluster(final OrderResolver orderResolver) { 88 | return new SimpleCluster(properties.getName(), orderResolver); 89 | } 90 | 91 | @Bean 92 | @ConditionalOnMissingBean 93 | public ClusterSelector defaultClusterSelector(final Cluster cluster) { 94 | return new DefaultClusterSelector(cluster); 95 | } 96 | 97 | @Bean 98 | @ConditionalOnMissingBean 99 | public EventBusTerminal simpleEventBusTerminal() { 100 | return new SimpleEventBusTerminal(); 101 | } 102 | 103 | @Bean 104 | @ConditionalOnMissingBean 105 | public EventBus clusteringEventBus(final ClusterSelector selecter, 106 | final EventBusTerminal terminal) { 107 | return new ClusteringEventBus(selecter, terminal); 108 | } 109 | 110 | @ConfigurationProperties("axon.cluster") 111 | @Data 112 | public static final class AxonClusterProperties { 113 | private String name; 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-clustering-eventbus/src/main/java/hm/binkley/spring/axon/EventProcessingMonitorAutomation.java: -------------------------------------------------------------------------------- 1 | package hm.binkley.spring.axon; 2 | 3 | import org.axonframework.eventhandling.Cluster; 4 | import org.axonframework.eventhandling.EventProcessingMonitor; 5 | import org.springframework.context.ApplicationListener; 6 | import org.springframework.context.ConfigurableApplicationContext; 7 | import org.springframework.context.event.ContextRefreshedEvent; 8 | 9 | import java.util.Collection; 10 | 11 | import static org.springframework.beans.factory.BeanFactoryUtils 12 | .beansOfTypeIncludingAncestors; 13 | 14 | public class EventProcessingMonitorAutomation 15 | implements ApplicationListener { 16 | @Override 17 | public void onApplicationEvent(final ContextRefreshedEvent event) { 18 | final ConfigurableApplicationContext context 19 | = (ConfigurableApplicationContext) event.getSource(); 20 | final Collection monitors 21 | = beansOfTypeIncludingAncestors(context.getBeanFactory(), 22 | EventProcessingMonitor.class).values(); 23 | 24 | for (final Cluster cluster : beansOfTypeIncludingAncestors( 25 | context.getBeanFactory(), Cluster.class).values()) 26 | monitors.forEach(cluster::subscribeEventProcessingMonitor); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-clustering-eventbus/src/main/java/hm/binkley/spring/axon/SimpleEventBusTerminal.java: -------------------------------------------------------------------------------- 1 | package hm.binkley.spring.axon; 2 | 3 | import org.axonframework.domain.EventMessage; 4 | import org.axonframework.eventhandling.Cluster; 5 | import org.axonframework.eventhandling.ClusteringEventBus; 6 | import org.axonframework.eventhandling.EventBusTerminal; 7 | 8 | import java.util.List; 9 | import java.util.concurrent.CopyOnWriteArrayList; 10 | 11 | /** 12 | * {@code SimpleEventBusTerminal} is an explicit copy from {@link 13 | * ClusteringEventBus} which is marked {@code private}, so that 14 | * autoconfiguration can expose an {@link EventBusTerminal} bean to be 15 | * conditionally replaced. 16 | * 17 | * @author B. K. Oxley (binkley) 18 | * @todo Why private in Axon Framework? This may be automated! 19 | */ 20 | public class SimpleEventBusTerminal 21 | implements EventBusTerminal { 22 | private final List clusters = new CopyOnWriteArrayList<>(); 23 | 24 | @Override 25 | public void publish(final EventMessage... events) { 26 | for (final Cluster cluster : clusters) 27 | cluster.publish(events); 28 | } 29 | 30 | @Override 31 | public void onClusterCreated(final Cluster cluster) { 32 | clusters.add(cluster); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-clustering-eventbus/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ 2 | hm.binkley.spring.axon.AxonClusterAutoConfiguration 3 | org.springframework.context.ApplicationListener=\ 4 | hm.binkley.spring.axon.EventProcessingMonitorAutomation 5 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-clustering-eventbus/src/test/java/hm/binkley/spring/axon/audit/MonitoringIT.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free and unencumbered software released into the public domain. 3 | * 4 | * Anyone is free to copy, modify, publish, use, compile, sell, or 5 | * distribute this software, either in source code form or as a compiled 6 | * binary, for any purpose, commercial or non-commercial, and by any 7 | * means. 8 | * 9 | * In jurisdictions that recognize copyright laws, the author or authors 10 | * of this software dedicate any and all copyright interest in the 11 | * software to the public domain. We make this dedication for the benefit 12 | * of the public at large and to the detriment of our heirs and 13 | * successors. We intend this dedication to be an overt act of 14 | * relinquishment in perpetuity of all present and future rights to this 15 | * software under copyright law. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | * 25 | * For more information, please refer to . 26 | */ 27 | 28 | package hm.binkley.spring.axon.audit; 29 | 30 | import hm.binkley.spring.axon.audit.MonitoringTestConfiguration 31 | .Processed; 32 | import hm.binkley.spring.axon.audit.MonitoringTestConfiguration 33 | .TestEvent; 34 | import org.axonframework.domain.GenericDomainEventMessage; 35 | import org.axonframework.eventhandling.EventBus; 36 | import org.junit.After; 37 | import org.junit.Test; 38 | import org.junit.runner.RunWith; 39 | import org.springframework.beans.factory.annotation.Autowired; 40 | import org.springframework.boot.test.SpringApplicationConfiguration; 41 | import org.springframework.test.annotation.DirtiesContext; 42 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 43 | 44 | import static org.assertj.core.api.Assertions.assertThat; 45 | 46 | @DirtiesContext 47 | @RunWith(SpringJUnit4ClassRunner.class) 48 | @SpringApplicationConfiguration(classes = MonitoringTestConfiguration.class) 49 | public final class MonitoringIT { 50 | @Autowired 51 | private EventBus eventBus; 52 | @Autowired 53 | private TestEventProcessingMonitor monitor; 54 | 55 | @After 56 | public void resetMonitor() { 57 | monitor.processed.clear(); 58 | } 59 | 60 | @Test 61 | public void shouldMonitorForCompletedEventPublishing() { 62 | final TestEvent payload = new TestEvent(null); 63 | eventBus.publish(new GenericDomainEventMessage<>("abc", 1L, payload)); 64 | 65 | final Processed processed = monitor.processed.get(0); 66 | assertThat(processed.cause).isEqualTo(null); 67 | assertThat(processed.messages).hasSize(1); 68 | assertThat(processed.messages.get(0).getPayload()). 69 | isEqualTo(payload); 70 | } 71 | 72 | @Test 73 | public void shouldMonitorForFailedEventPublishing() { 74 | final TestException fail = new TestException(); 75 | final TestEvent payload = new TestEvent(fail); 76 | try { 77 | eventBus.publish( 78 | new GenericDomainEventMessage<>("abc", 1L, payload)); 79 | } catch (final TestException ignored) {} 80 | 81 | final Processed processed = monitor.processed.get(0); 82 | assertThat(processed.cause).isEqualTo(fail); 83 | assertThat(processed.messages).hasSize(1); 84 | assertThat(processed.messages.get(0).getPayload()). 85 | isEqualTo(payload); 86 | } 87 | 88 | public static final class TestException 89 | extends RuntimeException {} 90 | } 91 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-clustering-eventbus/src/test/java/hm/binkley/spring/axon/audit/MonitoringTestConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free and unencumbered software released into the public domain. 3 | * 4 | * Anyone is free to copy, modify, publish, use, compile, sell, or 5 | * distribute this software, either in source code form or as a compiled 6 | * binary, for any purpose, commercial or non-commercial, and by any 7 | * means. 8 | * 9 | * In jurisdictions that recognize copyright laws, the author or authors 10 | * of this software dedicate any and all copyright interest in the 11 | * software to the public domain. We make this dedication for the benefit 12 | * of the public at large and to the detriment of our heirs and 13 | * successors. We intend this dedication to be an overt act of 14 | * relinquishment in perpetuity of all present and future rights to this 15 | * software under copyright law. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | * 25 | * For more information, please refer to . 26 | */ 27 | 28 | package hm.binkley.spring.axon.audit; 29 | 30 | import lombok.EqualsAndHashCode; 31 | import lombok.RequiredArgsConstructor; 32 | import lombok.ToString; 33 | import org.axonframework.domain.EventMessage; 34 | import org.axonframework.eventhandling.annotation.EventHandler; 35 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 36 | import org.springframework.context.annotation.Bean; 37 | import org.springframework.context.annotation.Configuration; 38 | 39 | import java.util.List; 40 | 41 | @Configuration 42 | @EnableAutoConfiguration 43 | public class MonitoringTestConfiguration { 44 | @Bean 45 | public TestEventProcessingMonitor testEventProcessingMonitor() { 46 | return new TestEventProcessingMonitor(); 47 | } 48 | 49 | @Bean 50 | public Handler testHandler() { 51 | return new Handler(); 52 | } 53 | 54 | @RequiredArgsConstructor 55 | static final class Processed { 56 | public final List messages; 57 | public final Throwable cause; 58 | } 59 | 60 | @EqualsAndHashCode 61 | @RequiredArgsConstructor 62 | @ToString 63 | static final class TestEvent { 64 | private final Exception fail; 65 | } 66 | 67 | private static class Handler { 68 | @EventHandler 69 | void handle(final TestEvent event) 70 | throws Exception { 71 | if (null != event.fail) 72 | throw event.fail; 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-clustering-eventbus/src/test/java/hm/binkley/spring/axon/audit/TestEventProcessingMonitor.java: -------------------------------------------------------------------------------- 1 | package hm.binkley.spring.axon.audit; 2 | 3 | import hm.binkley.spring.axon.audit.MonitoringTestConfiguration 4 | .Processed; 5 | import org.axonframework.domain.EventMessage; 6 | import org.axonframework.eventhandling.EventProcessingMonitor; 7 | 8 | import java.util.ArrayList; 9 | import java.util.List; 10 | 11 | final class TestEventProcessingMonitor 12 | implements EventProcessingMonitor { 13 | final List processed = new ArrayList<>(); 14 | 15 | @Override 16 | public void onEventProcessingCompleted( 17 | final List eventMessages) { 18 | processed.add(new Processed((List) eventMessages, null)); 19 | } 20 | 21 | @Override 22 | public void onEventProcessingFailed( 23 | final List eventMessages, 24 | final Throwable cause) { 25 | processed.add(new Processed((List) eventMessages, cause)); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-clustering-eventbus/src/test/java/hm/binkley/spring/axon/query/ClusterIT.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free and unencumbered software released into the public domain. 3 | * 4 | * Anyone is free to copy, modify, publish, use, compile, sell, or 5 | * distribute this software, either in source code form or as a compiled 6 | * binary, for any purpose, commercial or non-commercial, and by any 7 | * means. 8 | * 9 | * In jurisdictions that recognize copyright laws, the author or authors 10 | * of this software dedicate any and all copyright interest in the 11 | * software to the public domain. We make this dedication for the benefit 12 | * of the public at large and to the detriment of our heirs and 13 | * successors. We intend this dedication to be an overt act of 14 | * relinquishment in perpetuity of all present and future rights to this 15 | * software under copyright law. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | * 25 | * For more information, please refer to . 26 | */ 27 | 28 | package hm.binkley.spring.axon.query; 29 | 30 | import org.axonframework.eventhandling.ClusteringEventBus; 31 | import org.axonframework.eventhandling.EventBus; 32 | import org.junit.Test; 33 | import org.junit.runner.RunWith; 34 | import org.springframework.beans.factory.annotation.Autowired; 35 | import org.springframework.boot.test.SpringApplicationConfiguration; 36 | import org.springframework.test.annotation.DirtiesContext; 37 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 38 | 39 | import static org.assertj.core.api.Assertions.assertThat; 40 | 41 | @DirtiesContext 42 | @RunWith(SpringJUnit4ClassRunner.class) 43 | @SpringApplicationConfiguration(classes = ClusterTestConfiguration.class) 44 | public final class ClusterIT { 45 | @Autowired 46 | private EventBus eventBus; 47 | 48 | @Test 49 | public void shouldWireClusteringEventBus() { 50 | assertThat(eventBus).isInstanceOf(ClusteringEventBus.class); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-clustering-eventbus/src/test/java/hm/binkley/spring/axon/query/ClusterIWithCustomT.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free and unencumbered software released into the public domain. 3 | * 4 | * Anyone is free to copy, modify, publish, use, compile, sell, or 5 | * distribute this software, either in source code form or as a compiled 6 | * binary, for any purpose, commercial or non-commercial, and by any 7 | * means. 8 | * 9 | * In jurisdictions that recognize copyright laws, the author or authors 10 | * of this software dedicate any and all copyright interest in the 11 | * software to the public domain. We make this dedication for the benefit 12 | * of the public at large and to the detriment of our heirs and 13 | * successors. We intend this dedication to be an overt act of 14 | * relinquishment in perpetuity of all present and future rights to this 15 | * software under copyright law. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | * 25 | * For more information, please refer to . 26 | */ 27 | 28 | package hm.binkley.spring.axon.query; 29 | 30 | import hm.binkley.spring.axon.query.ClusterWithCustomTestConfiguration 31 | .CustomClusteringEventBus; 32 | import org.axonframework.eventhandling.EventBus; 33 | import org.junit.Test; 34 | import org.junit.runner.RunWith; 35 | import org.springframework.beans.factory.annotation.Autowired; 36 | import org.springframework.boot.test.SpringApplicationConfiguration; 37 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 38 | 39 | import static org.assertj.core.api.Assertions.assertThat; 40 | 41 | @SpringApplicationConfiguration( 42 | classes = ClusterWithCustomTestConfiguration.class) 43 | @RunWith(SpringJUnit4ClassRunner.class) 44 | public final class ClusterIWithCustomT { 45 | @Autowired 46 | private EventBus eventBus; 47 | 48 | @Test 49 | public void shouldWireCustomEventBus() { 50 | assertThat(eventBus).isInstanceOf(CustomClusteringEventBus.class); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-clustering-eventbus/src/test/java/hm/binkley/spring/axon/query/ClusterTestConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free and unencumbered software released into the public domain. 3 | * 4 | * Anyone is free to copy, modify, publish, use, compile, sell, or 5 | * distribute this software, either in source code form or as a compiled 6 | * binary, for any purpose, commercial or non-commercial, and by any 7 | * means. 8 | * 9 | * In jurisdictions that recognize copyright laws, the author or authors 10 | * of this software dedicate any and all copyright interest in the 11 | * software to the public domain. We make this dedication for the benefit 12 | * of the public at large and to the detriment of our heirs and 13 | * successors. We intend this dedication to be an overt act of 14 | * relinquishment in perpetuity of all present and future rights to this 15 | * software under copyright law. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | * 25 | * For more information, please refer to . 26 | */ 27 | 28 | package hm.binkley.spring.axon.query; 29 | 30 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 31 | import org.springframework.context.annotation.Configuration; 32 | 33 | @Configuration 34 | @EnableAutoConfiguration 35 | public class ClusterTestConfiguration {} 36 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-clustering-eventbus/src/test/java/hm/binkley/spring/axon/query/ClusterWithCustomTestConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free and unencumbered software released into the public domain. 3 | * 4 | * Anyone is free to copy, modify, publish, use, compile, sell, or 5 | * distribute this software, either in source code form or as a compiled 6 | * binary, for any purpose, commercial or non-commercial, and by any 7 | * means. 8 | * 9 | * In jurisdictions that recognize copyright laws, the author or authors 10 | * of this software dedicate any and all copyright interest in the 11 | * software to the public domain. We make this dedication for the benefit 12 | * of the public at large and to the detriment of our heirs and 13 | * successors. We intend this dedication to be an overt act of 14 | * relinquishment in perpetuity of all present and future rights to this 15 | * software under copyright law. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | * 25 | * For more information, please refer to . 26 | */ 27 | 28 | package hm.binkley.spring.axon.query; 29 | 30 | import org.axonframework.eventhandling.ClusterSelector; 31 | import org.axonframework.eventhandling.ClusteringEventBus; 32 | import org.axonframework.eventhandling.EventBus; 33 | import org.axonframework.eventhandling.EventBusTerminal; 34 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 35 | import org.springframework.context.annotation.Bean; 36 | import org.springframework.context.annotation.Configuration; 37 | 38 | @Configuration 39 | @EnableAutoConfiguration 40 | public class ClusterWithCustomTestConfiguration { 41 | @Bean 42 | public EventBus customClusterEventBus(final ClusterSelector selector, 43 | final EventBusTerminal terminal) { 44 | return new CustomClusteringEventBus(selector, terminal); 45 | } 46 | 47 | static final class CustomClusteringEventBus 48 | extends ClusteringEventBus { 49 | CustomClusteringEventBus(final ClusterSelector selector, 50 | final EventBusTerminal terminal) { 51 | super(selector, terminal); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-clustering-eventbus/src/test/resources/application.yml: -------------------------------------------------------------------------------- 1 | axon: 2 | cluster: 3 | name: TEST 4 | 5 | spring: 6 | main: 7 | show-banner: false 8 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-distributed-commandbus/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | 6 | hm.binkley 7 | axon-spring-boot-starter-parent 8 | 5 9 | 10 | 11 | axon-spring-boot-starter-distributed-commandbus 12 | 13 | Spring Boot/Axon Starter - JGroups Command Bus 14 | 15 | 16 | 17 | org.springframework.boot 18 | spring-boot-configuration-processor 19 | 20 | 21 | ${project.groupId} 22 | axon-spring-boot-starter 23 | 24 | 25 | org.axonframework 26 | axon-distributed-commandbus 27 | 28 | 29 | org.jgroups 30 | jgroups 31 | 32 | 33 | ${project.groupId} 34 | axon-spring-boot-testing 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-distributed-commandbus/src/main/java/hm/binkley/spring/axon/AxonDistributedCommandBusAutoConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free and unencumbered software released into the public domain. 3 | * 4 | * Anyone is free to copy, modify, publish, use, compile, sell, or 5 | * distribute this software, either in source code form or as a compiled 6 | * binary, for any purpose, commercial or non-commercial, and by any 7 | * means. 8 | * 9 | * In jurisdictions that recognize copyright laws, the author or authors 10 | * of this software dedicate any and all copyright interest in the 11 | * software to the public domain. We make this dedication for the benefit 12 | * of the public at large and to the detriment of our heirs and 13 | * successors. We intend this dedication to be an overt act of 14 | * relinquishment in perpetuity of all present and future rights to this 15 | * software under copyright law. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | * 25 | * For more information, please refer to . 26 | */ 27 | 28 | package hm.binkley.spring.axon; 29 | 30 | import hm.binkley.spring.axon.AxonDistributedCommandBusAutoConfiguration 31 | .AxonDistributedCommandBusProperties; 32 | import lombok.Getter; 33 | import lombok.Setter; 34 | import org.axonframework.commandhandling.CommandBus; 35 | import org.axonframework.commandhandling.SimpleCommandBus; 36 | import org.axonframework.commandhandling.distributed.DistributedCommandBus; 37 | import org.axonframework.commandhandling.distributed.jgroups.JGroupsConnector; 38 | import org.axonframework.eventstore.EventStore; 39 | import org.axonframework.serializer.Serializer; 40 | import org.axonframework.serializer.xml.XStreamSerializer; 41 | import org.jgroups.JChannel; 42 | import org.springframework.beans.factory.annotation.Autowired; 43 | import org.springframework.beans.factory.annotation.Qualifier; 44 | import org.springframework.boot.autoconfigure.AutoConfigureBefore; 45 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 46 | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; 47 | import org.springframework.boot.autoconfigure.condition 48 | .ConditionalOnMissingBean; 49 | import org.springframework.boot.context.properties.ConfigurationProperties; 50 | import org.springframework.boot.context.properties 51 | .EnableConfigurationProperties; 52 | import org.springframework.context.annotation.Bean; 53 | import org.springframework.context.annotation.Configuration; 54 | import org.springframework.context.annotation.Primary; 55 | import org.springframework.core.io.Resource; 56 | 57 | /** 58 | * {@code AxonDistributedCommandBusAutoConfiguration} autoconfigures Axon 59 | * Framework for Spring Boot with a distributed command bus using JGroups. Use 60 | * {@link EnableAutoConfiguration} on your configuration class, and define a 61 | * bean for {@link EventStore} (see {@link AxonAutoConfiguration} for 62 | * details). Then define application properties for JGroups:
   axon:
 63 |  *   jgroups:
 64 |  *     cluster-name: test
 65 |  *     configuration: classpath:/my-config.xml  # Optional
66 | * Autoconfiguration defaults to XML serialization for JGroups. 67 | * 68 | * @author B. K. Oxley (binkley) 69 | * @see AxonAutoConfiguration 70 | */ 71 | @AutoConfigureBefore(AxonAutoConfiguration.class) 72 | @ConditionalOnClass(CommandBus.class) 73 | @Configuration 74 | @EnableConfigurationProperties(AxonDistributedCommandBusProperties.class) 75 | public class AxonDistributedCommandBusAutoConfiguration { 76 | @Autowired 77 | private AxonDistributedCommandBusProperties properties; 78 | 79 | @Bean 80 | @ConditionalOnMissingBean 81 | public JChannel jChannel() 82 | throws Exception { 83 | final Resource configuration = properties.getConfiguration(); 84 | return null == configuration ? new JChannel() 85 | : new JChannel(configuration.getFile()); 86 | } 87 | 88 | @Bean 89 | @ConditionalOnMissingBean 90 | public CommandBus localSegmentCommandBus() { 91 | return new SimpleCommandBus(); 92 | } 93 | 94 | @Bean 95 | @ConditionalOnMissingBean 96 | public Serializer serializer() { 97 | return new XStreamSerializer(); 98 | } 99 | 100 | @Bean 101 | @ConditionalOnMissingBean 102 | public JGroupsConnector jGroupsConnector(final JChannel channel, 103 | @Qualifier("localSegmentCommandBus") final CommandBus commandBus, 104 | final Serializer serializer) { 105 | return new JGroupsConnector(channel, properties.getClusterName(), 106 | commandBus, serializer); 107 | } 108 | 109 | @Bean 110 | @ConditionalOnMissingBean 111 | @Primary 112 | public DistributedCommandBus distributedCommandBus( 113 | final JGroupsConnector connector) { 114 | return new DistributedCommandBus(connector); 115 | } 116 | 117 | @ConfigurationProperties("axon.jgroups") 118 | @Getter 119 | @Setter 120 | public static class AxonDistributedCommandBusProperties { 121 | /** The JGroups cluster name. */ 122 | private String clusterName; 123 | /** 124 | * The Spring resource path to JGroups XML configuration, optioanl. 125 | */ 126 | private Resource configuration; 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-distributed-commandbus/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ 2 | hm.binkley.spring.axon.AxonDistributedCommandBusAutoConfiguration 3 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-distributed-commandbus/src/test/java/hm/binkley/spring/axon/jgroups/DistributedIT.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free and unencumbered software released into the public domain. 3 | * 4 | * Anyone is free to copy, modify, publish, use, compile, sell, or 5 | * distribute this software, either in source code form or as a compiled 6 | * binary, for any purpose, commercial or non-commercial, and by any 7 | * means. 8 | * 9 | * In jurisdictions that recognize copyright laws, the author or authors 10 | * of this software dedicate any and all copyright interest in the 11 | * software to the public domain. We make this dedication for the benefit 12 | * of the public at large and to the detriment of our heirs and 13 | * successors. We intend this dedication to be an overt act of 14 | * relinquishment in perpetuity of all present and future rights to this 15 | * software under copyright law. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | * 25 | * For more information, please refer to . 26 | */ 27 | 28 | package hm.binkley.spring.axon.jgroups; 29 | 30 | import org.axonframework.commandhandling.CommandBus; 31 | import org.axonframework.commandhandling.distributed.DistributedCommandBus; 32 | import org.junit.Test; 33 | import org.junit.runner.RunWith; 34 | import org.springframework.beans.factory.annotation.Autowired; 35 | import org.springframework.boot.test.SpringApplicationConfiguration; 36 | import org.springframework.test.annotation.DirtiesContext; 37 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 38 | 39 | import static org.assertj.core.api.Assertions.assertThat; 40 | 41 | @DirtiesContext 42 | @RunWith(SpringJUnit4ClassRunner.class) 43 | @SpringApplicationConfiguration(classes = DistributedTestConfiguration.class) 44 | public final class DistributedIT { 45 | @Autowired 46 | private CommandBus commandBus; 47 | 48 | @Test 49 | public void shouldWireDistributedCommandBus() { 50 | assertThat(commandBus).isInstanceOf(DistributedCommandBus.class); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-distributed-commandbus/src/test/java/hm/binkley/spring/axon/jgroups/DistributedTestConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free and unencumbered software released into the public domain. 3 | * 4 | * Anyone is free to copy, modify, publish, use, compile, sell, or 5 | * distribute this software, either in source code form or as a compiled 6 | * binary, for any purpose, commercial or non-commercial, and by any 7 | * means. 8 | * 9 | * In jurisdictions that recognize copyright laws, the author or authors 10 | * of this software dedicate any and all copyright interest in the 11 | * software to the public domain. We make this dedication for the benefit 12 | * of the public at large and to the detriment of our heirs and 13 | * successors. We intend this dedication to be an overt act of 14 | * relinquishment in perpetuity of all present and future rights to this 15 | * software under copyright law. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | * 25 | * For more information, please refer to . 26 | */ 27 | 28 | package hm.binkley.spring.axon.jgroups; 29 | 30 | import org.axonframework.eventstore.EventStore; 31 | import org.axonframework.eventstore.supporting.VolatileEventStore; 32 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 33 | import org.springframework.context.annotation.Bean; 34 | import org.springframework.context.annotation.Configuration; 35 | 36 | @Configuration 37 | @EnableAutoConfiguration 38 | public class DistributedTestConfiguration { 39 | @Bean 40 | public EventStore eventStore() { 41 | return new VolatileEventStore(); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-distributed-commandbus/src/test/resources/application.yml: -------------------------------------------------------------------------------- 1 | axon: 2 | jgroups: 3 | cluster-name: TEST 4 | 5 | spring: 6 | main: 7 | show-banner: false 8 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-distributed-commandbus/src/test/resources/jgroups-config.xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/binkley/axon-spring-boot-starter/84764163899cc25b6b2513cb064afea904ed26f5/axon-spring-boot-starter-distributed-commandbus/src/test/resources/jgroups-config.xml -------------------------------------------------------------------------------- /axon-spring-boot-starter-monitoring/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | 6 | hm.binkley 7 | axon-spring-boot-starter-parent 8 | 5 9 | 10 | 11 | axon-spring-boot-starter-monitoring 12 | 13 | Spring Boot/Axon Starter - Monitoring 14 | 15 | 16 | 17 | ${project.groupId} 18 | axon-spring-boot-starter 19 | 20 | 21 | ${project.groupId} 22 | axon-spring-boot-starter-clustering-eventbus 23 | 24 | 25 | 26 | org.axonframework 27 | axon-monitoring-jmx 28 | ${axon.version} 29 | 30 | 31 | org.springframework.boot 32 | spring-boot-starter-web 33 | 34 | 35 | ${project.groupId} 36 | axon-spring-boot-testing 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-monitoring/src/main/java/hm/binkley/spring/axon/AxonAuditEvent.java: -------------------------------------------------------------------------------- 1 | package hm.binkley.spring.axon; 2 | 3 | import org.springframework.boot.actuate.audit.listener.AuditApplicationEvent; 4 | 5 | import java.util.Date; 6 | import java.util.Map; 7 | 8 | /** 9 | * {@code AxonAuditEvent} is a base Spring application audit event for Axon. 10 | * 11 | * @author B. K. Oxley (binkley) 12 | */ 13 | public abstract class AxonAuditEvent 14 | extends AuditApplicationEvent { 15 | protected AxonAuditEvent(final String principal, final String type, 16 | final Map data) { 17 | super(principal, type, data); 18 | } 19 | 20 | protected AxonAuditEvent(final String principal, final String type, 21 | final String... data) { 22 | super(principal, type, data); 23 | } 24 | 25 | protected AxonAuditEvent(final Date timestamp, final String principal, 26 | final String type, final Map data) { 27 | super(timestamp, principal, type, data); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-monitoring/src/main/java/hm/binkley/spring/axon/AxonCommandAuditEvent.java: -------------------------------------------------------------------------------- 1 | package hm.binkley.spring.axon; 2 | 3 | import org.axonframework.commandhandling.CommandMessage; 4 | 5 | import java.util.Date; 6 | import java.util.Map; 7 | 8 | /** 9 | * {@code AxonCommandAuditEvent} is a Spring application audit event for Axon 10 | * commands.. 11 | * 12 | * @author B. K. Oxley (binkley) 13 | */ 14 | public class AxonCommandAuditEvent 15 | extends AxonAuditEvent { 16 | public static final String AXON_COMMAND_AUDIT_TYPE = CommandMessage.class 17 | .getName(); 18 | 19 | public AxonCommandAuditEvent(final String principal, 20 | final Map data) { 21 | super(principal, AXON_COMMAND_AUDIT_TYPE, data); 22 | } 23 | 24 | public AxonCommandAuditEvent(final String principal, 25 | final String... data) { 26 | super(principal, AXON_COMMAND_AUDIT_TYPE, data); 27 | } 28 | 29 | public AxonCommandAuditEvent(final Date timestamp, final String principal, 30 | final Map data) { 31 | super(timestamp, principal, AXON_COMMAND_AUDIT_TYPE, data); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-monitoring/src/main/java/hm/binkley/spring/axon/AxonEventAuditEvent.java: -------------------------------------------------------------------------------- 1 | package hm.binkley.spring.axon; 2 | 3 | import org.axonframework.domain.EventMessage; 4 | 5 | import java.util.Date; 6 | import java.util.Map; 7 | 8 | /** 9 | * {@code AxonEventAuditEvent} is a Spring application audit event for Axon 10 | * events.. 11 | * 12 | * @author B. K. Oxley (binkley) 13 | */ 14 | public class AxonEventAuditEvent 15 | extends AxonAuditEvent { 16 | public static final String AXON_EVENT_AUDIT_TYPE = EventMessage.class 17 | .getName(); 18 | 19 | public AxonEventAuditEvent(final String principal, 20 | final Map data) { 21 | super(principal, AXON_EVENT_AUDIT_TYPE, data); 22 | } 23 | 24 | public AxonEventAuditEvent(final String principal, final String... data) { 25 | super(principal, EventMessage.class.getName(), data); 26 | } 27 | 28 | public AxonEventAuditEvent(final Date timestamp, final String principal, 29 | final Map data) { 30 | super(timestamp, principal, EventMessage.class.getName(), data); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-monitoring/src/main/java/hm/binkley/spring/axon/AxonMonitoringAutoConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free and unencumbered software released into the public domain. 3 | * 4 | * Anyone is free to copy, modify, publish, use, compile, sell, or 5 | * distribute this software, either in source code form or as a compiled 6 | * binary, for any purpose, commercial or non-commercial, and by any 7 | * means. 8 | * 9 | * In jurisdictions that recognize copyright laws, the author or authors 10 | * of this software dedicate any and all copyright interest in the 11 | * software to the public domain. We make this dedication for the benefit 12 | * of the public at large and to the detriment of our heirs and 13 | * successors. We intend this dedication to be an overt act of 14 | * relinquishment in perpetuity of all present and future rights to this 15 | * software under copyright law. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | * 25 | * For more information, please refer to . 26 | */ 27 | 28 | package hm.binkley.spring.axon; 29 | 30 | import org.axonframework.auditing.AuditLogger; 31 | import org.axonframework.auditing.AuditingInterceptor; 32 | import org.axonframework.commandhandling.CommandBus; 33 | import org.axonframework.eventstore.EventStore; 34 | import org.springframework.boot.actuate.audit.AuditEventRepository; 35 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 36 | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; 37 | import org.springframework.boot.autoconfigure.condition 38 | .ConditionalOnMissingBean; 39 | import org.springframework.context.annotation.Bean; 40 | import org.springframework.context.annotation.Configuration; 41 | 42 | /** 43 | * {@code AxonSpringMessagingAutoConfiguration} autoconfigures Axon Framework 44 | * for Spring Boot for monitoring. Use {@link EnableAutoConfiguration} on 45 | * your configuration class, and define beans for {@link EventStore} and 46 | * {@link AuditEventRepository}. A minimal configuration is: 47 | *
@Configuration
48 |  * @EnableAutoConfiguration
49 |  * public class AConfiguration {
50 |  *     @Bean
51 |  *     public {@link EventStore} eventStore() {
52 |  *         return ...;
53 |  *     }
54 |  *
55 |  *     @Bean
56 |  *     public {@link AuditEventRepository} auditEventRepository() {
57 |  *         return ...;
58 |  *     }
59 |  * }
In other classes inject Axon types 60 | * normally with {@code @Autowired}. 61 | * 62 | * @author B. K. Oxley (binkley) 63 | */ 64 | @ConditionalOnClass(CommandBus.class) 65 | @Configuration 66 | public class AxonMonitoringAutoConfiguration { 67 | @Bean 68 | @ConditionalOnMissingBean 69 | public AuditingInterceptor auditingInterceptor( 70 | final MessageAuditDataProvider provider, 71 | final AuditLogger logger) { 72 | final AuditingInterceptor interceptor = new AuditingInterceptor(); 73 | interceptor.setAuditDataProvider(provider.asAuditDataProvider()); 74 | interceptor.setAuditLogger(logger); 75 | return interceptor; 76 | } 77 | 78 | @Bean 79 | @ConditionalOnMissingBean 80 | public MessageAuditDataProvider messageAuditDataProvider() { 81 | return new MessageMetaDataProvider(); 82 | } 83 | 84 | @Bean 85 | @ConditionalOnMissingBean 86 | public AuditLogger auditLogger(final MessageAuditDataProvider provider) { 87 | return new SpringBootAuditLogger(provider); 88 | } 89 | 90 | @Bean 91 | @ConditionalOnMissingBean 92 | public CorrelationDataCommandDispatchInterceptor 93 | correlationDataCommandDispatchInterceptor() { 94 | return new CorrelationDataCommandDispatchInterceptor(); 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-monitoring/src/main/java/hm/binkley/spring/axon/CorrelationDataCommandDispatchInterceptor.java: -------------------------------------------------------------------------------- 1 | package hm.binkley.spring.axon; 2 | 3 | import org.axonframework.commandhandling.CommandDispatchInterceptor; 4 | import org.axonframework.commandhandling.CommandMessage; 5 | import org.springframework.core.annotation.Order; 6 | 7 | import static org.axonframework.correlation.CorrelationDataHolder.getCorrelationData; 8 | import static org.axonframework.correlation.CorrelationDataHolder.setCorrelationData; 9 | import static org.springframework.core.Ordered.HIGHEST_PRECEDENCE; 10 | 11 | /** 12 | * {@code CorrelationDataCommandDispatchInterceptor} needs 13 | * documentation. 14 | * 15 | * @author B. K. Oxley (binkley) 16 | * @todo Needs documentation 17 | */ 18 | @Order(HIGHEST_PRECEDENCE) 19 | public class CorrelationDataCommandDispatchInterceptor 20 | implements CommandDispatchInterceptor { 21 | @Override 22 | public CommandMessage handle(final CommandMessage commandMessage) { 23 | if (getCorrelationData().isEmpty()) { 24 | setCorrelationData(commandMessage.getMetaData()); 25 | return commandMessage; 26 | } else 27 | return commandMessage.andMetaData(getCorrelationData()); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-monitoring/src/main/java/hm/binkley/spring/axon/DuplicateAuditKeyException.java: -------------------------------------------------------------------------------- 1 | package hm.binkley.spring.axon; 2 | 3 | /** 4 | * {@code DuplicateAuditKeyException} is thrown when copying metadata if a 5 | * user-supplied metadata key duplicates already used. 6 | * 7 | * @author B. K. Oxley (binkley) 8 | * @todo Rethink this exception 9 | * @see SpringBootAuditLogger#EVENTS 10 | * @see SpringBootAuditLogger#FAILURE_CAUSE 11 | * @see SpringBootAuditLogger#MESSAGE_TYPE 12 | * @see SpringBootAuditLogger#RETURN_VALUE 13 | */ 14 | public final class DuplicateAuditKeyException 15 | extends RuntimeException { 16 | DuplicateAuditKeyException(final String key) { 17 | super("Duplicate audit key: " + key); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-monitoring/src/main/java/hm/binkley/spring/axon/MessageAuditDataProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2014. Axon Framework 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hm.binkley.spring.axon; 18 | 19 | import org.axonframework.auditing.AuditDataProvider; 20 | import org.axonframework.domain.Message; 21 | 22 | import java.util.Map; 23 | 24 | /** 25 | * {@code MessageAuditDataProvider} is a look-a-like for {@link 26 | * AuditDataProvider} but more generally for messages rather than only command 27 | * messages. 28 | * 29 | * @author B. K. Oxley (binkley) 30 | */ 31 | public interface MessageAuditDataProvider { 32 | /** 33 | * Return the relevant auditing information for the given message. This 34 | * method is called exactly once for each time the message is dispatched 35 | * (commands) or processed (events). 36 | * 37 | * @param message The message being dispatched, never missing 38 | * 39 | * @return a map containing key-value pairs of relevant information to 40 | * include in audit logs, never missing 41 | */ 42 | Map provideAuditDataFor(final Message message); 43 | 44 | /** 45 | * Shim method to coerce this interface into an {@link 46 | * AuditDataProvider}. 47 | * 48 | * @return this interface, never missing 49 | */ 50 | default AuditDataProvider asAuditDataProvider() { 51 | return this::provideAuditDataFor; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-monitoring/src/main/java/hm/binkley/spring/axon/MessageMetaDataProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2014. Axon Framework 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hm.binkley.spring.axon; 18 | 19 | import org.axonframework.domain.Message; 20 | 21 | import java.util.Map; 22 | 23 | /** 24 | * {@code MessageMetaDataProvider} uses a message's metadata for audit. 25 | * 26 | * @author B. K. Oxley (binkley) 27 | */ 28 | public class MessageMetaDataProvider 29 | implements MessageAuditDataProvider { 30 | @Override 31 | public Map provideAuditDataFor(final Message command) { 32 | return command.getMetaData(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-monitoring/src/main/java/hm/binkley/spring/axon/SpringBootAuditLogger.java: -------------------------------------------------------------------------------- 1 | package hm.binkley.spring.axon; 2 | 3 | import lombok.RequiredArgsConstructor; 4 | import lombok.Setter; 5 | import org.axonframework.auditing.AuditLogger; 6 | import org.axonframework.commandhandling.CommandMessage; 7 | import org.axonframework.domain.EventMessage; 8 | import org.axonframework.domain.Message; 9 | import org.axonframework.eventhandling.EventProcessingMonitor; 10 | import org.springframework.context.ApplicationEventPublisher; 11 | import org.springframework.context.ApplicationEventPublisherAware; 12 | 13 | import java.util.LinkedHashMap; 14 | import java.util.List; 15 | import java.util.Map; 16 | 17 | import static org.axonframework.auditing.CorrelationAuditDataProvider 18 | .DEFAULT_CORRELATION_KEY; 19 | 20 | @RequiredArgsConstructor 21 | public class SpringBootAuditLogger 22 | implements AuditLogger, EventProcessingMonitor, 23 | ApplicationEventPublisherAware { 24 | public static final String PARENT_CORRELATION_ID = inNamespace( 25 | "parent-correlation-id"); 26 | public static final String MESSAGE_TYPE = inNamespace("message-type"); 27 | public static final String RETURN_VALUE = inNamespace("return-value"); 28 | public static final String FAILURE_CAUSE = inNamespace("failure-cause"); 29 | public static final String EVENTS = inNamespace("events"); 30 | 31 | private final MessageAuditDataProvider provider; 32 | @Setter 33 | private ApplicationEventPublisher applicationEventPublisher; 34 | 35 | @Override 36 | public void logSuccessful(final CommandMessage command, 37 | final Object returnValue, final List events) { 38 | applicationEventPublisher.publishEvent(new AxonCommandAuditEvent(null, 39 | successfulCommand(provider, command, returnValue, events))); 40 | } 41 | 42 | @Override 43 | public void logFailed(final CommandMessage command, 44 | final Throwable failureCause, final List events) { 45 | applicationEventPublisher.publishEvent(new AxonCommandAuditEvent(null, 46 | failedCommand(provider, command, failureCause, events))); 47 | } 48 | 49 | @Override 50 | public void onEventProcessingCompleted( 51 | final List eventMessages) { 52 | for (final EventMessage event : eventMessages) 53 | applicationEventPublisher.publishEvent( 54 | new AxonEventAuditEvent(null, 55 | successfulEvent(provider, event))); 56 | } 57 | 58 | @Override 59 | public void onEventProcessingFailed( 60 | final List eventMessages, 61 | final Throwable cause) { 62 | for (final EventMessage event : eventMessages) 63 | applicationEventPublisher.publishEvent( 64 | new AxonEventAuditEvent(null, 65 | failedEvent(provider, event, cause))); 66 | } 67 | 68 | private static String inNamespace(final String key) { 69 | return SpringBootAuditLogger.class.getName() + ':' + key; 70 | } 71 | 72 | private static Map successfulCommand( 73 | final MessageAuditDataProvider provider, 74 | final CommandMessage command, final Object returnValue, 75 | final List events) { 76 | return auditData(provider, command, command.getCommandName(), 77 | returnValue, null, events); 78 | } 79 | 80 | private static Map successfulEvent( 81 | final MessageAuditDataProvider provider, 82 | final EventMessage event) { 83 | return auditData(provider, event, event.getPayloadType().getName(), 84 | null, null, null); 85 | } 86 | 87 | private static Map failedCommand( 88 | final MessageAuditDataProvider provider, 89 | final CommandMessage command, final Throwable failureCause, 90 | final List events) { 91 | return auditData(provider, command, command.getCommandName(), null, 92 | failureCause, events); 93 | } 94 | 95 | private static Map failedEvent( 96 | final MessageAuditDataProvider provider, final EventMessage event, 97 | final Throwable failureCause) { 98 | return auditData(provider, event, event.getPayloadType().getName(), 99 | null, failureCause, null); 100 | } 101 | 102 | private static Map auditData( 103 | final MessageAuditDataProvider provider, final Message message, 104 | final String name, final Object returnValue, 105 | final Throwable failureCause, final List events) { 106 | final Map map = new LinkedHashMap<>(); 107 | map.putAll(provider.provideAuditDataFor(message)); 108 | map.put(DEFAULT_CORRELATION_KEY, message.getIdentifier()); 109 | map.put(MESSAGE_TYPE, name); 110 | map.put(RETURN_VALUE, returnValue); 111 | map.put(FAILURE_CAUSE, failureCause); 112 | map.put(EVENTS, events); 113 | return map; 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-monitoring/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ 2 | hm.binkley.spring.axon.AxonMonitoringAutoConfiguration 3 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-monitoring/src/test/java/hm/binkley/spring/axon/audit/AuditIT.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free and unencumbered software released into the public domain. 3 | * 4 | * Anyone is free to copy, modify, publish, use, compile, sell, or 5 | * distribute this software, either in source code form or as a compiled 6 | * binary, for any purpose, commercial or non-commercial, and by any 7 | * means. 8 | * 9 | * In jurisdictions that recognize copyright laws, the author or authors 10 | * of this software dedicate any and all copyright interest in the 11 | * software to the public domain. We make this dedication for the benefit 12 | * of the public at large and to the detriment of our heirs and 13 | * successors. We intend this dedication to be an overt act of 14 | * relinquishment in perpetuity of all present and future rights to this 15 | * software under copyright law. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | * 25 | * For more information, please refer to . 26 | */ 27 | 28 | package hm.binkley.spring.axon.audit; 29 | 30 | import hm.binkley.spring.axon.shared.TestAuditEventRepository; 31 | import org.axonframework.commandhandling.gateway.CommandGateway; 32 | import org.axonframework.domain.GenericDomainEventMessage; 33 | import org.axonframework.eventhandling.Cluster; 34 | import org.junit.After; 35 | import org.junit.Test; 36 | import org.junit.runner.RunWith; 37 | import org.springframework.beans.factory.annotation.Autowired; 38 | import org.springframework.boot.actuate.audit.AuditEvent; 39 | import org.springframework.boot.test.SpringApplicationConfiguration; 40 | import org.springframework.test.annotation.DirtiesContext; 41 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 42 | 43 | import java.util.Map; 44 | 45 | import static hm.binkley.spring.axon.AxonCommandAuditEvent.AXON_COMMAND_AUDIT_TYPE; 46 | import static hm.binkley.spring.axon.AxonEventAuditEvent.AXON_EVENT_AUDIT_TYPE; 47 | import static hm.binkley.spring.axon.SpringBootAuditLogger.FAILURE_CAUSE; 48 | import static hm.binkley.spring.axon.SpringBootAuditLogger.MESSAGE_TYPE; 49 | import static hm.binkley.spring.axon.SpringBootAuditLogger.RETURN_VALUE; 50 | import static org.assertj.core.api.Assertions.assertThat; 51 | import static org.junit.Assert.fail; 52 | 53 | @DirtiesContext 54 | @RunWith(SpringJUnit4ClassRunner.class) 55 | @SpringApplicationConfiguration(classes = AuditTestConfiguration.class) 56 | public final class AuditIT { 57 | @Autowired 58 | private CommandGateway commands; 59 | @Autowired 60 | private Cluster events; 61 | @Autowired 62 | private TestAuditEventRepository trail; 63 | 64 | @After 65 | public void resetTrail() { 66 | trail.reset(); 67 | } 68 | 69 | @Test 70 | public void shouldAuditSuccessfulCommands() { 71 | final SuccessfulCommand payload = new SuccessfulCommand(); 72 | commands.send(payload); 73 | 74 | assertThat(trail.received()). 75 | isEqualTo(1); 76 | final AuditEvent auditEvent = trail.eventAt(0); 77 | assertThat(auditEvent.getType()). 78 | isEqualTo(AXON_COMMAND_AUDIT_TYPE); 79 | final Map data = auditEvent.getData(); 80 | assertThat(data.get(MESSAGE_TYPE)). 81 | isEqualTo(payload.getClass().getName()); 82 | assertThat(data.get(RETURN_VALUE)). 83 | isEqualTo(3); 84 | assertThat(data.get(FAILURE_CAUSE)). 85 | isNull(); 86 | } 87 | 88 | @Test 89 | public void shouldAuditFailedCommands() { 90 | final FailedException cause = new FailedException(); 91 | final FailedCommand payload = new FailedCommand(cause); 92 | commands.send(payload); 93 | 94 | assertThat(trail.received()). 95 | isEqualTo(1); 96 | final AuditEvent auditEvent = trail.eventAt(0); 97 | assertThat(auditEvent.getType()). 98 | isEqualTo(AXON_COMMAND_AUDIT_TYPE); 99 | final Map data = auditEvent.getData(); 100 | assertThat(data.get(MESSAGE_TYPE)). 101 | isEqualTo(payload.getClass().getName()); 102 | assertThat(data.get(RETURN_VALUE)). 103 | isNull(); 104 | assertThat(data.get(FAILURE_CAUSE)). 105 | isSameAs(cause); 106 | } 107 | 108 | @Test 109 | public void shouldAuditSuccessfulEvents() { 110 | final SuccessfulEvent payload = new SuccessfulEvent(); 111 | events.publish(new GenericDomainEventMessage<>("abc", 1L, payload)); 112 | 113 | assertThat(trail.received()). 114 | isEqualTo(1); 115 | final AuditEvent auditEvent = trail.eventAt(0); 116 | assertThat(auditEvent.getType()). 117 | isEqualTo(AXON_EVENT_AUDIT_TYPE); 118 | final Map data = auditEvent.getData(); 119 | assertThat(data.get(MESSAGE_TYPE)). 120 | isEqualTo(payload.getClass().getName()); 121 | assertThat(data.get(FAILURE_CAUSE)). 122 | isNull(); 123 | } 124 | 125 | @Test 126 | public void shouldAuditFailedEvents() { 127 | final FailedException cause = new FailedException(); 128 | final FailedEvent payload = new FailedEvent(cause); 129 | try { 130 | events.publish( 131 | new GenericDomainEventMessage<>("abc", 1L, payload)); 132 | fail(); 133 | } catch (final FailedException ignored) { 134 | assertThat(trail.received()). 135 | isEqualTo(1); 136 | final AuditEvent auditEvent = trail.eventAt(0); 137 | assertThat(auditEvent.getType()). 138 | isEqualTo(AXON_EVENT_AUDIT_TYPE); 139 | final Map data = auditEvent.getData(); 140 | assertThat(data.get(MESSAGE_TYPE)). 141 | isEqualTo(payload.getClass().getName()); 142 | assertThat(data.get(FAILURE_CAUSE)). 143 | isSameAs(cause); 144 | } 145 | } 146 | } 147 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-monitoring/src/test/java/hm/binkley/spring/axon/audit/AuditTestConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free and unencumbered software released into the public domain. 3 | * 4 | * Anyone is free to copy, modify, publish, use, compile, sell, or 5 | * distribute this software, either in source code form or as a compiled 6 | * binary, for any purpose, commercial or non-commercial, and by any 7 | * means. 8 | * 9 | * In jurisdictions that recognize copyright laws, the author or authors 10 | * of this software dedicate any and all copyright interest in the 11 | * software to the public domain. We make this dedication for the benefit 12 | * of the public at large and to the detriment of our heirs and 13 | * successors. We intend this dedication to be an overt act of 14 | * relinquishment in perpetuity of all present and future rights to this 15 | * software under copyright law. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | * 25 | * For more information, please refer to . 26 | */ 27 | 28 | package hm.binkley.spring.axon.audit; 29 | 30 | import hm.binkley.spring.axon.shared.TestAuditEventRepository; 31 | import org.axonframework.eventstore.EventStore; 32 | import org.axonframework.eventstore.supporting.VolatileEventStore; 33 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 34 | import org.springframework.context.annotation.Bean; 35 | import org.springframework.context.annotation.Configuration; 36 | 37 | @Configuration 38 | @EnableAutoConfiguration 39 | public class AuditTestConfiguration { 40 | @Bean 41 | public EventStore eventStore() { 42 | return new VolatileEventStore(); 43 | } 44 | 45 | @Bean 46 | public TestAuditEventRepository testAuditEventRepository() { 47 | return new TestAuditEventRepository(); 48 | } 49 | 50 | @Bean 51 | public SuccessfulCommandHandler successfulCommandHandler() { 52 | return new SuccessfulCommandHandler(); 53 | } 54 | 55 | @Bean 56 | public FailedCommandHandler failedCommandHandler() { 57 | return new FailedCommandHandler(); 58 | } 59 | 60 | @Bean 61 | public SuccessfulEventHandler successfulEventHandler() { 62 | return new SuccessfulEventHandler(); 63 | } 64 | 65 | @Bean 66 | public FailedEventHandler failedEventHandler() { 67 | return new FailedEventHandler(); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-monitoring/src/test/java/hm/binkley/spring/axon/audit/FailedCommand.java: -------------------------------------------------------------------------------- 1 | package hm.binkley.spring.axon.audit; 2 | 3 | import lombok.RequiredArgsConstructor; 4 | 5 | @RequiredArgsConstructor 6 | public final class FailedCommand { 7 | final FailedException cause; 8 | } 9 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-monitoring/src/test/java/hm/binkley/spring/axon/audit/FailedCommandHandler.java: -------------------------------------------------------------------------------- 1 | package hm.binkley.spring.axon.audit; 2 | 3 | import org.axonframework.commandhandling.annotation.CommandHandler; 4 | 5 | public class FailedCommandHandler { 6 | @CommandHandler 7 | public Object handle(final FailedCommand command) { 8 | throw command.cause; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-monitoring/src/test/java/hm/binkley/spring/axon/audit/FailedEvent.java: -------------------------------------------------------------------------------- 1 | package hm.binkley.spring.axon.audit; 2 | 3 | import lombok.RequiredArgsConstructor; 4 | 5 | @RequiredArgsConstructor 6 | public final class FailedEvent { 7 | final FailedException cause; 8 | } 9 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-monitoring/src/test/java/hm/binkley/spring/axon/audit/FailedEventHandler.java: -------------------------------------------------------------------------------- 1 | package hm.binkley.spring.axon.audit; 2 | 3 | import org.axonframework.eventhandling.annotation.EventHandler; 4 | 5 | public class FailedEventHandler { 6 | @EventHandler 7 | public void handle(final FailedEvent event) { 8 | throw event.cause; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-monitoring/src/test/java/hm/binkley/spring/axon/audit/FailedException.java: -------------------------------------------------------------------------------- 1 | package hm.binkley.spring.axon.audit; 2 | 3 | public final class FailedException 4 | extends RuntimeException {} 5 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-monitoring/src/test/java/hm/binkley/spring/axon/audit/SuccessfulCommand.java: -------------------------------------------------------------------------------- 1 | package hm.binkley.spring.axon.audit; 2 | 3 | public final class SuccessfulCommand {} 4 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-monitoring/src/test/java/hm/binkley/spring/axon/audit/SuccessfulCommandHandler.java: -------------------------------------------------------------------------------- 1 | package hm.binkley.spring.axon.audit; 2 | 3 | import org.axonframework.commandhandling.annotation.CommandHandler; 4 | 5 | public class SuccessfulCommandHandler { 6 | @CommandHandler 7 | public Object handle(final SuccessfulCommand command) { 8 | return 3; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-monitoring/src/test/java/hm/binkley/spring/axon/audit/SuccessfulEvent.java: -------------------------------------------------------------------------------- 1 | package hm.binkley.spring.axon.audit; 2 | 3 | public final class SuccessfulEvent {} 4 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-monitoring/src/test/java/hm/binkley/spring/axon/audit/SuccessfulEventHandler.java: -------------------------------------------------------------------------------- 1 | package hm.binkley.spring.axon.audit; 2 | 3 | import org.axonframework.eventhandling.annotation.EventHandler; 4 | 5 | public class SuccessfulEventHandler { 6 | @EventHandler 7 | public void handle(final SuccessfulEvent Event) {} 8 | } 9 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-monitoring/src/test/java/hm/binkley/spring/axon/flow/FlowIT.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free and unencumbered software released into the public domain. 3 | * 4 | * Anyone is free to copy, modify, publish, use, compile, sell, or 5 | * distribute this software, either in source code form or as a compiled 6 | * binary, for any purpose, commercial or non-commercial, and by any 7 | * means. 8 | * 9 | * In jurisdictions that recognize copyright laws, the author or authors 10 | * of this software dedicate any and all copyright interest in the 11 | * software to the public domain. We make this dedication for the benefit 12 | * of the public at large and to the detriment of our heirs and 13 | * successors. We intend this dedication to be an overt act of 14 | * relinquishment in perpetuity of all present and future rights to this 15 | * software under copyright law. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | * 25 | * For more information, please refer to . 26 | */ 27 | 28 | package hm.binkley.spring.axon.flow; 29 | 30 | import hm.binkley.spring.axon.shared.TestAuditEventRepository; 31 | import org.axonframework.commandhandling.GenericCommandMessage; 32 | import org.axonframework.commandhandling.gateway.CommandGateway; 33 | import org.junit.After; 34 | import org.junit.Test; 35 | import org.junit.runner.RunWith; 36 | import org.springframework.beans.factory.annotation.Autowired; 37 | import org.springframework.boot.actuate.audit.AuditEvent; 38 | import org.springframework.boot.test.SpringApplicationConfiguration; 39 | import org.springframework.test.annotation.DirtiesContext; 40 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 41 | 42 | import java.util.Map; 43 | 44 | import static hm.binkley.spring.axon.AxonCommandAuditEvent 45 | .AXON_COMMAND_AUDIT_TYPE; 46 | import static hm.binkley.spring.axon.AxonEventAuditEvent 47 | .AXON_EVENT_AUDIT_TYPE; 48 | import static hm.binkley.spring.axon.SpringBootAuditLogger.MESSAGE_TYPE; 49 | import static java.util.Collections.singletonMap; 50 | import static org.assertj.core.api.Assertions.assertThat; 51 | import static org.axonframework.correlation.CorrelationDataHolder 52 | .getCorrelationData; 53 | 54 | @DirtiesContext 55 | @RunWith(SpringJUnit4ClassRunner.class) 56 | @SpringApplicationConfiguration(classes = FlowTestConfiguration.class) 57 | public final class FlowIT { 58 | @Autowired 59 | private CommandGateway commands; 60 | @Autowired 61 | private TestAuditEventRepository trail; 62 | 63 | @After 64 | public void resetTrail() { 65 | trail.reset(); 66 | } 67 | 68 | @Test 69 | public void shouldAuditCommandToEventToCommand() { 70 | final String aggregateId = "abc"; 71 | final InitialCommand payload = new InitialCommand(aggregateId); 72 | commands.send(payload); 73 | 74 | assertThat(trail.received()). 75 | isEqualTo(3); 76 | 77 | final AuditEvent initialCommandAuditEvent = trail.eventAt(2); 78 | assertThat(initialCommandAuditEvent.getType()). 79 | isEqualTo(AXON_COMMAND_AUDIT_TYPE); 80 | final Map initialCommandData 81 | = initialCommandAuditEvent.getData(); 82 | assertThat(initialCommandData.get(MESSAGE_TYPE)). 83 | isEqualTo(InitialCommand.class.getName()); 84 | 85 | final AuditEvent initialEventAuditEvent = trail.eventAt(1); 86 | assertThat(initialEventAuditEvent.getType()). 87 | isEqualTo(AXON_EVENT_AUDIT_TYPE); 88 | final Map initialEventData = initialEventAuditEvent 89 | .getData(); 90 | assertThat(initialEventData.get(MESSAGE_TYPE)). 91 | isEqualTo(InitialEvent.class.getName()); 92 | 93 | final AuditEvent terminalCommandAuditEvent = trail.eventAt(0); 94 | assertThat(terminalCommandAuditEvent.getType()). 95 | isEqualTo(AXON_COMMAND_AUDIT_TYPE); 96 | final Map terminalCommandData 97 | = terminalCommandAuditEvent.getData(); 98 | assertThat(terminalCommandData.get(MESSAGE_TYPE)). 99 | isEqualTo(TerminalCommand.class.getName()); 100 | } 101 | 102 | @Test 103 | public void shouldPassMetaDataCommandToEventToCommand() { 104 | commands.send(new GenericCommandMessage<>(new InitialCommand("abc"), 105 | singletonMap("mumble", 3))); 106 | 107 | final Map initialCommandData = trail.eventAt(2) 108 | .getData(); 109 | assertThat(initialCommandData.get("mumble")). 110 | isEqualTo(3); 111 | 112 | final Map initialEventData = trail.eventAt(1) 113 | .getData(); 114 | assertThat(initialEventData.get("mumble")). 115 | isEqualTo(3); 116 | 117 | final Map terminalCommandData = trail.eventAt(0) 118 | .getData(); 119 | assertThat(terminalCommandData.get("mumble")). 120 | isEqualTo(3); 121 | } 122 | 123 | @Test 124 | public void shouldReleaseThreadLocalWhenDone() { 125 | commands.send(new InitialCommand("abc")); 126 | 127 | assertThat(getCorrelationData()). 128 | isEmpty(); 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-monitoring/src/test/java/hm/binkley/spring/axon/flow/FlowTestConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free and unencumbered software released into the public domain. 3 | * 4 | * Anyone is free to copy, modify, publish, use, compile, sell, or 5 | * distribute this software, either in source code form or as a compiled 6 | * binary, for any purpose, commercial or non-commercial, and by any 7 | * means. 8 | * 9 | * In jurisdictions that recognize copyright laws, the author or authors 10 | * of this software dedicate any and all copyright interest in the 11 | * software to the public domain. We make this dedication for the benefit 12 | * of the public at large and to the detriment of our heirs and 13 | * successors. We intend this dedication to be an overt act of 14 | * relinquishment in perpetuity of all present and future rights to this 15 | * software under copyright law. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | * 25 | * For more information, please refer to . 26 | */ 27 | 28 | package hm.binkley.spring.axon.flow; 29 | 30 | import hm.binkley.spring.axon.shared.TestAuditEventRepository; 31 | import org.axonframework.commandhandling.gateway.CommandGateway; 32 | import org.axonframework.eventstore.EventStore; 33 | import org.axonframework.eventstore.supporting.VolatileEventStore; 34 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 35 | import org.springframework.context.annotation.Bean; 36 | import org.springframework.context.annotation.Configuration; 37 | 38 | @Configuration 39 | @EnableAutoConfiguration 40 | public class FlowTestConfiguration { 41 | @Bean 42 | public EventStore eventStore() { 43 | return new VolatileEventStore(); 44 | } 45 | 46 | @Bean 47 | public TestAuditEventRepository testAuditEventRepository() { 48 | return new TestAuditEventRepository(); 49 | } 50 | 51 | @Bean 52 | public InitialEventHandler successfulEventHandler( 53 | final CommandGateway commands) { 54 | return new InitialEventHandler(commands); 55 | } 56 | 57 | @Bean 58 | public TerminalCommandHandler terminalCommandHandler() { 59 | return new TerminalCommandHandler(); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-monitoring/src/test/java/hm/binkley/spring/axon/flow/InitialAggregateRoot.java: -------------------------------------------------------------------------------- 1 | package hm.binkley.spring.axon.flow; 2 | 3 | import lombok.NoArgsConstructor; 4 | import org.axonframework.commandhandling.annotation.CommandHandler; 5 | import org.axonframework.eventsourcing.annotation.AbstractAnnotatedAggregateRoot; 6 | import org.axonframework.eventsourcing.annotation.AggregateIdentifier; 7 | import org.kohsuke.MetaInfServices; 8 | 9 | @MetaInfServices 10 | @NoArgsConstructor 11 | public final class InitialAggregateRoot 12 | extends AbstractAnnotatedAggregateRoot { 13 | @AggregateIdentifier 14 | private String id; 15 | 16 | @CommandHandler 17 | public InitialAggregateRoot(final InitialCommand command) { 18 | id = command.getId(); 19 | apply(new InitialEvent(command.getId())); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-monitoring/src/test/java/hm/binkley/spring/axon/flow/InitialCommand.java: -------------------------------------------------------------------------------- 1 | package hm.binkley.spring.axon.flow; 2 | 3 | import lombok.Value; 4 | 5 | @Value 6 | public class InitialCommand { 7 | private final String id; 8 | } 9 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-monitoring/src/test/java/hm/binkley/spring/axon/flow/InitialEvent.java: -------------------------------------------------------------------------------- 1 | package hm.binkley.spring.axon.flow; 2 | 3 | import lombok.Value; 4 | 5 | @Value 6 | public class InitialEvent { 7 | private final String id; 8 | } 9 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-monitoring/src/test/java/hm/binkley/spring/axon/flow/InitialEventHandler.java: -------------------------------------------------------------------------------- 1 | package hm.binkley.spring.axon.flow; 2 | 3 | import lombok.RequiredArgsConstructor; 4 | import org.axonframework.commandhandling.gateway.CommandGateway; 5 | import org.axonframework.eventhandling.annotation.EventHandler; 6 | 7 | @RequiredArgsConstructor 8 | public class InitialEventHandler { 9 | private final CommandGateway commands; 10 | 11 | @EventHandler 12 | public void handle(final InitialEvent event) { 13 | commands.send(new TerminalCommand(event.getId())); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-monitoring/src/test/java/hm/binkley/spring/axon/flow/TerminalCommand.java: -------------------------------------------------------------------------------- 1 | package hm.binkley.spring.axon.flow; 2 | 3 | import lombok.Value; 4 | 5 | @Value 6 | public class TerminalCommand { 7 | private final String id; 8 | } 9 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-monitoring/src/test/java/hm/binkley/spring/axon/flow/TerminalCommandHandler.java: -------------------------------------------------------------------------------- 1 | package hm.binkley.spring.axon.flow; 2 | 3 | import org.axonframework.commandhandling.annotation.CommandHandler; 4 | 5 | public class TerminalCommandHandler { 6 | @CommandHandler 7 | public void handle(final TerminalCommand command) {} 8 | } 9 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-monitoring/src/test/java/hm/binkley/spring/axon/metadata/FailedAggregateRoot.java: -------------------------------------------------------------------------------- 1 | package hm.binkley.spring.axon.metadata; 2 | 3 | import lombok.NoArgsConstructor; 4 | import org.axonframework.commandhandling.annotation.CommandHandler; 5 | import org.axonframework.eventsourcing.annotation 6 | .AbstractAnnotatedAggregateRoot; 7 | import org.axonframework.eventsourcing.annotation.AggregateIdentifier; 8 | import org.kohsuke.MetaInfServices; 9 | 10 | @MetaInfServices 11 | @NoArgsConstructor 12 | public final class FailedAggregateRoot 13 | extends AbstractAnnotatedAggregateRoot { 14 | @AggregateIdentifier 15 | private String id; 16 | 17 | @CommandHandler 18 | public FailedAggregateRoot(final FailedCommand command) { 19 | id = command.getId(); 20 | apply(new FailedEvent(command.getId(), command.getCause())); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-monitoring/src/test/java/hm/binkley/spring/axon/metadata/FailedCommand.java: -------------------------------------------------------------------------------- 1 | package hm.binkley.spring.axon.metadata; 2 | 3 | import lombok.Value; 4 | 5 | @Value 6 | public class FailedCommand { 7 | private final String id; 8 | private final FailedException cause; 9 | } 10 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-monitoring/src/test/java/hm/binkley/spring/axon/metadata/FailedEvent.java: -------------------------------------------------------------------------------- 1 | package hm.binkley.spring.axon.metadata; 2 | 3 | import lombok.Value; 4 | 5 | @Value 6 | public class FailedEvent { 7 | private final String id; 8 | private final FailedException cause; 9 | } 10 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-monitoring/src/test/java/hm/binkley/spring/axon/metadata/FailedEventHandler.java: -------------------------------------------------------------------------------- 1 | package hm.binkley.spring.axon.metadata; 2 | 3 | import org.axonframework.eventhandling.annotation.EventHandler; 4 | 5 | public class FailedEventHandler { 6 | @EventHandler 7 | public void handle(final FailedEvent event) { 8 | throw event.getCause(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-monitoring/src/test/java/hm/binkley/spring/axon/metadata/FailedException.java: -------------------------------------------------------------------------------- 1 | package hm.binkley.spring.axon.metadata; 2 | 3 | public final class FailedException 4 | extends RuntimeException {} 5 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-monitoring/src/test/java/hm/binkley/spring/axon/metadata/MetaDataIT.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free and unencumbered software released into the public domain. 3 | * 4 | * Anyone is free to copy, modify, publish, use, compile, sell, or 5 | * distribute this software, either in source code form or as a compiled 6 | * binary, for any purpose, commercial or non-commercial, and by any 7 | * means. 8 | * 9 | * In jurisdictions that recognize copyright laws, the author or authors 10 | * of this software dedicate any and all copyright interest in the 11 | * software to the public domain. We make this dedication for the benefit 12 | * of the public at large and to the detriment of our heirs and 13 | * successors. We intend this dedication to be an overt act of 14 | * relinquishment in perpetuity of all present and future rights to this 15 | * software under copyright law. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | * 25 | * For more information, please refer to . 26 | */ 27 | 28 | package hm.binkley.spring.axon.metadata; 29 | 30 | import hm.binkley.spring.axon.shared.TestAuditEventRepository; 31 | import org.axonframework.commandhandling.GenericCommandMessage; 32 | import org.axonframework.commandhandling.gateway.CommandGateway; 33 | import org.junit.After; 34 | import org.junit.Test; 35 | import org.junit.runner.RunWith; 36 | import org.springframework.beans.factory.annotation.Autowired; 37 | import org.springframework.boot.actuate.audit.AuditEvent; 38 | import org.springframework.boot.test.SpringApplicationConfiguration; 39 | import org.springframework.test.annotation.DirtiesContext; 40 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 41 | 42 | import java.util.Map; 43 | 44 | import static hm.binkley.spring.axon.AxonCommandAuditEvent.AXON_COMMAND_AUDIT_TYPE; 45 | import static hm.binkley.spring.axon.AxonEventAuditEvent.AXON_EVENT_AUDIT_TYPE; 46 | import static hm.binkley.spring.axon.SpringBootAuditLogger.FAILURE_CAUSE; 47 | import static hm.binkley.spring.axon.SpringBootAuditLogger.MESSAGE_TYPE; 48 | import static hm.binkley.spring.axon.SpringBootAuditLogger.RETURN_VALUE; 49 | import static java.util.Collections.singletonMap; 50 | import static org.assertj.core.api.Assertions.assertThat; 51 | 52 | @DirtiesContext 53 | @RunWith(SpringJUnit4ClassRunner.class) 54 | @SpringApplicationConfiguration(classes = MetaDataTestConfiguration.class) 55 | public final class MetaDataIT { 56 | @Autowired 57 | private CommandGateway commands; 58 | @Autowired 59 | private TestAuditEventRepository trail; 60 | 61 | @After 62 | public void resetTrail() { 63 | trail.reset(); 64 | } 65 | 66 | @Test 67 | public void shouldAuditWhenSuccessful() { 68 | final String aggregateId = "abc"; 69 | final SuccessfulCommand payload = new SuccessfulCommand(aggregateId); 70 | commands.send(payload); 71 | 72 | assertThat(trail.received()). 73 | isEqualTo(2); 74 | 75 | final AuditEvent commandAuditEvent = trail.eventAt(1); 76 | assertThat(commandAuditEvent.getType()). 77 | isEqualTo(AXON_COMMAND_AUDIT_TYPE); 78 | final Map commandData = commandAuditEvent.getData(); 79 | assertThat(commandData.get(MESSAGE_TYPE)). 80 | isEqualTo(SuccessfulCommand.class.getName()); 81 | assertThat(commandData.get(RETURN_VALUE)). 82 | isEqualTo(aggregateId); 83 | assertThat(commandData.get(FAILURE_CAUSE)). 84 | isNull(); 85 | 86 | final AuditEvent eventAuditEvent = trail.eventAt(0); 87 | assertThat(eventAuditEvent.getType()). 88 | isEqualTo(AXON_EVENT_AUDIT_TYPE); 89 | final Map eventData = eventAuditEvent.getData(); 90 | assertThat(eventData.get(MESSAGE_TYPE)). 91 | isEqualTo(SuccessfulEvent.class.getName()); 92 | assertThat(eventData.get(FAILURE_CAUSE)). 93 | isNull(); 94 | } 95 | 96 | @Test 97 | public void shouldAuditWhenFailed() { 98 | final FailedException cause = new FailedException(); 99 | final FailedCommand payload = new FailedCommand("def", cause); 100 | commands.send(payload); 101 | 102 | assertThat(trail.received()). 103 | isEqualTo(2); 104 | 105 | final AuditEvent commandAuditEvent = trail.eventAt(1); 106 | assertThat(commandAuditEvent.getType()). 107 | isEqualTo(AXON_COMMAND_AUDIT_TYPE); 108 | final Map commandData = commandAuditEvent.getData(); 109 | assertThat(commandData.get(MESSAGE_TYPE)). 110 | isEqualTo(FailedCommand.class.getName()); 111 | assertThat(commandData.get(RETURN_VALUE)). 112 | isNull(); 113 | assertThat(commandData.get(FAILURE_CAUSE)). 114 | isSameAs(cause); 115 | 116 | final AuditEvent eventAuditEvent = trail.eventAt(0); 117 | assertThat(eventAuditEvent.getType()). 118 | isEqualTo(AXON_EVENT_AUDIT_TYPE); 119 | final Map eventData = eventAuditEvent.getData(); 120 | assertThat(eventData.get(MESSAGE_TYPE)). 121 | isEqualTo(FailedEvent.class.getName()); 122 | assertThat(eventData.get(FAILURE_CAUSE)). 123 | isSameAs(cause); 124 | } 125 | 126 | @Test 127 | public void shouldPassAlongMetaDataWhenSuccessful() { 128 | commands.send( 129 | new GenericCommandMessage<>(new SuccessfulCommand("abc"), 130 | singletonMap("mumble", 3))); 131 | 132 | final Map commandData = trail.eventAt(1).getData(); 133 | assertThat(commandData.get("mumble")). 134 | isEqualTo(3); 135 | 136 | final Map eventData = trail.eventAt(0).getData(); 137 | assertThat(eventData.get("mumble")). 138 | isEqualTo(3); 139 | } 140 | 141 | @Test 142 | public void shouldPassAlongMetaDataWhenFailed() { 143 | commands.send(new GenericCommandMessage<>( 144 | new FailedCommand("abc", new FailedException()), 145 | singletonMap("mumble", 3))); 146 | 147 | final Map commandData = trail.eventAt(1).getData(); 148 | assertThat(commandData.get("mumble")). 149 | isEqualTo(3); 150 | 151 | final Map eventData = trail.eventAt(0).getData(); 152 | assertThat(eventData.get("mumble")). 153 | isEqualTo(3); 154 | } 155 | } 156 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-monitoring/src/test/java/hm/binkley/spring/axon/metadata/MetaDataTestConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free and unencumbered software released into the public domain. 3 | * 4 | * Anyone is free to copy, modify, publish, use, compile, sell, or 5 | * distribute this software, either in source code form or as a compiled 6 | * binary, for any purpose, commercial or non-commercial, and by any 7 | * means. 8 | * 9 | * In jurisdictions that recognize copyright laws, the author or authors 10 | * of this software dedicate any and all copyright interest in the 11 | * software to the public domain. We make this dedication for the benefit 12 | * of the public at large and to the detriment of our heirs and 13 | * successors. We intend this dedication to be an overt act of 14 | * relinquishment in perpetuity of all present and future rights to this 15 | * software under copyright law. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | * 25 | * For more information, please refer to . 26 | */ 27 | 28 | package hm.binkley.spring.axon.metadata; 29 | 30 | import hm.binkley.spring.axon.shared.TestAuditEventRepository; 31 | import org.axonframework.eventstore.EventStore; 32 | import org.axonframework.eventstore.supporting.VolatileEventStore; 33 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 34 | import org.springframework.context.annotation.Bean; 35 | import org.springframework.context.annotation.Configuration; 36 | 37 | @Configuration 38 | @EnableAutoConfiguration 39 | public class MetaDataTestConfiguration { 40 | @Bean 41 | public EventStore eventStore() { 42 | return new VolatileEventStore(); 43 | } 44 | 45 | @Bean 46 | public TestAuditEventRepository testAuditEventRepository() { 47 | return new TestAuditEventRepository(); 48 | } 49 | 50 | @Bean 51 | public SuccessfulEventHandler successfulEventHandler() { 52 | return new SuccessfulEventHandler(); 53 | } 54 | 55 | @Bean 56 | public FailedEventHandler failedEventHandler() { 57 | return new FailedEventHandler(); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-monitoring/src/test/java/hm/binkley/spring/axon/metadata/SuccessfulAggregateRoot.java: -------------------------------------------------------------------------------- 1 | package hm.binkley.spring.axon.metadata; 2 | 3 | import lombok.NoArgsConstructor; 4 | import org.axonframework.commandhandling.annotation.CommandHandler; 5 | import org.axonframework.eventsourcing.annotation 6 | .AbstractAnnotatedAggregateRoot; 7 | import org.axonframework.eventsourcing.annotation.AggregateIdentifier; 8 | import org.kohsuke.MetaInfServices; 9 | 10 | @MetaInfServices 11 | @NoArgsConstructor 12 | public final class SuccessfulAggregateRoot 13 | extends AbstractAnnotatedAggregateRoot { 14 | @AggregateIdentifier 15 | private String id; 16 | 17 | @CommandHandler 18 | public SuccessfulAggregateRoot(final SuccessfulCommand command) { 19 | id = command.getId(); 20 | apply(new SuccessfulEvent(command.getId())); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-monitoring/src/test/java/hm/binkley/spring/axon/metadata/SuccessfulCommand.java: -------------------------------------------------------------------------------- 1 | package hm.binkley.spring.axon.metadata; 2 | 3 | import lombok.Value; 4 | 5 | @Value 6 | public class SuccessfulCommand { 7 | private final String id; 8 | } 9 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-monitoring/src/test/java/hm/binkley/spring/axon/metadata/SuccessfulEvent.java: -------------------------------------------------------------------------------- 1 | package hm.binkley.spring.axon.metadata; 2 | 3 | import lombok.Value; 4 | 5 | @Value 6 | public class SuccessfulEvent { 7 | private final String id; 8 | } 9 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-monitoring/src/test/java/hm/binkley/spring/axon/metadata/SuccessfulEventHandler.java: -------------------------------------------------------------------------------- 1 | package hm.binkley.spring.axon.metadata; 2 | 3 | import org.axonframework.eventhandling.annotation.EventHandler; 4 | 5 | public class SuccessfulEventHandler { 6 | @EventHandler 7 | public void handle(final SuccessfulEvent event) {} 8 | } 9 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-monitoring/src/test/java/hm/binkley/spring/axon/shared/TestAuditEventRepository.java: -------------------------------------------------------------------------------- 1 | package hm.binkley.spring.axon.shared; 2 | 3 | import org.springframework.boot.actuate.audit.AuditEvent; 4 | import org.springframework.boot.actuate.audit.AuditEventRepository; 5 | 6 | import java.util.ArrayList; 7 | import java.util.Date; 8 | import java.util.List; 9 | 10 | public class TestAuditEventRepository 11 | implements AuditEventRepository { 12 | private final List trail = new ArrayList<>(); 13 | 14 | @Override 15 | public List find(final String principal, final Date after) { 16 | throw new UnsupportedOperationException(); 17 | } 18 | 19 | @Override 20 | public void add(final AuditEvent event) { 21 | trail.add(event); 22 | } 23 | 24 | public void reset() { 25 | trail.clear(); 26 | } 27 | 28 | public int received() { 29 | return trail.size(); 30 | } 31 | 32 | public AuditEvent eventAt(final int sequence) { 33 | return trail.get(sequence); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-monitoring/src/test/resources/application.yaml: -------------------------------------------------------------------------------- 1 | axon: 2 | cluster: 3 | name: TEST 4 | 5 | spring: 6 | main: 7 | show-banner: false 8 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-query/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | 6 | hm.binkley 7 | axon-spring-boot-starter-parent 8 | 5 9 | 10 | 11 | axon-spring-boot-starter-query 12 | 13 | Spring Boot/Axon Starter - Read-side Only 14 | 15 | 16 | 17 | org.springframework.boot 18 | spring-boot-starter-actuator 19 | 20 | 21 | 22 | org.axonframework 23 | axon-core 24 | 25 | 26 | ${project.groupId} 27 | axon-spring-boot-testing 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-query/src/main/java/hm/binkley/spring/axon/AxonQueryAutoConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free and unencumbered software released into the public domain. 3 | * 4 | * Anyone is free to copy, modify, publish, use, compile, sell, or 5 | * distribute this software, either in source code form or as a compiled 6 | * binary, for any purpose, commercial or non-commercial, and by any 7 | * means. 8 | * 9 | * In jurisdictions that recognize copyright laws, the author or authors 10 | * of this software dedicate any and all copyright interest in the 11 | * software to the public domain. We make this dedication for the benefit 12 | * of the public at large and to the detriment of our heirs and 13 | * successors. We intend this dedication to be an overt act of 14 | * relinquishment in perpetuity of all present and future rights to this 15 | * software under copyright law. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | * 25 | * For more information, please refer to . 26 | */ 27 | 28 | package hm.binkley.spring.axon; 29 | 30 | import org.axonframework.eventhandling.EventBus; 31 | import org.axonframework.eventhandling.SimpleEventBus; 32 | import org.axonframework.eventhandling.annotation 33 | .AnnotationEventListenerBeanPostProcessor; 34 | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; 35 | import org.springframework.boot.autoconfigure.condition 36 | .ConditionalOnMissingBean; 37 | import org.springframework.context.annotation.Bean; 38 | import org.springframework.context.annotation.Configuration; 39 | 40 | /** 41 | * {@code AxonQueryAutoConfiguration} autoconfigures Axon Framework for Spring 42 | * Boot but only for query (read side). 43 | *

44 | * A minimal configuration is:

   @Configuration
45 |  * @EnableAutoConfiguration
46 |  * public class AConfiguration {}
In other classes inject Axon types 47 | * normally with {@code @Autowired}. 48 | *

49 | * Event handlers automatically subscribe to event buses in the Spring context 50 | * when annotated with {@code @EventHandler}. 51 | * 52 | * @author B. K. Oxley (binkley) 53 | */ 54 | @ConditionalOnClass(EventBus.class) 55 | @Configuration 56 | public class AxonQueryAutoConfiguration { 57 | @Bean 58 | @ConditionalOnMissingBean 59 | public EventBus eventBus() { 60 | return new SimpleEventBus(); 61 | } 62 | 63 | @Bean 64 | public AnnotationEventListenerBeanPostProcessor 65 | annotationEventListenerBeanPostProcessor() { 66 | return new AnnotationEventListenerBeanPostProcessor(); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-query/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ 2 | hm.binkley.spring.axon.AxonQueryAutoConfiguration 3 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-query/src/test/java/hm/binkley/spring/axon/query/QueryIT.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free and unencumbered software released into the public domain. 3 | * 4 | * Anyone is free to copy, modify, publish, use, compile, sell, or 5 | * distribute this software, either in source code form or as a compiled 6 | * binary, for any purpose, commercial or non-commercial, and by any 7 | * means. 8 | * 9 | * In jurisdictions that recognize copyright laws, the author or authors 10 | * of this software dedicate any and all copyright interest in the 11 | * software to the public domain. We make this dedication for the benefit 12 | * of the public at large and to the detriment of our heirs and 13 | * successors. We intend this dedication to be an overt act of 14 | * relinquishment in perpetuity of all present and future rights to this 15 | * software under copyright law. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | * 25 | * For more information, please refer to . 26 | */ 27 | 28 | package hm.binkley.spring.axon.query; 29 | 30 | import org.axonframework.eventhandling.EventBus; 31 | import org.junit.Test; 32 | import org.junit.runner.RunWith; 33 | import org.springframework.beans.factory.annotation.Autowired; 34 | import org.springframework.boot.test.SpringApplicationConfiguration; 35 | import org.springframework.test.annotation.DirtiesContext; 36 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 37 | 38 | import static org.assertj.core.api.Assertions.assertThat; 39 | 40 | @DirtiesContext 41 | @RunWith(SpringJUnit4ClassRunner.class) 42 | @SpringApplicationConfiguration(classes = QueryTestConfiguration.class) 43 | public final class QueryIT { 44 | @Autowired 45 | private EventBus eventBus; 46 | 47 | @Test 48 | public void shouldWireEventBus() { 49 | assertThat(eventBus).isNotNull(); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-query/src/test/java/hm/binkley/spring/axon/query/QueryIWithCustomT.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free and unencumbered software released into the public domain. 3 | * 4 | * Anyone is free to copy, modify, publish, use, compile, sell, or 5 | * distribute this software, either in source code form or as a compiled 6 | * binary, for any purpose, commercial or non-commercial, and by any 7 | * means. 8 | * 9 | * In jurisdictions that recognize copyright laws, the author or authors 10 | * of this software dedicate any and all copyright interest in the 11 | * software to the public domain. We make this dedication for the benefit 12 | * of the public at large and to the detriment of our heirs and 13 | * successors. We intend this dedication to be an overt act of 14 | * relinquishment in perpetuity of all present and future rights to this 15 | * software under copyright law. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | * 25 | * For more information, please refer to . 26 | */ 27 | 28 | package hm.binkley.spring.axon.query; 29 | 30 | import hm.binkley.spring.axon.query.QueryWithCustomTestConfiguration 31 | .CustomEventBus; 32 | import org.axonframework.eventhandling.EventBus; 33 | import org.junit.Test; 34 | import org.junit.runner.RunWith; 35 | import org.springframework.beans.factory.annotation.Autowired; 36 | import org.springframework.boot.test.SpringApplicationConfiguration; 37 | import org.springframework.test.annotation.DirtiesContext; 38 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 39 | 40 | import static org.assertj.core.api.Assertions.assertThat; 41 | 42 | @DirtiesContext 43 | @SpringApplicationConfiguration( 44 | classes = QueryWithCustomTestConfiguration.class) 45 | @RunWith(SpringJUnit4ClassRunner.class) 46 | public final class QueryIWithCustomT { 47 | @Autowired 48 | private EventBus eventBus; 49 | 50 | @Test 51 | public void shouldWireCustomEventBus() { 52 | assertThat(eventBus).isInstanceOf(CustomEventBus.class); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-query/src/test/java/hm/binkley/spring/axon/query/QueryTestConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free and unencumbered software released into the public domain. 3 | * 4 | * Anyone is free to copy, modify, publish, use, compile, sell, or 5 | * distribute this software, either in source code form or as a compiled 6 | * binary, for any purpose, commercial or non-commercial, and by any 7 | * means. 8 | * 9 | * In jurisdictions that recognize copyright laws, the author or authors 10 | * of this software dedicate any and all copyright interest in the 11 | * software to the public domain. We make this dedication for the benefit 12 | * of the public at large and to the detriment of our heirs and 13 | * successors. We intend this dedication to be an overt act of 14 | * relinquishment in perpetuity of all present and future rights to this 15 | * software under copyright law. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | * 25 | * For more information, please refer to . 26 | */ 27 | 28 | package hm.binkley.spring.axon.query; 29 | 30 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 31 | import org.springframework.context.annotation.Configuration; 32 | 33 | @Configuration 34 | @EnableAutoConfiguration 35 | public class QueryTestConfiguration {} 36 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-query/src/test/java/hm/binkley/spring/axon/query/QueryWithCustomTestConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free and unencumbered software released into the public domain. 3 | * 4 | * Anyone is free to copy, modify, publish, use, compile, sell, or 5 | * distribute this software, either in source code form or as a compiled 6 | * binary, for any purpose, commercial or non-commercial, and by any 7 | * means. 8 | * 9 | * In jurisdictions that recognize copyright laws, the author or authors 10 | * of this software dedicate any and all copyright interest in the 11 | * software to the public domain. We make this dedication for the benefit 12 | * of the public at large and to the detriment of our heirs and 13 | * successors. We intend this dedication to be an overt act of 14 | * relinquishment in perpetuity of all present and future rights to this 15 | * software under copyright law. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | * 25 | * For more information, please refer to . 26 | */ 27 | 28 | package hm.binkley.spring.axon.query; 29 | 30 | import org.axonframework.eventhandling.EventBus; 31 | import org.axonframework.eventhandling.SimpleEventBus; 32 | import org.springframework.context.annotation.Bean; 33 | import org.springframework.context.annotation.Configuration; 34 | 35 | @Configuration 36 | public class QueryWithCustomTestConfiguration { 37 | @Bean 38 | public EventBus customEventBus() { 39 | return new CustomEventBus(); 40 | } 41 | 42 | static final class CustomEventBus 43 | extends SimpleEventBus {} 44 | } 45 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-springmessaging/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | 6 | hm.binkley 7 | axon-spring-boot-starter-parent 8 | 5 9 | 10 | 11 | axon-spring-boot-starter-springmessaging 12 | 13 | Spring Boot/Axon Starter - JMS Event Bus 14 | 15 | 16 | 17 | org.springframework.boot 18 | spring-boot-configuration-processor 19 | 20 | 21 | ${project.groupId} 22 | axon-spring-boot-starter-query 23 | 24 | 25 | org.axonframework 26 | axon-springmessaging 27 | 28 | 29 | ${project.groupId} 30 | axon-spring-boot-testing 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-springmessaging/src/main/java/hm/binkley/spring/axon/AxonSpringMessagingAutoConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free and unencumbered software released into the public domain. 3 | * 4 | * Anyone is free to copy, modify, publish, use, compile, sell, or 5 | * distribute this software, either in source code form or as a compiled 6 | * binary, for any purpose, commercial or non-commercial, and by any 7 | * means. 8 | * 9 | * In jurisdictions that recognize copyright laws, the author or authors 10 | * of this software dedicate any and all copyright interest in the 11 | * software to the public domain. We make this dedication for the benefit 12 | * of the public at large and to the detriment of our heirs and 13 | * successors. We intend this dedication to be an overt act of 14 | * relinquishment in perpetuity of all present and future rights to this 15 | * software under copyright law. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | * 25 | * For more information, please refer to . 26 | */ 27 | 28 | package hm.binkley.spring.axon; 29 | 30 | import org.axonframework.eventhandling.EventBus; 31 | import org.axonframework.springmessaging.eventbus.SpringMessagingEventBus; 32 | import org.springframework.boot.autoconfigure.AutoConfigureBefore; 33 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 34 | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; 35 | import org.springframework.boot.autoconfigure.condition 36 | .ConditionalOnMissingBean; 37 | import org.springframework.context.annotation.Bean; 38 | import org.springframework.context.annotation.Configuration; 39 | import org.springframework.messaging.SubscribableChannel; 40 | 41 | /** 42 | * {@code AxonSpringMessagingAutoConfiguration} autoconfigures Axon Framework 43 | * for Spring Boot with a distributed event bus using Spring Messaging 44 | * (typically JMS). Use {@link EnableAutoConfiguration} on your configuration 45 | * class, and define a bean for {@link SubscribableChannel}. 46 | *

47 | * A minimal configuration is:

   @Configuration
48 |  * @EnableAutoConfiguration
49 |  * public class AConfiguration {
50 |  *     @Bean
51 |  *     public SubscribableChannel subscribableChannel() {
52 |  *         return ...;
53 |  *     }
54 |  * }
In other classes inject Axon types 55 | * normally with {@code @Autowired}. 56 | * 57 | * @author B. K. Oxley (binkley) 58 | */ 59 | @AutoConfigureBefore(AxonQueryAutoConfiguration.class) 60 | @ConditionalOnClass(EventBus.class) 61 | @Configuration 62 | public class AxonSpringMessagingAutoConfiguration { 63 | @Bean 64 | @ConditionalOnMissingBean 65 | public EventBus springMessagingEventBus( 66 | final SubscribableChannel channel) { 67 | final SpringMessagingEventBus eventBus 68 | = new SpringMessagingEventBus(); 69 | eventBus.setChannel(channel); 70 | return eventBus; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-springmessaging/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ 2 | hm.binkley.spring.axon.AxonSpringMessagingAutoConfiguration 3 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-springmessaging/src/test/java/hm/binkley/spring/axon/jms/JmsIT.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free and unencumbered software released into the public domain. 3 | * 4 | * Anyone is free to copy, modify, publish, use, compile, sell, or 5 | * distribute this software, either in source code form or as a compiled 6 | * binary, for any purpose, commercial or non-commercial, and by any 7 | * means. 8 | * 9 | * In jurisdictions that recognize copyright laws, the author or authors 10 | * of this software dedicate any and all copyright interest in the 11 | * software to the public domain. We make this dedication for the benefit 12 | * of the public at large and to the detriment of our heirs and 13 | * successors. We intend this dedication to be an overt act of 14 | * relinquishment in perpetuity of all present and future rights to this 15 | * software under copyright law. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | * 25 | * For more information, please refer to . 26 | */ 27 | 28 | package hm.binkley.spring.axon.jms; 29 | 30 | import org.axonframework.domain.GenericDomainEventMessage; 31 | import org.axonframework.eventhandling.EventBus; 32 | import org.axonframework.springmessaging.eventbus.SpringMessagingEventBus; 33 | import org.junit.Test; 34 | import org.junit.runner.RunWith; 35 | import org.springframework.beans.factory.annotation.Autowired; 36 | import org.springframework.boot.test.SpringApplicationConfiguration; 37 | import org.springframework.test.annotation.DirtiesContext; 38 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 39 | 40 | import static org.assertj.core.api.Assertions.assertThat; 41 | 42 | @DirtiesContext 43 | @RunWith(SpringJUnit4ClassRunner.class) 44 | @SpringApplicationConfiguration(classes = JmsTestConfiguration.class) 45 | public final class JmsIT { 46 | @Autowired 47 | private EventBus eventBus; 48 | @Autowired 49 | private TestSubscribableChannel channel; 50 | 51 | @Test 52 | public void shouldWireSpringMessagingEventBus() { 53 | assertThat(eventBus).isInstanceOf(SpringMessagingEventBus.class); 54 | } 55 | 56 | @Test 57 | public void shouldPublishEventToEventBus() { 58 | eventBus.publish( 59 | new GenericDomainEventMessage<>("abc", 1L, "Dog fish!")); 60 | assertThat(channel.sentMessages).hasSize(1); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-springmessaging/src/test/java/hm/binkley/spring/axon/jms/JmsTestConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free and unencumbered software released into the public domain. 3 | * 4 | * Anyone is free to copy, modify, publish, use, compile, sell, or 5 | * distribute this software, either in source code form or as a compiled 6 | * binary, for any purpose, commercial or non-commercial, and by any 7 | * means. 8 | * 9 | * In jurisdictions that recognize copyright laws, the author or authors 10 | * of this software dedicate any and all copyright interest in the 11 | * software to the public domain. We make this dedication for the benefit 12 | * of the public at large and to the detriment of our heirs and 13 | * successors. We intend this dedication to be an overt act of 14 | * relinquishment in perpetuity of all present and future rights to this 15 | * software under copyright law. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | * 25 | * For more information, please refer to . 26 | */ 27 | 28 | package hm.binkley.spring.axon.jms; 29 | 30 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 31 | import org.springframework.context.annotation.Bean; 32 | import org.springframework.context.annotation.Configuration; 33 | 34 | @Configuration 35 | @EnableAutoConfiguration 36 | public class JmsTestConfiguration { 37 | @Bean 38 | public TestSubscribableChannel testSubscribableChannel() { 39 | return new TestSubscribableChannel(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /axon-spring-boot-starter-springmessaging/src/test/java/hm/binkley/spring/axon/jms/TestSubscribableChannel.java: -------------------------------------------------------------------------------- 1 | package hm.binkley.spring.axon.jms; 2 | 3 | import org.springframework.messaging.Message; 4 | import org.springframework.messaging.support.AbstractSubscribableChannel; 5 | 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | 9 | public final class TestSubscribableChannel 10 | extends AbstractSubscribableChannel { 11 | public final List> sentMessages = new ArrayList<>(); 12 | 13 | @Override 14 | protected boolean sendInternal(final Message message, 15 | final long timeout) { 16 | return sentMessages.add(message); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /axon-spring-boot-starter/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | 6 | hm.binkley 7 | axon-spring-boot-starter-parent 8 | 5 9 | 10 | 11 | axon-spring-boot-starter 12 | 13 | Spring Boot/Axon Starter - Basic Functionality 14 | 15 | 16 | 17 | ${project.groupId} 18 | axon-spring-boot-starter-query 19 | 20 | 21 | 22 | org.springframework.boot 23 | spring-boot-starter-actuator 24 | 25 | 26 | 27 | org.axonframework 28 | axon-core 29 | 30 | 31 | javax.persistence 32 | persistence-api 33 | 34 | 35 | ${project.groupId} 36 | axon-spring-boot-testing 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /axon-spring-boot-starter/src/main/java/hm/binkley/spring/axon/AxonAutoConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free and unencumbered software released into the public domain. 3 | * 4 | * Anyone is free to copy, modify, publish, use, compile, sell, or 5 | * distribute this software, either in source code form or as a compiled 6 | * binary, for any purpose, commercial or non-commercial, and by any 7 | * means. 8 | * 9 | * In jurisdictions that recognize copyright laws, the author or authors 10 | * of this software dedicate any and all copyright interest in the 11 | * software to the public domain. We make this dedication for the benefit 12 | * of the public at large and to the detriment of our heirs and 13 | * successors. We intend this dedication to be an overt act of 14 | * relinquishment in perpetuity of all present and future rights to this 15 | * software under copyright law. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | * 25 | * For more information, please refer to . 26 | */ 27 | 28 | package hm.binkley.spring.axon; 29 | 30 | import org.axonframework.commandhandling.CommandBus; 31 | import org.axonframework.commandhandling.SimpleCommandBus; 32 | import org.axonframework.commandhandling.annotation 33 | .AnnotationCommandHandlerBeanPostProcessor; 34 | import org.axonframework.commandhandling.gateway.CommandGateway; 35 | import org.axonframework.commandhandling.gateway.DefaultCommandGateway; 36 | import org.axonframework.eventhandling.EventBus; 37 | import org.axonframework.eventsourcing.annotation 38 | .AbstractAnnotatedAggregateRoot; 39 | import org.axonframework.eventstore.EventStore; 40 | import org.springframework.beans.factory.annotation.Autowired; 41 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 42 | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; 43 | import org.springframework.boot.autoconfigure.condition 44 | .ConditionalOnMissingBean; 45 | import org.springframework.context.annotation 46 | .AnnotationConfigApplicationContext; 47 | import org.springframework.context.annotation.Bean; 48 | import org.springframework.context.annotation.Configuration; 49 | 50 | import javax.annotation.PostConstruct; 51 | import java.util.ServiceLoader; 52 | 53 | import static java.util.ServiceLoader.load; 54 | import static java.util.stream.StreamSupport.stream; 55 | 56 | /** 57 | * {@code AxonAutoConfiguration} autoconfigures Axon Framework for Spring 58 | * Boot. Use {@link EnableAutoConfiguration} on your configuration class, and 59 | * define a bean for {@link EventStore}. 60 | *

61 | * A minimal configuration is:

   @Configuration
 62 |  * @EnableAutoConfiguration
 63 |  * public class AConfiguration {
 64 |  *     @Bean
 65 |  *     public EventStore eventStore() {
 66 |  *         return ...;
 67 |  *     }
 68 |  * }
In other classes inject Axon types 69 | * normally with {@code @Autowired}. When injecting 70 | * repositories include the bean name:
   @Autowired
 71 |  * @Qualifier("someAggregateRepository")
 72 |  * private Repository<SomeAggregate> repository;
73 | * For autoconfiguration to create the repository, mark your aggregate root 74 | * class with {@code @MetaInfServices} and extend {@link 75 | * AbstractAnnotatedAggregateRoot}: 76 | *
   @MetaInfServices
 77 |  * public class SomeAggregate
 78 |  *         extends AbstractAnnotatedAggregateRoot<SomeIDType>
 79 |  *     @AggregateIdentifier
 80 |  *     private SomeIDType id;
 81 |  * }
Autoconfigurating repositories uses standard {@link 82 | * ServiceLoader} to discover aggregate root classes. 83 | * 84 | * Command handlers automatically subscribe to command buses in the Spring 85 | * context when annotated with {@code @CommandHandler}. 86 | * 87 | * @author B. K. Oxley (binkley) 88 | */ 89 | @ConditionalOnClass(CommandBus.class) 90 | @Configuration 91 | public class AxonAutoConfiguration { 92 | @Autowired 93 | private AnnotationConfigApplicationContext context; 94 | 95 | @Bean 96 | @ConditionalOnMissingBean 97 | public CommandBus commandBus() { 98 | return new SimpleCommandBus(); 99 | } 100 | 101 | @Bean 102 | @ConditionalOnMissingBean 103 | public CommandGateway commandGateway(final CommandBus commandBus) { 104 | return new DefaultCommandGateway(commandBus); 105 | } 106 | 107 | @SuppressWarnings("SpringJavaAutowiringInspection") 108 | @Bean 109 | public EventSourcingRepositoryRegistrar eventSourcingRepositoryRegistrar( 110 | final CommandBus commandBus, final EventBus eventBus, 111 | final EventStore eventStore) { 112 | return new EventSourcingRepositoryRegistrar(commandBus, eventBus, 113 | eventStore); 114 | } 115 | 116 | @Bean 117 | public AnnotationCommandHandlerBeanPostProcessor 118 | annotationCommandHandlerBeanPostProcessor() { 119 | return new AnnotationCommandHandlerBeanPostProcessor(); 120 | } 121 | 122 | @PostConstruct 123 | public void registerRepositories() { 124 | stream(load(AbstractAnnotatedAggregateRoot.class).spliterator(), 125 | false). 126 | map(Object::getClass). 127 | distinct(). 128 | forEach(context::register); 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /axon-spring-boot-starter/src/main/java/hm/binkley/spring/axon/CommandDispatchInterceptorAutomation.java: -------------------------------------------------------------------------------- 1 | package hm.binkley.spring.axon; 2 | 3 | import org.axonframework.commandhandling.CommandDispatchInterceptor; 4 | import org.axonframework.commandhandling.SimpleCommandBus; 5 | import org.springframework.context.ApplicationListener; 6 | import org.springframework.context.ConfigurableApplicationContext; 7 | import org.springframework.context.event.ContextRefreshedEvent; 8 | 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | 12 | import static org.springframework.beans.factory.BeanFactoryUtils 13 | .beansOfTypeIncludingAncestors; 14 | import static org.springframework.core.annotation 15 | .AnnotationAwareOrderComparator.sort; 16 | 17 | public class CommandDispatchInterceptorAutomation 18 | implements ApplicationListener { 19 | @Override 20 | public void onApplicationEvent(final ContextRefreshedEvent event) { 21 | final ConfigurableApplicationContext context 22 | = (ConfigurableApplicationContext) event.getSource(); 23 | final List interceptors = new ArrayList<>( 24 | beansOfTypeIncludingAncestors(context.getBeanFactory(), 25 | CommandDispatchInterceptor.class).values()); 26 | sort(interceptors); 27 | 28 | for (final SimpleCommandBus commandBus : 29 | beansOfTypeIncludingAncestors( 30 | context.getBeanFactory(), SimpleCommandBus.class).values()) 31 | commandBus.setDispatchInterceptors(interceptors); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /axon-spring-boot-starter/src/main/java/hm/binkley/spring/axon/CommandHandlerInterceptorAutomation.java: -------------------------------------------------------------------------------- 1 | package hm.binkley.spring.axon; 2 | 3 | import org.axonframework.commandhandling.CommandHandlerInterceptor; 4 | import org.axonframework.commandhandling.SimpleCommandBus; 5 | import org.springframework.context.ApplicationListener; 6 | import org.springframework.context.ConfigurableApplicationContext; 7 | import org.springframework.context.event.ContextRefreshedEvent; 8 | 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | 12 | import static org.springframework.beans.factory.BeanFactoryUtils 13 | .beansOfTypeIncludingAncestors; 14 | import static org.springframework.core.annotation 15 | .AnnotationAwareOrderComparator.sort; 16 | 17 | public class CommandHandlerInterceptorAutomation 18 | implements ApplicationListener { 19 | @Override 20 | public void onApplicationEvent(final ContextRefreshedEvent event) { 21 | final ConfigurableApplicationContext context 22 | = (ConfigurableApplicationContext) event.getSource(); 23 | final List interceptors = new ArrayList<>( 24 | beansOfTypeIncludingAncestors(context.getBeanFactory(), 25 | CommandHandlerInterceptor.class).values()); 26 | sort(interceptors); 27 | 28 | for (final SimpleCommandBus commandBus : 29 | beansOfTypeIncludingAncestors( 30 | context.getBeanFactory(), SimpleCommandBus.class).values()) 31 | commandBus.setHandlerInterceptors(interceptors); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /axon-spring-boot-starter/src/main/java/hm/binkley/spring/axon/EventSourcingRepositoryRegistrar.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free and unencumbered software released into the public domain. 3 | * 4 | * Anyone is free to copy, modify, publish, use, compile, sell, or 5 | * distribute this software, either in source code form or as a compiled 6 | * binary, for any purpose, commercial or non-commercial, and by any 7 | * means. 8 | * 9 | * In jurisdictions that recognize copyright laws, the author or authors 10 | * of this software dedicate any and all copyright interest in the 11 | * software to the public domain. We make this dedication for the benefit 12 | * of the public at large and to the detriment of our heirs and 13 | * successors. We intend this dedication to be an overt act of 14 | * relinquishment in perpetuity of all present and future rights to this 15 | * software under copyright law. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | * 25 | * For more information, please refer to . 26 | */ 27 | 28 | package hm.binkley.spring.axon; 29 | 30 | import lombok.RequiredArgsConstructor; 31 | import org.axonframework.commandhandling.CommandBus; 32 | import org.axonframework.eventhandling.EventBus; 33 | import org.axonframework.eventsourcing.EventSourcedAggregateRoot; 34 | import org.axonframework.eventsourcing.EventSourcingRepository; 35 | import org.axonframework.eventstore.EventStore; 36 | import org.springframework.beans.BeansException; 37 | import org.springframework.beans.factory.BeanFactory; 38 | import org.springframework.beans.factory.BeanFactoryAware; 39 | import org.springframework.beans.factory.config.BeanPostProcessor; 40 | import org.springframework.beans.factory.config 41 | .ConfigurableListableBeanFactory; 42 | 43 | import static java.lang.String.format; 44 | import static org.axonframework.commandhandling.annotation 45 | .AggregateAnnotationCommandHandler.subscribe; 46 | 47 | @RequiredArgsConstructor 48 | class EventSourcingRepositoryRegistrar 49 | implements BeanPostProcessor, BeanFactoryAware { 50 | private final CommandBus commandBus; 51 | private final EventBus eventBus; 52 | private final EventStore eventStore; 53 | private ConfigurableListableBeanFactory beanFactory; 54 | 55 | @Override 56 | public void setBeanFactory(final BeanFactory beanFactory) 57 | throws BeansException { 58 | this.beanFactory = (ConfigurableListableBeanFactory) beanFactory; 59 | } 60 | 61 | @Override 62 | public Object postProcessBeforeInitialization(final Object bean, 63 | final String beanName) 64 | throws BeansException { 65 | return bean; 66 | } 67 | 68 | @Override 69 | public Object postProcessAfterInitialization(final Object bean, 70 | final String beanName) 71 | throws BeansException { 72 | final Class beanType = bean.getClass(); 73 | if (EventSourcedAggregateRoot.class.isAssignableFrom(beanType)) 74 | beanFactory.registerSingleton(format("%sRepository", beanName), 75 | repositoryFor(beanType)); 76 | return bean; 77 | } 78 | 79 | private 80 | EventSourcingRepository repositoryFor( 81 | final Class beanType) { 82 | final EventSourcingRepository repository 83 | = new EventSourcingRepository<>(beanType, eventStore); 84 | repository.setEventBus(eventBus); 85 | subscribe(beanType, repository, commandBus); 86 | return repository; 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /axon-spring-boot-starter/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ 2 | hm.binkley.spring.axon.AxonAutoConfiguration 3 | org.springframework.context.ApplicationListener=\ 4 | hm.binkley.spring.axon.CommandDispatchInterceptorAutomation,\ 5 | hm.binkley.spring.axon.CommandHandlerInterceptorAutomation 6 | -------------------------------------------------------------------------------- /axon-spring-boot-starter/src/test/java/hm/binkley/spring/axon/handlers/HandlersIT.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free and unencumbered software released into the public domain. 3 | * 4 | * Anyone is free to copy, modify, publish, use, compile, sell, or 5 | * distribute this software, either in source code form or as a compiled 6 | * binary, for any purpose, commercial or non-commercial, and by any 7 | * means. 8 | * 9 | * In jurisdictions that recognize copyright laws, the author or authors 10 | * of this software dedicate any and all copyright interest in the 11 | * software to the public domain. We make this dedication for the benefit 12 | * of the public at large and to the detriment of our heirs and 13 | * successors. We intend this dedication to be an overt act of 14 | * relinquishment in perpetuity of all present and future rights to this 15 | * software under copyright law. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | * 25 | * For more information, please refer to . 26 | */ 27 | 28 | package hm.binkley.spring.axon.handlers; 29 | 30 | import hm.binkley.spring.axon.handlers.HandlersTestConfiguration 31 | .EventCollector; 32 | import org.axonframework.commandhandling.gateway.CommandGateway; 33 | import org.axonframework.domain.DomainEventStream; 34 | import org.axonframework.eventstore.EventStore; 35 | import org.junit.Test; 36 | import org.junit.runner.RunWith; 37 | import org.springframework.beans.factory.annotation.Autowired; 38 | import org.springframework.boot.test.SpringApplicationConfiguration; 39 | import org.springframework.test.annotation.DirtiesContext; 40 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 41 | 42 | import java.util.ArrayList; 43 | import java.util.List; 44 | 45 | import static java.util.Collections.singletonList; 46 | import static org.assertj.core.api.Assertions.assertThat; 47 | 48 | @DirtiesContext 49 | @RunWith(SpringJUnit4ClassRunner.class) 50 | @SpringApplicationConfiguration(classes = HandlersTestConfiguration.class) 51 | public final class HandlersIT { 52 | @Autowired 53 | private CommandGateway commands; 54 | @Autowired 55 | private EventCollector eventCollector; 56 | @Autowired 57 | private EventStore eventStore; 58 | 59 | @Test 60 | public void shouldWireEventStore() { 61 | commands.send(new HandlersTestCommand("abc")); 62 | assertThat(asAggregateIds(eventStore 63 | .readEvents(HandlersTestAggregateRoot.class.getSimpleName(), 64 | "abc"))). 65 | isEqualTo(singletonList(new HandlersTestEvent("abc"))); 66 | } 67 | 68 | @Test 69 | public void shouldFireHandlers() { 70 | commands.send(new HandlersTestCommand("def")); 71 | assertThat(eventCollector.getEvents()). 72 | isEqualTo(singletonList(new HandlersTestEvent("def"))); 73 | } 74 | 75 | private static List asAggregateIds( 76 | final DomainEventStream stream) { 77 | final List events = new ArrayList<>(); 78 | while (stream.hasNext()) 79 | events.add((HandlersTestEvent) stream.next().getPayload()); 80 | return events; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /axon-spring-boot-starter/src/test/java/hm/binkley/spring/axon/handlers/HandlersTest.java: -------------------------------------------------------------------------------- 1 | package hm.binkley.spring.axon.handlers; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.axonframework.test.Fixtures.newGivenWhenThenFixture; 6 | 7 | public class HandlersTest { 8 | @Test 9 | public void shouldPublishEvents() { 10 | newGivenWhenThenFixture(HandlersTestAggregateRoot.class). 11 | given(). 12 | when(new HandlersTestCommand("abc")). 13 | expectEvents(new HandlersTestEvent("abc")); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /axon-spring-boot-starter/src/test/java/hm/binkley/spring/axon/handlers/HandlersTestAggregateRoot.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free and unencumbered software released into the public domain. 3 | * 4 | * Anyone is free to copy, modify, publish, use, compile, sell, or 5 | * distribute this software, either in source code form or as a compiled 6 | * binary, for any purpose, commercial or non-commercial, and by any 7 | * means. 8 | * 9 | * In jurisdictions that recognize copyright laws, the author or authors 10 | * of this software dedicate any and all copyright interest in the 11 | * software to the public domain. We make this dedication for the benefit 12 | * of the public at large and to the detriment of our heirs and 13 | * successors. We intend this dedication to be an overt act of 14 | * relinquishment in perpetuity of all present and future rights to this 15 | * software under copyright law. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | * 25 | * For more information, please refer to . 26 | */ 27 | 28 | package hm.binkley.spring.axon.handlers; 29 | 30 | import lombok.NoArgsConstructor; 31 | import org.axonframework.commandhandling.annotation.CommandHandler; 32 | import org.axonframework.eventsourcing.annotation 33 | .AbstractAnnotatedAggregateRoot; 34 | import org.axonframework.eventsourcing.annotation.AggregateIdentifier; 35 | import org.kohsuke.MetaInfServices; 36 | 37 | @MetaInfServices 38 | @NoArgsConstructor 39 | public class HandlersTestAggregateRoot 40 | extends AbstractAnnotatedAggregateRoot { 41 | @AggregateIdentifier 42 | private String id; 43 | 44 | @CommandHandler 45 | public HandlersTestAggregateRoot(final HandlersTestCommand command) { 46 | id = command.getId(); 47 | apply(new HandlersTestEvent(command.getId())); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /axon-spring-boot-starter/src/test/java/hm/binkley/spring/axon/handlers/HandlersTestCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free and unencumbered software released into the public domain. 3 | * 4 | * Anyone is free to copy, modify, publish, use, compile, sell, or 5 | * distribute this software, either in source code form or as a compiled 6 | * binary, for any purpose, commercial or non-commercial, and by any 7 | * means. 8 | * 9 | * In jurisdictions that recognize copyright laws, the author or authors 10 | * of this software dedicate any and all copyright interest in the 11 | * software to the public domain. We make this dedication for the benefit 12 | * of the public at large and to the detriment of our heirs and 13 | * successors. We intend this dedication to be an overt act of 14 | * relinquishment in perpetuity of all present and future rights to this 15 | * software under copyright law. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | * 25 | * For more information, please refer to . 26 | */ 27 | 28 | package hm.binkley.spring.axon.handlers; 29 | 30 | import lombok.Value; 31 | 32 | @Value 33 | public class HandlersTestCommand { 34 | private final String id; 35 | } 36 | -------------------------------------------------------------------------------- /axon-spring-boot-starter/src/test/java/hm/binkley/spring/axon/handlers/HandlersTestConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free and unencumbered software released into the public domain. 3 | * 4 | * Anyone is free to copy, modify, publish, use, compile, sell, or 5 | * distribute this software, either in source code form or as a compiled 6 | * binary, for any purpose, commercial or non-commercial, and by any 7 | * means. 8 | * 9 | * In jurisdictions that recognize copyright laws, the author or authors 10 | * of this software dedicate any and all copyright interest in the 11 | * software to the public domain. We make this dedication for the benefit 12 | * of the public at large and to the detriment of our heirs and 13 | * successors. We intend this dedication to be an overt act of 14 | * relinquishment in perpetuity of all present and future rights to this 15 | * software under copyright law. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | * 25 | * For more information, please refer to . 26 | */ 27 | 28 | package hm.binkley.spring.axon.handlers; 29 | 30 | import lombok.Getter; 31 | import org.axonframework.eventhandling.annotation.EventHandler; 32 | import org.axonframework.eventstore.EventStore; 33 | import org.axonframework.eventstore.supporting.VolatileEventStore; 34 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 35 | import org.springframework.context.annotation.Bean; 36 | import org.springframework.context.annotation.Configuration; 37 | import org.springframework.stereotype.Component; 38 | 39 | import java.util.ArrayList; 40 | import java.util.List; 41 | 42 | @Configuration 43 | @EnableAutoConfiguration 44 | public class HandlersTestConfiguration { 45 | @Bean 46 | public EventStore eventStore() { 47 | return new VolatileEventStore(); 48 | } 49 | 50 | @Component 51 | @Getter 52 | public static class EventCollector { 53 | private final List events = new ArrayList<>(); 54 | 55 | @EventHandler 56 | public void on(final HandlersTestEvent event) { 57 | events.add(event); 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /axon-spring-boot-starter/src/test/java/hm/binkley/spring/axon/handlers/HandlersTestEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free and unencumbered software released into the public domain. 3 | * 4 | * Anyone is free to copy, modify, publish, use, compile, sell, or 5 | * distribute this software, either in source code form or as a compiled 6 | * binary, for any purpose, commercial or non-commercial, and by any 7 | * means. 8 | * 9 | * In jurisdictions that recognize copyright laws, the author or authors 10 | * of this software dedicate any and all copyright interest in the 11 | * software to the public domain. We make this dedication for the benefit 12 | * of the public at large and to the detriment of our heirs and 13 | * successors. We intend this dedication to be an overt act of 14 | * relinquishment in perpetuity of all present and future rights to this 15 | * software under copyright law. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | * 25 | * For more information, please refer to . 26 | */ 27 | 28 | package hm.binkley.spring.axon.handlers; 29 | 30 | import lombok.Value; 31 | 32 | @Value 33 | public class HandlersTestEvent { 34 | private final String id; 35 | } 36 | -------------------------------------------------------------------------------- /axon-spring-boot-starter/src/test/java/hm/binkley/spring/axon/interceptors/DispatchInterceptorsIT.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free and unencumbered software released into the public domain. 3 | * 4 | * Anyone is free to copy, modify, publish, use, compile, sell, or 5 | * distribute this software, either in source code form or as a compiled 6 | * binary, for any purpose, commercial or non-commercial, and by any 7 | * means. 8 | * 9 | * In jurisdictions that recognize copyright laws, the author or authors 10 | * of this software dedicate any and all copyright interest in the 11 | * software to the public domain. We make this dedication for the benefit 12 | * of the public at large and to the detriment of our heirs and 13 | * successors. We intend this dedication to be an overt act of 14 | * relinquishment in perpetuity of all present and future rights to this 15 | * software under copyright law. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | * 25 | * For more information, please refer to . 26 | */ 27 | 28 | package hm.binkley.spring.axon.interceptors; 29 | 30 | import org.axonframework.commandhandling.gateway.CommandGateway; 31 | import org.junit.Test; 32 | import org.junit.runner.RunWith; 33 | import org.springframework.beans.factory.annotation.Autowired; 34 | import org.springframework.boot.test.SpringApplicationConfiguration; 35 | import org.springframework.test.annotation.DirtiesContext; 36 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 37 | 38 | import static java.util.Arrays.asList; 39 | import static org.assertj.core.api.Assertions.assertThat; 40 | 41 | @DirtiesContext 42 | @RunWith(SpringJUnit4ClassRunner.class) 43 | @SpringApplicationConfiguration( 44 | classes = DispatchInterceptorsTestConfiguration.class) 45 | public final class DispatchInterceptorsIT { 46 | @Autowired 47 | private CommandGateway commands; 48 | @Autowired 49 | private DispatchInterceptorsTestConfiguration configuration; 50 | 51 | @Test 52 | public void shouldInterceptInOrder() { 53 | commands.send(this); 54 | 55 | assertThat(configuration.handlings).isEqualTo(asList(1, 2)); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /axon-spring-boot-starter/src/test/java/hm/binkley/spring/axon/interceptors/DispatchInterceptorsTestConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free and unencumbered software released into the public domain. 3 | * 4 | * Anyone is free to copy, modify, publish, use, compile, sell, or 5 | * distribute this software, either in source code form or as a compiled 6 | * binary, for any purpose, commercial or non-commercial, and by any 7 | * means. 8 | * 9 | * In jurisdictions that recognize copyright laws, the author or authors 10 | * of this software dedicate any and all copyright interest in the 11 | * software to the public domain. We make this dedication for the benefit 12 | * of the public at large and to the detriment of our heirs and 13 | * successors. We intend this dedication to be an overt act of 14 | * relinquishment in perpetuity of all present and future rights to this 15 | * software under copyright law. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | * 25 | * For more information, please refer to . 26 | */ 27 | 28 | package hm.binkley.spring.axon.interceptors; 29 | 30 | import org.axonframework.commandhandling.CommandDispatchInterceptor; 31 | import org.axonframework.commandhandling.CommandMessage; 32 | import org.axonframework.eventstore.EventStore; 33 | import org.axonframework.eventstore.supporting.VolatileEventStore; 34 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 35 | import org.springframework.context.annotation.Bean; 36 | import org.springframework.context.annotation.Configuration; 37 | import org.springframework.core.annotation.Order; 38 | 39 | import java.util.ArrayList; 40 | import java.util.List; 41 | 42 | @Configuration 43 | @EnableAutoConfiguration 44 | public class DispatchInterceptorsTestConfiguration { 45 | final List handlings = new ArrayList<>(); 46 | 47 | @Bean 48 | public EventStore eventStore() { 49 | return new VolatileEventStore(); 50 | } 51 | 52 | @Bean 53 | public CommandDispatchInterceptor aCommandHandlerInterceptor() { 54 | return new ACommandDispatchInterceptor(); 55 | } 56 | 57 | @Bean 58 | public CommandDispatchInterceptor bCommandHandlerInterceptor() { 59 | return new BCommandDispatchInterceptor(); 60 | } 61 | 62 | @Order(2) 63 | private class ACommandDispatchInterceptor 64 | implements CommandDispatchInterceptor { 65 | @Override 66 | public CommandMessage handle( 67 | final CommandMessage commandMessage) { 68 | handlings.add(2); 69 | return commandMessage; 70 | } 71 | } 72 | 73 | @Order(1) 74 | private class BCommandDispatchInterceptor 75 | implements CommandDispatchInterceptor { 76 | @Override 77 | public CommandMessage handle( 78 | final CommandMessage commandMessage) { 79 | handlings.add(1); 80 | return commandMessage; 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /axon-spring-boot-starter/src/test/java/hm/binkley/spring/axon/interceptors/HandlerInterceptorsIT.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free and unencumbered software released into the public domain. 3 | * 4 | * Anyone is free to copy, modify, publish, use, compile, sell, or 5 | * distribute this software, either in source code form or as a compiled 6 | * binary, for any purpose, commercial or non-commercial, and by any 7 | * means. 8 | * 9 | * In jurisdictions that recognize copyright laws, the author or authors 10 | * of this software dedicate any and all copyright interest in the 11 | * software to the public domain. We make this dedication for the benefit 12 | * of the public at large and to the detriment of our heirs and 13 | * successors. We intend this dedication to be an overt act of 14 | * relinquishment in perpetuity of all present and future rights to this 15 | * software under copyright law. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | * 25 | * For more information, please refer to . 26 | */ 27 | 28 | package hm.binkley.spring.axon.interceptors; 29 | 30 | import org.axonframework.commandhandling.gateway.CommandGateway; 31 | import org.junit.Test; 32 | import org.junit.runner.RunWith; 33 | import org.springframework.beans.factory.annotation.Autowired; 34 | import org.springframework.boot.test.SpringApplicationConfiguration; 35 | import org.springframework.test.annotation.DirtiesContext; 36 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 37 | 38 | import static java.util.Arrays.asList; 39 | import static org.assertj.core.api.Assertions.assertThat; 40 | 41 | @DirtiesContext 42 | @RunWith(SpringJUnit4ClassRunner.class) 43 | @SpringApplicationConfiguration( 44 | classes = HandlerInterceptorsTestConfiguration.class) 45 | public final class HandlerInterceptorsIT { 46 | @Autowired 47 | private CommandGateway commands; 48 | @Autowired 49 | private HandlerInterceptorsTestConfiguration configuration; 50 | 51 | @Test 52 | public void shouldInterceptInOrder() { 53 | commands.send(new TestCommand()); 54 | 55 | assertThat(configuration.handlings).isEqualTo(asList(1, 2)); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /axon-spring-boot-starter/src/test/java/hm/binkley/spring/axon/interceptors/HandlerInterceptorsTestConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free and unencumbered software released into the public domain. 3 | * 4 | * Anyone is free to copy, modify, publish, use, compile, sell, or 5 | * distribute this software, either in source code form or as a compiled 6 | * binary, for any purpose, commercial or non-commercial, and by any 7 | * means. 8 | * 9 | * In jurisdictions that recognize copyright laws, the author or authors 10 | * of this software dedicate any and all copyright interest in the 11 | * software to the public domain. We make this dedication for the benefit 12 | * of the public at large and to the detriment of our heirs and 13 | * successors. We intend this dedication to be an overt act of 14 | * relinquishment in perpetuity of all present and future rights to this 15 | * software under copyright law. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | * 25 | * For more information, please refer to . 26 | */ 27 | 28 | package hm.binkley.spring.axon.interceptors; 29 | 30 | import lombok.Getter; 31 | import org.axonframework.commandhandling.CommandHandlerInterceptor; 32 | import org.axonframework.commandhandling.CommandMessage; 33 | import org.axonframework.commandhandling.InterceptorChain; 34 | import org.axonframework.commandhandling.annotation.CommandHandler; 35 | import org.axonframework.eventstore.EventStore; 36 | import org.axonframework.eventstore.supporting.VolatileEventStore; 37 | import org.axonframework.unitofwork.UnitOfWork; 38 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 39 | import org.springframework.context.annotation.Bean; 40 | import org.springframework.context.annotation.Configuration; 41 | import org.springframework.core.annotation.Order; 42 | import org.springframework.stereotype.Component; 43 | 44 | import java.util.ArrayList; 45 | import java.util.List; 46 | 47 | @Configuration 48 | @EnableAutoConfiguration 49 | public class HandlerInterceptorsTestConfiguration { 50 | final List handlings = new ArrayList<>(); 51 | 52 | @Bean 53 | public EventStore eventStore() { 54 | return new VolatileEventStore(); 55 | } 56 | 57 | @Bean 58 | public CommandHandlerInterceptor aCommandHandlerInterceptor() { 59 | return new ACommandHandlerInterceptor(); 60 | } 61 | 62 | @Bean 63 | public CommandHandlerInterceptor bCommandHandlerInterceptor() { 64 | return new BCommandHandlerInterceptor(); 65 | } 66 | 67 | @Component 68 | @Getter 69 | public static class TestCommandHandler { 70 | @CommandHandler 71 | public void on(final TestCommand ignored) { } 72 | } 73 | 74 | @Order(2) 75 | private class ACommandHandlerInterceptor 76 | implements CommandHandlerInterceptor { 77 | @Override 78 | public Object handle(final CommandMessage commandMessage, 79 | final UnitOfWork unitOfWork, 80 | final InterceptorChain interceptorChain) 81 | throws Throwable { 82 | handlings.add(2); 83 | return interceptorChain.proceed(); 84 | } 85 | } 86 | 87 | @Order(1) 88 | private class BCommandHandlerInterceptor 89 | implements CommandHandlerInterceptor { 90 | @Override 91 | public Object handle(final CommandMessage commandMessage, 92 | final UnitOfWork unitOfWork, 93 | final InterceptorChain interceptorChain) 94 | throws Throwable { 95 | handlings.add(1); 96 | return interceptorChain.proceed(); 97 | } 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /axon-spring-boot-starter/src/test/java/hm/binkley/spring/axon/interceptors/TestCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free and unencumbered software released into the public domain. 3 | * 4 | * Anyone is free to copy, modify, publish, use, compile, sell, or 5 | * distribute this software, either in source code form or as a compiled 6 | * binary, for any purpose, commercial or non-commercial, and by any 7 | * means. 8 | * 9 | * In jurisdictions that recognize copyright laws, the author or authors 10 | * of this software dedicate any and all copyright interest in the 11 | * software to the public domain. We make this dedication for the benefit 12 | * of the public at large and to the detriment of our heirs and 13 | * successors. We intend this dedication to be an overt act of 14 | * relinquishment in perpetuity of all present and future rights to this 15 | * software under copyright law. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | * 25 | * For more information, please refer to . 26 | */ 27 | 28 | package hm.binkley.spring.axon.interceptors; 29 | 30 | public class TestCommand {} 31 | -------------------------------------------------------------------------------- /axon-spring-boot-starter/src/test/java/hm/binkley/spring/axon/query/BasicIT.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free and unencumbered software released into the public domain. 3 | * 4 | * Anyone is free to copy, modify, publish, use, compile, sell, or 5 | * distribute this software, either in source code form or as a compiled 6 | * binary, for any purpose, commercial or non-commercial, and by any 7 | * means. 8 | * 9 | * In jurisdictions that recognize copyright laws, the author or authors 10 | * of this software dedicate any and all copyright interest in the 11 | * software to the public domain. We make this dedication for the benefit 12 | * of the public at large and to the detriment of our heirs and 13 | * successors. We intend this dedication to be an overt act of 14 | * relinquishment in perpetuity of all present and future rights to this 15 | * software under copyright law. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | * 25 | * For more information, please refer to . 26 | */ 27 | 28 | package hm.binkley.spring.axon.query; 29 | 30 | import org.axonframework.commandhandling.CommandBus; 31 | import org.axonframework.eventhandling.EventBus; 32 | import org.axonframework.eventstore.EventStore; 33 | import org.junit.Test; 34 | import org.junit.runner.RunWith; 35 | import org.springframework.beans.factory.annotation.Autowired; 36 | import org.springframework.boot.test.SpringApplicationConfiguration; 37 | import org.springframework.test.annotation.DirtiesContext; 38 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 39 | 40 | import static org.assertj.core.api.Assertions.assertThat; 41 | 42 | @DirtiesContext 43 | @RunWith(SpringJUnit4ClassRunner.class) 44 | @SpringApplicationConfiguration(classes = BasicTestConfiguration.class) 45 | public final class BasicIT { 46 | @Autowired 47 | private CommandBus commandBus; 48 | @Autowired 49 | private EventBus eventBus; 50 | @Autowired 51 | private EventStore eventStore; 52 | 53 | @Test 54 | public void shouldWireCommandBus() { 55 | assertThat(commandBus).isNotNull(); 56 | } 57 | 58 | @Test 59 | public void shouldWireEventBus() { 60 | assertThat(eventBus).isNotNull(); 61 | } 62 | 63 | @Test 64 | public void shouldWireEventStore() { 65 | assertThat(eventStore).isNotNull(); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /axon-spring-boot-starter/src/test/java/hm/binkley/spring/axon/query/BasicIWithCustomT.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free and unencumbered software released into the public domain. 3 | * 4 | * Anyone is free to copy, modify, publish, use, compile, sell, or 5 | * distribute this software, either in source code form or as a compiled 6 | * binary, for any purpose, commercial or non-commercial, and by any 7 | * means. 8 | * 9 | * In jurisdictions that recognize copyright laws, the author or authors 10 | * of this software dedicate any and all copyright interest in the 11 | * software to the public domain. We make this dedication for the benefit 12 | * of the public at large and to the detriment of our heirs and 13 | * successors. We intend this dedication to be an overt act of 14 | * relinquishment in perpetuity of all present and future rights to this 15 | * software under copyright law. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | * 25 | * For more information, please refer to . 26 | */ 27 | 28 | package hm.binkley.spring.axon.query; 29 | 30 | import hm.binkley.spring.axon.query.BasicWithCustomTestConfiguration 31 | .CustomCommandBus; 32 | import hm.binkley.spring.axon.query.BasicWithCustomTestConfiguration 33 | .CustomEventBus; 34 | import org.axonframework.commandhandling.CommandBus; 35 | import org.axonframework.eventhandling.EventBus; 36 | import org.junit.Test; 37 | import org.junit.runner.RunWith; 38 | import org.springframework.beans.factory.annotation.Autowired; 39 | import org.springframework.boot.test.SpringApplicationConfiguration; 40 | import org.springframework.test.annotation.DirtiesContext; 41 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 42 | 43 | import static org.assertj.core.api.Assertions.assertThat; 44 | 45 | @DirtiesContext 46 | @SpringApplicationConfiguration( 47 | classes = BasicWithCustomTestConfiguration.class) 48 | @RunWith(SpringJUnit4ClassRunner.class) 49 | public final class BasicIWithCustomT { 50 | @Autowired 51 | private CommandBus commandBus; 52 | @Autowired 53 | private EventBus eventBus; 54 | 55 | @Test 56 | public void shouldWireCustomCommandBus() { 57 | assertThat(commandBus).isInstanceOf(CustomCommandBus.class); 58 | } 59 | 60 | @Test 61 | public void shouldWireCustomEventBus() { 62 | assertThat(eventBus).isInstanceOf(CustomEventBus.class); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /axon-spring-boot-starter/src/test/java/hm/binkley/spring/axon/query/BasicTestConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free and unencumbered software released into the public domain. 3 | * 4 | * Anyone is free to copy, modify, publish, use, compile, sell, or 5 | * distribute this software, either in source code form or as a compiled 6 | * binary, for any purpose, commercial or non-commercial, and by any 7 | * means. 8 | * 9 | * In jurisdictions that recognize copyright laws, the author or authors 10 | * of this software dedicate any and all copyright interest in the 11 | * software to the public domain. We make this dedication for the benefit 12 | * of the public at large and to the detriment of our heirs and 13 | * successors. We intend this dedication to be an overt act of 14 | * relinquishment in perpetuity of all present and future rights to this 15 | * software under copyright law. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | * 25 | * For more information, please refer to . 26 | */ 27 | 28 | package hm.binkley.spring.axon.query; 29 | 30 | import org.axonframework.eventstore.EventStore; 31 | import org.axonframework.eventstore.supporting.VolatileEventStore; 32 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 33 | import org.springframework.context.annotation.Bean; 34 | import org.springframework.context.annotation.Configuration; 35 | 36 | @Configuration 37 | @EnableAutoConfiguration 38 | public class BasicTestConfiguration { 39 | @Bean 40 | public EventStore eventStore() { 41 | return new VolatileEventStore(); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /axon-spring-boot-starter/src/test/java/hm/binkley/spring/axon/query/BasicWithCustomTestConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free and unencumbered software released into the public domain. 3 | * 4 | * Anyone is free to copy, modify, publish, use, compile, sell, or 5 | * distribute this software, either in source code form or as a compiled 6 | * binary, for any purpose, commercial or non-commercial, and by any 7 | * means. 8 | * 9 | * In jurisdictions that recognize copyright laws, the author or authors 10 | * of this software dedicate any and all copyright interest in the 11 | * software to the public domain. We make this dedication for the benefit 12 | * of the public at large and to the detriment of our heirs and 13 | * successors. We intend this dedication to be an overt act of 14 | * relinquishment in perpetuity of all present and future rights to this 15 | * software under copyright law. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | * 25 | * For more information, please refer to . 26 | */ 27 | 28 | package hm.binkley.spring.axon.query; 29 | 30 | import org.axonframework.commandhandling.CommandBus; 31 | import org.axonframework.commandhandling.SimpleCommandBus; 32 | import org.axonframework.eventhandling.EventBus; 33 | import org.axonframework.eventhandling.SimpleEventBus; 34 | import org.axonframework.eventstore.EventStore; 35 | import org.axonframework.eventstore.supporting.VolatileEventStore; 36 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 37 | import org.springframework.context.annotation.Bean; 38 | import org.springframework.context.annotation.Configuration; 39 | 40 | @Configuration 41 | @EnableAutoConfiguration 42 | public class BasicWithCustomTestConfiguration { 43 | @Bean 44 | public EventStore eventStore() { 45 | return new VolatileEventStore(); 46 | } 47 | 48 | @Bean 49 | public CommandBus customCommandBus() { 50 | return new CustomCommandBus(); 51 | } 52 | 53 | @Bean 54 | public EventBus customEventBus() { 55 | return new CustomEventBus(); 56 | } 57 | 58 | static final class CustomCommandBus 59 | extends SimpleCommandBus {} 60 | 61 | static final class CustomEventBus 62 | extends SimpleEventBus {} 63 | } 64 | -------------------------------------------------------------------------------- /axon-spring-boot-starter/src/test/java/hm/binkley/spring/axon/repositories/RepositoriesIT.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free and unencumbered software released into the public domain. 3 | * 4 | * Anyone is free to copy, modify, publish, use, compile, sell, or 5 | * distribute this software, either in source code form or as a compiled 6 | * binary, for any purpose, commercial or non-commercial, and by any 7 | * means. 8 | * 9 | * In jurisdictions that recognize copyright laws, the author or authors 10 | * of this software dedicate any and all copyright interest in the 11 | * software to the public domain. We make this dedication for the benefit 12 | * of the public at large and to the detriment of our heirs and 13 | * successors. We intend this dedication to be an overt act of 14 | * relinquishment in perpetuity of all present and future rights to this 15 | * software under copyright law. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | * 25 | * For more information, please refer to . 26 | */ 27 | 28 | package hm.binkley.spring.axon.repositories; 29 | 30 | import org.axonframework.eventsourcing.EventSourcingRepository; 31 | import org.axonframework.repository.Repository; 32 | import org.junit.Test; 33 | import org.junit.runner.RunWith; 34 | import org.springframework.beans.factory.annotation.Autowired; 35 | import org.springframework.beans.factory.annotation.Qualifier; 36 | import org.springframework.boot.test.SpringApplicationConfiguration; 37 | import org.springframework.test.annotation.DirtiesContext; 38 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 39 | 40 | import static org.assertj.core.api.Assertions.assertThat; 41 | 42 | @DirtiesContext 43 | @RunWith(SpringJUnit4ClassRunner.class) 44 | @SpringApplicationConfiguration(classes = RepositoriesTestConfiguration.class) 45 | public final class RepositoriesIT { 46 | @Autowired 47 | @Qualifier("repositoriesTestAggregateRootRepository") 48 | private EventSourcingRepository repository; 49 | @Autowired 50 | @Qualifier("repositoriesTestAggregateRootRepository") 51 | private Repository duplicate; 52 | 53 | @Test 54 | public void shouldWireRepository() { 55 | assertThat(repository).isNotNull(); 56 | } 57 | 58 | @Test 59 | public void shouldCreateSingleton() { 60 | assertThat(duplicate).isSameAs(repository); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /axon-spring-boot-starter/src/test/java/hm/binkley/spring/axon/repositories/RepositoriesTestAggregateRoot.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free and unencumbered software released into the public domain. 3 | * 4 | * Anyone is free to copy, modify, publish, use, compile, sell, or 5 | * distribute this software, either in source code form or as a compiled 6 | * binary, for any purpose, commercial or non-commercial, and by any 7 | * means. 8 | * 9 | * In jurisdictions that recognize copyright laws, the author or authors 10 | * of this software dedicate any and all copyright interest in the 11 | * software to the public domain. We make this dedication for the benefit 12 | * of the public at large and to the detriment of our heirs and 13 | * successors. We intend this dedication to be an overt act of 14 | * relinquishment in perpetuity of all present and future rights to this 15 | * software under copyright law. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | * 25 | * For more information, please refer to . 26 | */ 27 | 28 | package hm.binkley.spring.axon.repositories; 29 | 30 | import org.axonframework.eventsourcing.annotation.AbstractAnnotatedAggregateRoot; 31 | import org.kohsuke.MetaInfServices; 32 | 33 | @MetaInfServices 34 | public class RepositoriesTestAggregateRoot 35 | extends AbstractAnnotatedAggregateRoot {} 36 | -------------------------------------------------------------------------------- /axon-spring-boot-starter/src/test/java/hm/binkley/spring/axon/repositories/RepositoriesTestConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free and unencumbered software released into the public domain. 3 | * 4 | * Anyone is free to copy, modify, publish, use, compile, sell, or 5 | * distribute this software, either in source code form or as a compiled 6 | * binary, for any purpose, commercial or non-commercial, and by any 7 | * means. 8 | * 9 | * In jurisdictions that recognize copyright laws, the author or authors 10 | * of this software dedicate any and all copyright interest in the 11 | * software to the public domain. We make this dedication for the benefit 12 | * of the public at large and to the detriment of our heirs and 13 | * successors. We intend this dedication to be an overt act of 14 | * relinquishment in perpetuity of all present and future rights to this 15 | * software under copyright law. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | * 25 | * For more information, please refer to . 26 | */ 27 | 28 | package hm.binkley.spring.axon.repositories; 29 | 30 | import org.axonframework.eventstore.EventStore; 31 | import org.axonframework.eventstore.supporting.VolatileEventStore; 32 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 33 | import org.springframework.context.annotation.Bean; 34 | import org.springframework.context.annotation.Configuration; 35 | 36 | @Configuration 37 | @EnableAutoConfiguration 38 | public class RepositoriesTestConfiguration { 39 | @Bean 40 | public EventStore eventStore() { 41 | return new VolatileEventStore(); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /axon-spring-boot-testing/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | 6 | hm.binkley 7 | axon-spring-boot-starter-parent 8 | 5 9 | 10 | 11 | axon-spring-boot-testing 12 | 13 | Spring Boot/Axon Starter - Shared Testing 14 | 15 | -------------------------------------------------------------------------------- /axon-spring-boot-testing/src/main/java/hm/binkley/spring/axon/WorkAroundJavadoc.java: -------------------------------------------------------------------------------- 1 | package hm.binkley.spring.axon; 2 | 3 | /** 4 | * {@code WorkAroundJavadoc} is a hack for javadoc. 5 | * 6 | * @author B. K. Oxley (binkley) 7 | * @todo Find better solution 8 | */ 9 | public final class WorkAroundJavadoc {} 10 | -------------------------------------------------------------------------------- /axon-spring-boot-testing/src/main/java/hm/binkley/spring/axon/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This is free and unencumbered software released into the public domain. 3 | * 4 | * Anyone is free to copy, modify, publish, use, compile, sell, or 5 | * distribute this software, either in source code form or as a compiled 6 | * binary, for any purpose, commercial or non-commercial, and by any 7 | * means. 8 | * 9 | * In jurisdictions that recognize copyright laws, the author or authors 10 | * of this software dedicate any and all copyright interest in the 11 | * software to the public domain. We make this dedication for the benefit 12 | * of the public at large and to the detriment of our heirs and 13 | * successors. We intend this dedication to be an overt act of 14 | * relinquishment in perpetuity of all present and future rights to this 15 | * software under copyright law. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | * 25 | * For more information, please refer to . 26 | */ 27 | 28 | /** 29 | * The axon-spring-boot-testing module is for test support of other modules. 30 | * Do not use this module directly. 31 | * 32 | * @author B. K. Oxley (binkley) 33 | */ 34 | package hm.binkley.spring.axon; 35 | -------------------------------------------------------------------------------- /axon-spring-boot-testing/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | main: 3 | show-banner: false 4 | -------------------------------------------------------------------------------- /axon-spring-boot-testing/src/main/resources/logback-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /maven-version-rules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | (?i).*Alpha(?:-?\d+)? 10 | (?i).*Beta(?:-?\d+)? 11 | (?i).*-B(?:-?\d+)? 12 | (?i).*RC(?:-?\d+)? 13 | (?i).*CR(?:-?\d+)? 14 | (?i).*M(?:-?\d+)? 15 | 16 | 17 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 1.3.3.RELEASE 9 | 10 | 11 | hm.binkley 12 | axon-spring-boot-starter-parent 13 | 5 14 | pom 15 | 16 | Spring Boot/Axon Starter - Parent 17 | 18 | 19 | 20 | B. K. Oxley (binkley) 21 | binkley@alumni.rice.edu 22 | https://binkley.blogspot.com 23 | The Oxley Family 24 | 25 | owner 26 | 27 | America/Chicago 28 | 29 | 30 | 31 | 32 | 33 | Public Domain 34 | http://unlicense.org/ 35 | repo 36 | 37 | 38 | 39 | 40 | Github 41 | https://github.com/binkley/spring-boot-starter-axon/issues 42 | 43 | 44 | 45 | Travis 46 | https://travis-ci.org/binkley/spring-boot-starter-axon 47 | 48 | 49 | 50 | 51 | scm:git:git://github.com/binkley/spring-boot-starter-axon.git 52 | 53 | 54 | scm:git:git@github.com:binkley/spring-boot-starter-axon.git 55 | 56 | https://github.com/binkley/spring-boot-starter-axon 57 | 58 | 59 | 60 | 61 | ossrh 62 | https://oss.sonatype.org/content/repositories/snapshots 63 | 64 | 65 | ossrh 66 | 67 | https://oss.sonatype.org/service/local/staging/deploy/maven2 68 | 69 | 70 | 71 | 72 | 73 | axon-spring-boot-testing 74 | axon-spring-boot-starter-query 75 | axon-spring-boot-starter-clustering-eventbus 76 | axon-spring-boot-starter-springmessaging 77 | axon-spring-boot-starter 78 | axon-spring-boot-starter-distributed-commandbus 79 | axon-spring-boot-starter-monitoring 80 | 81 | 82 | 83 | 84 | 3.3.0 85 | 2.4.4 86 | 1.2 87 | 1.0-beta-4 88 | false 89 | false 90 | UTF-8 91 | 1.8 92 | 1.0-m5.1 93 | 3.6.8.Final 94 | 4.12 95 | 1.16.6 96 | 3.5.1 97 | 2.10 98 | 1.4.1 99 | 2.6 100 | 2.10.3 101 | 2.4 102 | 2.19.1 103 | true 104 | 1.7 105 | 1.6.6 106 | 1.0.2 107 | ${java.charset} 108 | ${java.charset} 109 | ${java.charset} 110 | ${java.charset} 111 | false 112 | 2.2 113 | 114 | 115 | 116 | 117 | 118 | 119 | ${project.groupId} 120 | axon-spring-boot-testing 121 | ${project.version} 122 | test 123 | 124 | 125 | ${project.groupId} 126 | axon-spring-boot-starter-query 127 | ${project.version} 128 | 129 | 130 | ${project.groupId} 131 | axon-spring-boot-starter 132 | ${project.version} 133 | 134 | 135 | ${project.groupId} 136 | axon-spring-boot-starter-clustering-eventbus 137 | 138 | ${project.version} 139 | 140 | 141 | org.axonframework 142 | axon-core 143 | ${axon.version} 144 | 145 | 146 | javax.persistence 147 | persistence-api 148 | ${persistence-api.version} 149 | 150 | 151 | org.axonframework 152 | axon-monitoring-jmx 153 | ${axon.version} 154 | runtime 155 | 156 | 157 | org.axonframework 158 | axon-distributed-commandbus 159 | ${axon.version} 160 | 161 | 162 | org.axonframework 163 | axon-springmessaging 164 | ${axon.version} 165 | 166 | 167 | org.jgroups 168 | jgroups 169 | ${jgroups.version} 170 | 171 | 172 | 173 | 174 | 175 | 176 | org.projectlombok 177 | lombok 178 | ${lombok.version} 179 | provided 180 | 181 | 182 | org.kohsuke.metainf-services 183 | metainf-services 184 | ${metainf-services.version} 185 | provided 186 | 187 | 188 | 189 | org.assertj 190 | assertj-core 191 | ${assertj.version} 192 | test 193 | 194 | 195 | junit 196 | junit 197 | ${junit.version} 198 | test 199 | 200 | 201 | org.hamcrest 202 | hamcrest-core 203 | 204 | 205 | 206 | 207 | org.springframework.boot 208 | spring-boot-starter-test 209 | test 210 | 211 | 212 | org.axonframework 213 | axon-test 214 | ${axon.version} 215 | test 216 | 217 | 218 | 219 | 220 | 221 | 222 | fr.jcgay.maven.plugins 223 | buildplan-maven-plugin 224 | ${buildplan-maven-plugin.version} 225 | 226 | 227 | external.atlassian.jgitflow 228 | jgitflow-maven-plugin 229 | ${jgitflow-maven-plugin.version} 230 | 231 | 232 | maven-enforcer-plugin 233 | ${maven-enforcer-plugin.version} 234 | 235 | 236 | org.codehaus.mojo 237 | extra-enforcer-rules 238 | ${extra-enforcer-rules.version} 239 | 240 | 241 | 242 | 243 | enforce 244 | 245 | 246 | 247 | 248 | true 249 | 250 | 251 | 252 | 253 | org.xmlpull.v1.XmlPullParser 254 | 255 | 256 | org.xmlpull.v1.XmlPullParserException 257 | 258 | 259 | 260 | javax.persistence.PersistenceContexts 261 | 262 | 263 | javax.persistence.PersistenceContext 264 | 265 | 266 | javax.persistence.PersistenceContextType 267 | 268 | 269 | javax.persistence.PersistenceUnits 270 | 271 | 272 | javax.persistence.PersistenceProperty 273 | 274 | 275 | javax.persistence.PersistenceUnit 276 | 277 | 278 | 279 | 280 | true 281 | 282 | 283 | ${java.version} 284 | 285 | 286 | 287 | 288 | ${java.version} 289 | 290 | 291 | 292 | 293 | enforce 294 | 295 | 296 | 297 | 298 | 299 | org.codehaus.mojo 300 | versions-maven-plugin 301 | ${versions-maven-plugin.version} 302 | 303 | 304 | file://${session.executionRootDirectory}/maven-version-rules.xml 305 | 306 | 307 | 308 | 309 | update-dependencies 310 | validate 311 | 312 | update-parent 313 | update-properties 314 | 315 | 316 | 317 | 318 | 319 | maven-dependency-plugin 320 | ${maven-dependency-plugin.version} 321 | 322 | true 323 | 324 | 325 | 326 | record-versions 327 | 328 | properties 329 | 330 | 331 | 332 | download-sources 333 | 334 | sources 335 | 336 | 337 | 338 | download-javadocs 339 | 340 | javadoc 341 | 342 | 343 | resolve 344 | 345 | 346 | 347 | analyze-or-die 348 | verify 349 | 350 | true 351 | true 352 | 353 | 354 | analyze 355 | 356 | 357 | 358 | 359 | 360 | maven-compiler-plugin 361 | ${maven-compiler-plugin.version} 362 | 363 | 364 | -parameters 365 | -Werror 366 | 367 | true 368 | ${java.version} 369 | ${java.version} 370 | 371 | 372 | 373 | maven-surefire-plugin 374 | ${maven-surefire.version} 375 | 376 | true 377 | 378 | 379 | 380 | maven-failsafe-plugin 381 | 382 | ${maven-surefire.version} 383 | 384 | 385 | 386 | integration-test 387 | verify 388 | 389 | 390 | 391 | 392 | 393 | maven-source-plugin 394 | ${maven-source-plugin.version} 395 | 396 | 397 | true 398 | true 399 | true 400 | 401 | true 402 | 403 | 404 | 405 | attach-sources 406 | verify 407 | 408 | jar 409 | test-jar 410 | 411 | 412 | 413 | 414 | 415 | maven-javadoc-plugin 416 | ${maven-javadoc-plugin.version} 417 | 418 | 419 | true 420 | true 421 | true 422 | 423 | true 424 | ${java.charset} 425 | true 426 | true 427 | true 428 | 429 | 430 | todo 431 | a 432 | Pending: 433 | 434 | 435 | true 436 | true 437 | 438 | 439 | 440 | attach-javadocs 441 | verify 442 | 443 | jar 444 | 445 | 446 | 447 | 448 | 449 | maven-jar-plugin 450 | ${maven-jar-plugin.version} 451 | 452 | true 453 | 454 | 455 | 456 | 457 | test-jar 458 | 459 | 460 | 461 | 462 | 463 | org.sonatype.plugins 464 | nexus-staging-maven-plugin 465 | ${nexus-staging-maven-plugin.version} 466 | true 467 | 468 | ossrh 469 | https://oss.sonatype.org/ 470 | true 471 | 472 | 473 | 474 | 475 | 476 | --------------------------------------------------------------------------------