Search in sources :

Example 1 with SmartLifecycleUpstreamManagerImpl

use of com.alibaba.spring.boot.rsocket.upstream.SmartLifecycleUpstreamManagerImpl in project alibaba-rsocket-broker by alibaba.

the class RSocketAutoConfiguration method rsocketUpstreamManager.

@Bean(initMethod = "init")
public UpstreamManager rsocketUpstreamManager(@Autowired RSocketRequesterSupport rsocketRequesterSupport) throws JwtTokenNotFoundException {
    SmartLifecycleUpstreamManagerImpl upstreamManager = new SmartLifecycleUpstreamManagerImpl(rsocketRequesterSupport);
    if (properties.getBrokers() != null && !properties.getBrokers().isEmpty()) {
        if (properties.getJwtToken() == null || properties.getJwtToken().isEmpty()) {
            throw new JwtTokenNotFoundException();
        }
        UpstreamCluster cluster = new UpstreamCluster(null, "*", null);
        cluster.setUris(properties.getBrokers());
        upstreamManager.add(cluster);
    }
    upstreamManager.setP2pServices(properties.getP2pServices());
    if (properties.getRoutes() != null && !properties.getRoutes().isEmpty()) {
        for (RoutingEndpoint route : properties.getRoutes()) {
            UpstreamCluster cluster = new UpstreamCluster(route.getGroup(), route.getService(), route.getVersion());
            cluster.setUris(route.getUris());
            upstreamManager.add(cluster);
        }
    }
    return upstreamManager;
}
Also used : RoutingEndpoint(com.alibaba.rsocket.route.RoutingEndpoint) SmartLifecycleUpstreamManagerImpl(com.alibaba.spring.boot.rsocket.upstream.SmartLifecycleUpstreamManagerImpl) JwtTokenNotFoundException(com.alibaba.spring.boot.rsocket.upstream.JwtTokenNotFoundException) UpstreamCluster(com.alibaba.rsocket.upstream.UpstreamCluster) Bean(org.springframework.context.annotation.Bean)

Aggregations

RoutingEndpoint (com.alibaba.rsocket.route.RoutingEndpoint)1 UpstreamCluster (com.alibaba.rsocket.upstream.UpstreamCluster)1 JwtTokenNotFoundException (com.alibaba.spring.boot.rsocket.upstream.JwtTokenNotFoundException)1 SmartLifecycleUpstreamManagerImpl (com.alibaba.spring.boot.rsocket.upstream.SmartLifecycleUpstreamManagerImpl)1 Bean (org.springframework.context.annotation.Bean)1