zuul-route-cassandra-spring-cloud-starter

Spring Cloud Netflix Zuul Cassandra Store

License

License

Categories

Categories

Cassandra Data Databases Zuul Application Layer Libs Distributed Applications
GroupId

GroupId

io.jmnarloch
ArtifactId

ArtifactId

zuul-route-cassandra-spring-cloud-starter
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

zuul-route-cassandra-spring-cloud-starter
Spring Cloud Netflix Zuul Cassandra Store
Project URL

Project URL

https://github.com/jmnarloch/zuul-route-cassandra-spring-cloud-starter
Source Code Management

Source Code Management

https://github.com/jmnarloch/zuul-route-cassandra-spring-cloud-starter.git

Download zuul-route-cassandra-spring-cloud-starter

How to add to project

<!-- https://jarcasting.com/artifacts/io.jmnarloch/zuul-route-cassandra-spring-cloud-starter/ -->
<dependency>
    <groupId>io.jmnarloch</groupId>
    <artifactId>zuul-route-cassandra-spring-cloud-starter</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/io.jmnarloch/zuul-route-cassandra-spring-cloud-starter/
implementation 'io.jmnarloch:zuul-route-cassandra-spring-cloud-starter:1.0.0'
// https://jarcasting.com/artifacts/io.jmnarloch/zuul-route-cassandra-spring-cloud-starter/
implementation ("io.jmnarloch:zuul-route-cassandra-spring-cloud-starter:1.0.0")
'io.jmnarloch:zuul-route-cassandra-spring-cloud-starter:jar:1.0.0'
<dependency org="io.jmnarloch" name="zuul-route-cassandra-spring-cloud-starter" rev="1.0.0">
  <artifact name="zuul-route-cassandra-spring-cloud-starter" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.jmnarloch', module='zuul-route-cassandra-spring-cloud-starter', version='1.0.0')
)
libraryDependencies += "io.jmnarloch" % "zuul-route-cassandra-spring-cloud-starter" % "1.0.0"
[io.jmnarloch/zuul-route-cassandra-spring-cloud-starter "1.0.0"]

Dependencies

compile (3)

Group / Artifact Type Version
org.springframework.boot : spring-boot-configuration-processor Optional jar 1.2.5.RELEASE
org.springframework.cloud : spring-cloud-starter-zuul jar 1.0.3.RELEASE
org.springframework.data : spring-data-cassandra jar 1.2.2.RELEASE

test (6)

Group / Artifact Type Version
org.mockito : mockito-all jar 1.10.19
org.springframework.boot : spring-boot-starter-web jar 1.2.5.RELEASE
junit : junit jar 4.12
org.springframework.boot : spring-boot-starter-test jar 1.2.5.RELEASE
com.datastax.cassandra : cassandra-driver-core jar 2.1.7.1
org.cassandraunit : cassandra-unit-spring jar 2.1.9.2

Project Modules

There are no modules declared in this project.

Spring Cloud Zuul Route Cassandra Store

A Spring Cloud Cassandra store for Zuul routes.

Build Status Coverage Status

Features

Extends the Spring Cloud's ProxyRouteLocator with capabilities of loading routes out of the configured Cassandra database.

Instead of configuring your routes through zuul.routes like fallows:

zuul:
  ignoredServices: '*'
  routes:
    resource:
      path: /api/**
      serviceId: rest-service
    oauth2:
      path: /uaa/**
      serviceId: oauth2-service
      stripPrefix: false

You can store the routes in Cassandra.

Keep in mind that the other properties except for routes are still relevant.

zuul:
  ignoredServices: '*'
  store:
    cassandra:
      enabled: true

Setup

Add the Spring Cloud starter to your project:

<dependency>
  <groupId>io.jmnarloch</groupId>
  <artifactId>zuul-route-cassandra-spring-cloud-starter</artifactId>
  <version>1.0.0</version>
</dependency>

Connect to Cassandra and create a keyspace:

CREATE KEYSPACE IF NOT EXISTS zuul WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 3 };

USE zuul;

CREATE TABLE zuul_routes (
    id text,
    path text,
    service_id text,
    url text,
    strip_prefix boolean,
    retryable boolean,
    PRIMARY KEY(id)
);

Register CassandraOperations bean within your application:

@SpringBootApplication
public static class Application {

    @Bean
    public Cluster cluster() {
        return Cluster.builder()
                .addContactPoints(InetAddress.getLoopbackAddress())
                .withPort(9142)
                .build();
    }

    @Bean
    public CassandraOperations cassandraTemplate(Cluster cluster) {
        return new CassandraTemplate(cluster.connect("zuul"));
    }
}

Configure the Cassandra to be used for loading the Zuul routes:

zuul:
  store:
    cassandra:
      enabled: true

Finally enable the Zuul proxy with @EnableZuulProxyStore - use this annotation as a replacement for standard @EnableZuulProxy:

@EnableZuulProxyStore
@SpringBootApplication
public static class Application {

    ...
}

Properties

zuul.store.cassandra.enabled=true# false by default

License

Apache 2.0

Versions

Version
1.0.0