You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm working with Spring Boots CommandLineRunner in my project to fill my application with some data after start. For that reason it is necessary to make a gRPC-Call. Your implementation of the GRpcServerRunner which is starting the gRPC-Server has the lowest order to be executed compared to all other CommandLineRunner. Without a working Server I am not able to make any gRPC-Calls after startup .
I did some research and found a Method to control the actual order of all CommandLineRunner
, Spring Boots @Ordered-Annotation. Is it possible to use it?
See my code-Snippet:
**
* Hosts embedded gRPC server.
*/
@Slf4j
@Order(value = Ordered.HIGHEST_PRECEDENCE) //<-- Add this annotation
public class GRpcServerRunner implements CommandLineRunner, DisposableBean {
....
}
The value HIGHEST_PRECEDENCE forces Spring Boot to execute your runner directly after Startup. This would give me the opportunity to do some gRPC-Calls in my Runner.
The text was updated successfully, but these errors were encountered:
I will check the order of servlet runner implemented by spring team and follow the same rules.
I would suggest you to add grpc-server- initialized event listener and execute your logic from there.
Seems to work for me to subscribe on ApplicationContext to listen to GRpcServerInitializedEvent.
This also seems to be the correct way for my application thank you 👍
Regardless you should think about the @Order-annotation to make sure gRPC-Server has the highest order and will be initialized first
I'm working with Spring Boots
CommandLineRunner
in my project to fill my application with some data after start. For that reason it is necessary to make a gRPC-Call. Your implementation of theGRpcServerRunner
which is starting the gRPC-Server has the lowest order to be executed compared to all otherCommandLineRunner
. Without a working Server I am not able to make any gRPC-Calls after startup .I did some research and found a Method to control the actual order of all
CommandLineRunner
, Spring Boots
@Ordered
-Annotation. Is it possible to use it?See my code-Snippet:
The value
HIGHEST_PRECEDENCE
forces Spring Boot to execute your runner directly after Startup. This would give me the opportunity to do some gRPC-Calls in myRunner
.The text was updated successfully, but these errors were encountered: