SpringHttpCommandBusConnector /spring-command-bus-connector/command 404 error

Hey,

I’m working on axon with two deployed microservices instances. For the command communication, i’m using the DistributedCommandBus over spring cloud (with fabric8 deps).

I’m stuck on the following error that occurres while one MS-1 trying to dispatch a command to the second one MS-2:

org.axonframework.commandhandling.distributed.CommandDispatchException: An exception occurred while dispatching a command or its result
	at org.axonframework.extensions.springcloud.commandhandling.SpringHttpCommandBusConnector.lambda$send$2(SpringHttpCommandBusConnector.java:155) ~[axon-springcloud-4.6.0.jar:4.6.0]
	at org.axonframework.common.DirectExecutor.execute(DirectExecutor.java:42) ~[axon-messaging-4.6.0.jar:4.6.0]
	at org.axonframework.extensions.springcloud.commandhandling.SpringHttpCommandBusConnector.send(SpringHttpCommandBusConnector.java:147) ~[axon-springcloud-4.6.0.jar:4.6.0]
	at org.axonframework.commandhandling.distributed.DistributedCommandBus.dispatch(DistributedCommandBus.java:183) ~[axon-messaging-4.6.0.jar:4.6.0]
	at org.axonframework.commandhandling.gateway.AbstractCommandGateway.send(AbstractCommandGateway.java:76) ~[axon-messaging-4.6.0.jar:4.6.0]
	at org.axonframework.commandhandling.gateway.DefaultCommandGateway.send(DefaultCommandGateway.java:83) ~[axon-messaging-4.6.0.jar:4.6.0]
	at org.axonframework.commandhandling.gateway.DefaultCommandGateway.sendAndWait(DefaultCommandGateway.java:100) ~[axon-messaging-4.6.0.jar:4.6.0]
	at io.test.modules.order.infra.grpc.GrpcOrderApi.createOrder(GrpcOrderApi.java:36) ~[classes/:na]
	at io.test.order.OrderApiGrpc$MethodHandlers.invoke(OrderApiGrpc.java:343) ~[classes/:na]
	at io.grpc.stub.ServerCalls$UnaryServerCallHandler$UnaryServerCallListener.onHalfClose(ServerCalls.java:182) ~[grpc-stub-1.50.0.jar:1.50.0]
	at io.grpc.PartialForwardingServerCallListener.onHalfClose(PartialForwardingServerCallListener.java:35) ~[grpc-api-1.50.0.jar:1.50.0]
	at io.grpc.ForwardingServerCallListener.onHalfClose(ForwardingServerCallListener.java:23) ~[grpc-api-1.50.0.jar:1.50.0]
	at io.grpc.ForwardingServerCallListener$SimpleForwardingServerCallListener.onHalfClose(ForwardingServerCallListener.java:40) ~[grpc-api-1.50.0.jar:1.50.0]
	at org.lognet.springboot.grpc.MessageBlockingServerCallListener.onHalfClose(MessageBlockingServerCallListener.java:21) ~[grpc-spring-boot-starter-4.9.0.jar:na]
	at org.lognet.springboot.grpc.recovery.GRpcExceptionHandlerInterceptor$3.onHalfClose(GRpcExceptionHandlerInterceptor.java:85) ~[grpc-spring-boot-starter-4.9.0.jar:na]
	at io.grpc.internal.ServerCallImpl$ServerStreamListenerImpl.halfClosed(ServerCallImpl.java:355) ~[grpc-core-1.50.0.jar:1.50.0]
	at io.grpc.internal.ServerImpl$JumpToApplicationThreadServerStreamListener$1HalfClosed.runInContext(ServerImpl.java:867) ~[grpc-core-1.50.0.jar:1.50.0]
	at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37) ~[grpc-core-1.50.0.jar:1.50.0]
	at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:133) ~[grpc-core-1.50.0.jar:1.50.0]
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[na:na]
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[na:na]
	at java.base/java.lang.Thread.run(Thread.java:833) ~[na:na]
Caused by: org.springframework.web.client.HttpClientErrorException$NotFound: 404 : "{"timestamp":"2022-10-24T09:46:48.882+00:00","status":404,"error":"Not Found","path":"/spring-command-bus-connector/command"}"
	at org.springframework.web.client.HttpClientErrorException.create(HttpClientErrorException.java:113) ~[spring-web-5.3.23.jar:5.3.23]
	at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:168) ~[spring-web-5.3.23.jar:5.3.23]
	at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:122) ~[spring-web-5.3.23.jar:5.3.23]
	at org.springframework.web.client.ResponseErrorHandler.handleError(ResponseErrorHandler.java:63) ~[spring-web-5.3.23.jar:5.3.23]
	at org.springframework.web.client.RestTemplate.handleResponse(RestTemplate.java:819) ~[spring-web-5.3.23.jar:5.3.23]
	at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:777) ~[spring-web-5.3.23.jar:5.3.23]
	at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:751) ~[spring-web-5.3.23.jar:5.3.23]
	at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:651) ~[spring-web-5.3.23.jar:5.3.23]
	at org.axonframework.extensions.springcloud.commandhandling.SpringHttpCommandBusConnector.sendRemotely(SpringHttpCommandBusConnector.java:189) ~[axon-springcloud-4.6.0.jar:4.6.0]
	at org.axonframework.extensions.springcloud.commandhandling.SpringHttpCommandBusConnector.lambda$send$2(SpringHttpCommandBusConnector.java:150) ~[axon-springcloud-4.6.0.jar:4.6.0]
	... 21 common frames omitted

It supposed that the annotated PostMapping method “receiveCommand” from the auto-configured SpringHttpCommandBusConnector bean is not registered by spring on the MS-2. I don’t why, because the other endpoint GetMapping ‘/member-capabilities’ is well registered from the MemberCapabilitiesController bean.

Workaround:

If I override on my side the SpringHttpCommandBusConnector (copy/paste from the SpringCloudAutoConfiguration) on my own config class it works.

It seems this issue already occurred on the past and has been fixed and I don’t why I’m facing on:

I’m working with these version :

  • Mac Os: 11.2
  • java 17
  • spring boot 2.7.4
  • axon-spring-boot-starter:4.6.0
  • axon-springcloud-spring-boot-starter: 4.6.0

Help will be appreciate,
Regards

Firstly, welcome to the forum, @Yann_Perthuis!
I hope your journey with Axon Framework and the Spring Cloud Extension has been pleasant so far.
With the exception of this predicament, of course.

Coming to the point at hand, it’s troublesome to see this problem pops up again after five+ years.
If I’m to guess, perhaps the newer version of Spring is causing wiring changes.

To check whether I could replay the faulty behavior you’re seeing, I started the Spring Cloud Extension Sample.
Sadly enough (at least for figuring out the issue), this works completely as intended.

Just a thought, but perhaps you can adjust the sample we have to align more with your scenario, @Yann_Perthuis? By doing so, you may be able to deduce what the difference is and, thus, where the problem lies.

Sorry to be unable to provide you with a more concrete answer right now, though.
Nonetheless, I do hope this provides some guidance.