Skip to content
This repository was archived by the owner on Dec 7, 2018. It is now read-only.

Commit 2573af5

Browse files
committed
Make some minor adjustments to increase readability
Make some minor adjustments to increase readability #30
1 parent 62511b2 commit 2573af5

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

part-iii-infrastructure-components/command-dispatching.md

+2-6
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public class MyCommandDispatchInterceptor implements MessageDispatchInterceptor<
165165
private static final Logger LOGGER = LoggerFactory.getLogger(MyCommandDispatchInterceptor.class);
166166

167167
@Override
168-
public BiFunction<Integer, CommandMessage<?>, CommandMessage<?>> handle( List<? extends CommandMessage<?>> messages) {
168+
public BiFunction<Integer, CommandMessage<?>, CommandMessage<?>> handle(List<? extends CommandMessage<?>> messages) {
169169
return (index, command) -> {
170170
LOGGER.info("Dispatching a command {}.", command);
171171
return command;
@@ -179,9 +179,7 @@ public class CommandBusConfiguration {
179179

180180
public CommandBus configureCommandBus() {
181181
CommandBus commandBus = new SimpleCommandBus();
182-
183182
commandBus.registerDispatchInterceptor(new MyCommandDispatchInterceptor());
184-
185183
return commandBus;
186184
}
187185
}
@@ -209,7 +207,7 @@ Unlike Dispatch Interceptors, Handler Interceptors are invoked in the context of
209207

210208
Handler Interceptors are also typically used to manage transactions around the handling of a command. To do so, register a `TransactionManagingInterceptor`, which in turn is configured with a `TransactionManager` to start and commit \(or roll back\) the actual transaction.
211209

212-
Let's create a Message Handler Interceptor which will allow handling of commands that contain `axonUser` as a value for the `userId` field contained in the `MetaData`. If the `userId` is not present in the meta-data an exception will be thrown which will prevent the command from being handled. If the `userId`'s value does not match `axonUser`, we will not proceed through the chain.
210+
Let's create a Message Handler Interceptor which will only allow the handling of commands that contain `axonUser` as a value for the `userId` field in the `MetaData`. If the `userId` is not present in the meta-data, an exception will be thrown which will prevent the command from being handled. And if the `userId`'s value does not match `axonUser`, we will also not proceed up the chain.
213211

214212
```java
215213
public class MyCommandHandlerInterceptor implements MessageHandlerInterceptor<CommandMessage<?>> {
@@ -233,9 +231,7 @@ public class CommandBusConfiguration {
233231

234232
public CommandBus configureCommandBus() {
235233
CommandBus commandBus = new SimpleCommandBus();
236-
237234
commandBus.registerHandlerInterceptor(new MyCommandHandlerInterceptor());
238-
239235
return commandBus;
240236
}
241237
}

0 commit comments

Comments
 (0)