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 to Spring 6 #778

Open
lgklein opened this issue Oct 26, 2022 · 22 comments
Open

Support to Spring 6 #778

lgklein opened this issue Oct 26, 2022 · 22 comments
Labels
enhancement A feature request or improvement

Comments

@lgklein
Copy link

lgklein commented Oct 26, 2022

In November we will have the release of spring framework 6.0 and Boot 3.0, both with AOT integrated. Would be very nice to have support for this new version.

@lgklein lgklein added the enhancement A feature request or improvement label Oct 26, 2022
@ST-DDT
Copy link
Collaborator

ST-DDT commented Oct 26, 2022

We got a PR for the new auto config files used in Spring Boot 3 #775.
Is there anything else we "need" to support/for compatibility?

As for AOT integration it is tracked here: https://github.com/yidongnan/grpc-spring-boot-starter/issues/577
Without external help, I won't have a release ready at that time.

@dsyer
Copy link
Contributor

dsyer commented Dec 8, 2022

The change in #775 works for me. AOT also works fine, but there's a missing hint for netty (I will try and get it added to the metadata catalog) and you have to use the non-shaded grpc jars. Sample here: https://github.com/dsyer/native-grpc.

@lgklein
Copy link
Author

lgklein commented Dec 16, 2022

Hello @dsyer and @ST-DDT tks for your responses! With both yours examples i was able to make the server works (even with the netty-shaddy... not too much trouble with that), but the clients annotated with @GrpcClient(value="xpto") is always null... Maybe you guys have a example of the client too? (I put all autoconfiguration on the imports file likme ST-DDT point)

@lgklein
Copy link
Author

lgklein commented Dec 16, 2022

If anyone need it too, for make netty-shaded works, i only need to put this dependency com.google.cloud:native-image-suporte:0.14.1 on pom and set the build args with: --initialize-at-run-time=io.grpc.netty.shaded.io.netty.internal.tcnative.CertificateCompressionAlgo

@dsyer
Copy link
Contributor

dsyer commented Dec 16, 2022

There is a client in the test in my PR: oracle/graalvm-reachability-metadata#148 (see metadata/io.grpc/grpc-netty/1.51.0/reflect-config.json).

@lgklein
Copy link
Author

lgklein commented Dec 21, 2022

Tks for the example @dsyer, but saddly this is not enough...
I was abble to make it work, but this is not out of the box:

The problem is that all attribute annotated with @GrpcClient is always null. Debbuing the GrpcClientBeanPostProcessor class, i notice that the field was never there. Example:

In a class ContratosClienteClient:
@Service public class ContratosClienteClient { @GrpcClient(value = "xxxx") ContratosClienteBlockingStub stubListaContratos; @Autowired private DetalhesContratoMapper mapper;

The method GrpcClientBeanPostProcessor.processFields only bring me the "mapper" attribute...

Looking in the reflect-config.json that the spring generate, we have this:

{ "name": "xxxx.xxxx.xxxx.ContratosClienteClient", "fields": [ { "name": "mapper" } ], "queriedMethods": [ { "name": "<init>", "parameterTypes": [ ] } ] }

So, to be abble to make this works i was obligated to create another config:
{ "name" : "xxxx.xxxx.xxxx.ContratosClienteClient", "allDeclaredConstructors" : true, "allPublicConstructors" : true, "allDeclaredMethods" : true, "allPublicMethods" : true, "allPublicFields" : true, "allDeclaredFields" : true, "methods" : [ { "name" : "<init>", "parameterTypes" : [ ] } ] }

This work around is really simple in the end, but probably only the autoconfiguration put in .imports is not enough for spring boot 3.0 AOT. This problem doens't happen in JIT formatt, only in AOT.

@ST-DDT FYK.

@ST-DDT
Copy link
Collaborator

ST-DDT commented Dec 21, 2022

This work around is really simple in the end, but probably only the autoconfiguration put in .imports is not enough for spring boot 3.0 AOT. This problem doens't happen in JIT formatt, only in AOT.

Yeah, I know. I hope that I can convince (and potentially PR) protobuf/grpc to generate the required configs automatically for their part, so we only have to check our parts here.

@chaitanya87
Copy link

There is one more incompatibility with Spring 6

SocketUtils class has been removed from Spring 6 (spring-projects/spring-framework#28054) which is still used in net.devh.boot.grpc.server.config.GrpcServerProperties class.

Is there any plans to replace SocketUtils?

@dsyer
Copy link
Contributor

dsyer commented Jan 19, 2023

I would open a separate issue about that if I were you.

@dsyer
Copy link
Contributor

dsyer commented Apr 3, 2023

We also need #829 and #835. I think with #826 that will make everything pretty usable in Spring Boot 3.

@marcindabrowski
Copy link
Contributor

Any ETA on support for Spring 6?

@dsyer
Copy link
Contributor

dsyer commented May 16, 2023

It works pretty well already actually, but those issues I mentioned above would need to be addressed to bring absolutely everything up to date.

@genuss
Copy link
Contributor

genuss commented May 16, 2023

I can confirm, it basically works with some minor issues.

@SilviyaPBrayanova
Copy link

Can some of you point me to an example of application based on Spring Boot 3 using the grpc-spring-boot-starter (2.14.0.RELEASE)?

@dsyer
Copy link
Contributor

dsyer commented May 17, 2023

There's a small sample in my fork: https://github.com/dsyer/grpc-spring-boot-starter/tree/springboot3. Also a standalone one at https://github.com/dsyer/native-grpc (linked to above in a comment already).

@lgklein
Copy link
Author

lgklein commented May 17, 2023

@SilviyaPBrayanova I suggest you look and test everything that was said in this topic, the @dsyer examples really work in very simple scenarios, depending on what you are doing there, some other configurations will be necessary... But nothing that is not simple to do.

@gebizhuxiaowang
Copy link

After adding org.springframework.boot.autoconfigure.AutoConfiguration.imports, the net.devh.boot.grpc.server.autoconfigure.GrpcMetadataZookeeperConfiguration is not initialized properly, resulting in missing grpc port information in the Metadata registered to nacos. What should I do about this problem? @ST-DDT @dsyer @yidongnan

@dsyer
Copy link
Contributor

dsyer commented May 30, 2023

Did you copy the AutoConfiguration.imports from master? You might need to provide a few more details about what didn't work.

@marcindabrowski
Copy link
Contributor

For me, it started to work after adding @ImportAutoConfiguration(GrpcClientAutoConfiguration.class) to my configuration class.

@gebizhuxiaowang
Copy link

AutoConfiguration.imports

net.devh.boot.grpc.client.autoconfigure.GrpcClientAutoConfiguration
net.devh.boot.grpc.client.autoconfigure.GrpcClientMetricAutoConfiguration
net.devh.boot.grpc.client.autoconfigure.GrpcClientHealthAutoConfiguration
net.devh.boot.grpc.client.autoconfigure.GrpcClientSecurityAutoConfiguration
net.devh.boot.grpc.client.autoconfigure.GrpcClientTraceAutoConfiguration
net.devh.boot.grpc.client.autoconfigure.GrpcDiscoveryClientAutoConfiguration

net.devh.boot.grpc.common.autoconfigure.GrpcCommonCodecAutoConfiguration
net.devh.boot.grpc.common.autoconfigure.GrpcCommonTraceAutoConfiguration

net.devh.boot.grpc.server.autoconfigure.GrpcAdviceAutoConfiguration
net.devh.boot.grpc.server.autoconfigure.GrpcHealthServiceAutoConfiguration
net.devh.boot.grpc.server.autoconfigure.GrpcMetadataConsulConfiguration
net.devh.boot.grpc.server.autoconfigure.GrpcMetadataEurekaConfiguration
net.devh.boot.grpc.server.autoconfigure.GrpcMetadataNacosConfiguration
net.devh.boot.grpc.server.autoconfigure.GrpcMetadataZookeeperConfiguration
net.devh.boot.grpc.server.autoconfigure.GrpcReflectionServiceAutoConfiguration
net.devh.boot.grpc.server.autoconfigure.GrpcServerAutoConfiguration
net.devh.boot.grpc.server.autoconfigure.GrpcServerFactoryAutoConfiguration
net.devh.boot.grpc.server.autoconfigure.GrpcServerMetricAutoConfiguration
net.devh.boot.grpc.server.autoconfigure.GrpcServerSecurityAutoConfiguration
net.devh.boot.grpc.server.autoconfigure.GrpcServerTraceAutoConfiguration

The init method in GrpcMetadataNacosConfiguration, which is not executed when the service is started


    @PostConstruct
    public void init() {
        if (this.nacosRegistration != null) {
            int port = this.grpcProperties.getPort();
            if (-1 != port) {
                this.nacosRegistration.getMetadata().put("gRPC_port", Integer.toString(port));
            }
        }

 

@dsyer Later, I will write the address of the project here

@MissakaI-ObjectOne
Copy link

After adding org.springframework.boot.autoconfigure.AutoConfiguration.imports, the net.devh.boot.grpc.server.autoconfigure.GrpcMetadataZookeeperConfiguration is not initialized properly, resulting in missing grpc port information in the Metadata registered to nacos. What should I do about this problem? @ST-DDT @dsyer @yidongnan

Try adding @EnableConfigurationProperties(value = {GrpcChannelsProperties.class})

For me with Spring Boot 3.1.2 the ConfigurationPropeties of GrpcChannelsProperties didn't load unless I add the above annotation.

@dsyer
Copy link
Contributor

dsyer commented Jul 27, 2023

I don't have any of those problems. Spring will happily call the legacy @PostConstruct, and the @ConfigurationProperties work the same as before. I haven't tried it with all the server metadata options, or with the client autoconfig, so I might be missing something. If no-one wants to post a sample project to reproduce the issue, there doesn't seem much hope that it will be resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A feature request or improvement
Projects
None yet
Development

No branches or pull requests

9 participants