Giter Club home page Giter Club logo

proteus-spring's Introduction

proteus-spring

Join the chat at https://gitter.im/netifi/general Build Status

A simple and easy mechanism for integrating the power of Netifi Proteus into your Spring Boot applications.

Examples

Please see the included demo projects for examples on how to configure and use Proteus with Spring applications.

Bugs and Feedback

For bugs, questions, and discussions please use the Github Issues.

License

Copyright 2019 Netifi Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

proteus-spring's People

Contributors

eddumelendez avatar flyinprogrammer avatar gregwhitaker avatar kbahr avatar olegdokuka avatar rdegnan avatar robertroeser avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

proteus-spring's Issues

Handshake timed out while trying to run Proteus Broker

I am trying "proteus-spring" demo applications and set up as per the readme file. When I try to run Proteus Broker with the following command, I get few warnings and time out error:
docker run -p 8001:8001 -p 7001:7001 -e BROKER_SERVER_OPTS="'-Dnetifi.authentication.0.accessKey=9007199254740991' '-Dnetifi.authentication.0.accessToken=kTBDVtfRBO4tHOnZzSyY5ym2kfY=' '-Dnetifi.broker.admin.accessKey=9007199254740991' '-Dnetifi.broker.admin.accessToken=kTBDVtfRBO4tHOnZzSyY5ym2kfY='" netifi/proteus

I am getting time out error as following:
ERROR r.n.r.PooledConnectionProvider [reactor-http-client-epoll-10] [id: 0xba34281b, L:/172.17.0.2:45026 - R:updates.netifi.io/52.229.25.216:443] Pooled connection observed an error
javax.net.ssl.SSLException: handshake timed out
at io.netty.handler.ssl.SslHandler.handshake(...)(Unknown Source) ~[netty-handler-4.1.29.Final.jar:4.1.29.Final]

I will appreciate assistance so that I can run demo applications to evaluate proteus. I am attaching my full console log of starting Proteus [Broker.
Proteus Broker Log.txt

Thanks
Nimesh

cleaning error messages

Right now if there is a missing properties a null pointer is throw - it would be nice to have cleaner error messages that mention the property that is missing

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'proteus' defined in com.netifi.proteus.springboot.config.ProteusAutoConfiguration: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [io.netifi.proteus.Proteus]: Factory method 'proteus' threw exception; nested exception is java.lang.NullPointerException
	at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:590) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1256) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1105) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:503) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
	at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:251) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1065) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
	at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:818) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
	at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:724) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
	... 24 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [io.netifi.proteus.Proteus]: Factory method 'proteus' threw exception; nested exception is java.lang.NullPointerException
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
	at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:582) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
	... 37 common frames omitted
Caused by: java.lang.NullPointerException: null
	at com.netifi.proteus.springboot.config.ProteusAutoConfiguration.proteus(ProteusAutoConfiguration.java:65) ~[proteus-spring-boot-autoconfigure-0.3.4.jar:na]
	at com.netifi.proteus.springboot.config.ProteusAutoConfiguration$$EnhancerBySpringCGLIB$$a461488d.CGLIB$proteus$0(<generated>) ~[proteus-spring-boot-autoconfigure-0.3.4.jar:na]
	at com.netifi.proteus.springboot.config.ProteusAutoConfiguration$$EnhancerBySpringCGLIB$$a461488d$$FastClassBySpringCGLIB$$50f9a76b.invoke(<generated>) ~[proteus-spring-boot-autoconfigure-0.3.4.jar:na]
	at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) ~[spring-core-5.0.7.RELEASE.jar:5.0.7.RELEASE]
	at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:361) ~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE]
	at com.netifi.proteus.springboot.config.ProteusAutoConfiguration$$EnhancerBySpringCGLIB$$a461488d.proteus(<generated>) ~[proteus-spring-boot-autoconfigure-0.3.4.jar:na]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_151]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_151]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_151]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_151]
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
	... 38 common frames omitted

maven support

Add an example that uses maven to build the proteus spring demo project.

Proteus Spring Boot Test Kit

What I found during writing/testing Proteus-Spring application is the lack of proper test-kit that allows to easily mock broker (possibly avoid it at all) and mock Proteus instance so the testing of the generated client/server can be setup in a few steps.

For now, to test the app, I have to do something like the following:

@RunWith(SpringRunner.class)
@SpringBootTest
public class UserAccessServiceApplicationTest {
    @Destination(group = "test", destination = "test")
    AccessKeyInfoServiceClient accessKeyInfoServiceClient;
    ...
    @TestConfiguration
    public static class TestConfig {

        @Bean
        public Proteus proteus() {
            Proteus proteus = Mockito.mock(Proteus.class);

            RequestHandlingRSocket requestHandlingRSocket = new RequestHandlingRSocket();
            Mockito.when(proteus.getAccesskey()).thenReturn(1L);
            Mockito.when(proteus.getGroupName()).thenReturn("test");
            Mockito.when(proteus.getDestination()).thenReturn("test");
            Mockito.when(proteus.addService(Mockito.any()))
                   .thenAnswer(a -> {
                       requestHandlingRSocket.addService(a.getArgument(0));
                       return proteus;
                   });
            Mockito.when(proteus.destination(Mockito.anyString(), Mockito.anyString()))
                   .thenReturn(new DefaultProteusSocket(Payload::retain, () -> requestHandlingRSocket));
            Mockito.when(proteus.group(Mockito.anyString()))
                   .thenReturn(new DefaultProteusSocket(Payload::retain, () -> requestHandlingRSocket));
            Mockito.when(proteus.onClose()).thenReturn(Mono.never());

            return proteus;
        }
    }

}

What I would like to see is something similar to annotation based test env setup like one in spring web -> @WebFluxTest/@WebMvcTest

Is this a working in progress?

➜  proteus-spring git:(master) ls
LICENSE                           gradle                            proteus-spring-core
README.md                         gradle.properties                 proteus-spring.iml
build.gradle                      gradlew                           settings.gradle
buildtravis.sh                    gradlew.bat                       src
codequality                       proteus-spring-boot-autoconfigure
demos                             proteus-spring-boot-starter
➜  proteus-spring git:(master) gradle bootRun
Starting a Gradle Daemon (subsequent builds will be faster)

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':demos:springboot-demo:client:bootRun'.
> Could not resolve all task dependencies for configuration ':demos:springboot-demo:client:runtimeClasspath'.
   > Could not find io.rsocket.rpc:rsocket-rpc-core:0.2.2.
     Required by:
         project :demos:springboot-demo:client > project :demos:springboot-demo:vowelcount-idl
         project :demos:springboot-demo:client > project :proteus-spring-boot-starter > project :proteus-spring-boot-autoconfigure > io.netifi.proteus:proteus-client:0.9.4

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
See https://docs.gradle.org/4.8.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 52s

Publishing build scan...
https://gradle.com/s/7pnyw3tauoqys

➜  proteus-spring git:(master)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.