Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Springs @Ordered Annotation on GRpcServerRunner #126

Closed
MCLonips opened this issue Jul 26, 2019 · 4 comments
Closed

Support Springs @Ordered Annotation on GRpcServerRunner #126

MCLonips opened this issue Jul 26, 2019 · 4 comments
Labels
enhancement Auto-generates notes
Milestone

Comments

@MCLonips
Copy link

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.

@jvmlet
Copy link
Collaborator

jvmlet commented Jul 26, 2019

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.

@jvmlet
Copy link
Collaborator

jvmlet commented Jul 26, 2019

See GRpcServerInitializedEvent

@MCLonips
Copy link
Author

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

@jvmlet jvmlet added this to the 4.4.6 milestone Apr 27, 2021
@jvmlet jvmlet added the enhancement Auto-generates notes label Apr 27, 2021
@jvmlet
Copy link
Collaborator

jvmlet commented Apr 27, 2021

Controlled via grpc.start-up-phase property

@jvmlet jvmlet closed this as completed Apr 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Auto-generates notes
Projects
None yet
Development

No branches or pull requests

2 participants