spring-cloud-gateway icon indicating copy to clipboard operation
spring-cloud-gateway copied to clipboard

JDBC routes repository

Open naivefun opened this issue 8 years ago • 24 comments

Seems there is only memory based implementation now, would be great if it supports persistable repository.

naivefun avatar Jun 16 '17 09:06 naivefun

Certainly, other implementations will be created. I plan on using spring-data repositories. Since the api is non-blocking, repositories like casandra, redis, mongo and couchbase will fit easier. JDBC will need more work.

spencergibb avatar Jun 16 '17 17:06 spencergibb

Spring Data JPA is using @Async to offer non-blocking API so maybe that's not a bad idea for now.

naivefun avatar Jun 17 '17 15:06 naivefun

JDBC is, by definition, blocking. @Async only moves execution to a thread pool.

spencergibb avatar Jun 17 '17 15:06 spencergibb

Indeed. Is there any other way to enable non-blocking for JDBC?

naivefun avatar Jun 18 '17 01:06 naivefun

@naivefun nope.

spencergibb avatar Jun 30 '17 23:06 spencergibb

whenever we update the routes, we have to restart the gateway server. How can we update the routes dynamically ? is there any way to fetch the routes through jdbc?

ghoddg avatar Feb 05 '18 12:02 ghoddg

You can publish a new RefreshRoutesEvent() so that its reloaded without a restart.

samtonyclarke avatar Feb 05 '18 13:02 samtonyclarke

@ghoddg or post to /actuator/gateway/refresh.

spencergibb avatar Feb 06 '18 02:02 spencergibb

Thanks Spencer, Do you have the reference implementation project on github with JDBC routes repository?

ghoddg avatar Feb 06 '18 04:02 ghoddg

As long as this issue is open, there is not one.

spencergibb avatar Feb 06 '18 04:02 spencergibb

@ghoddg not in an unrelated issue. Please ask on stack overflow or gitter.

spencergibb avatar Feb 12 '18 20:02 spencergibb

Hello @spencergibb ..can you help me understand on your above comment "or post to /actuator/gateway/refresh"

I have implemented my Config Server with JDBC backend and not GIT. Now, i am thinking how can I use my config server to dynamically update the routes defined in application.yaml

ghoddg avatar Feb 16 '18 05:02 ghoddg

@ghoddg do you have any work around yet?

Emmarock avatar Jun 14 '18 15:06 Emmarock

Hi @Emmarock we can add the routes in PROPERTIES table of config server and make the gateway as client of config server. Make sure config server should start before the gateway, so when you start gateway, it will load the configuration from config server.

Sample config script for one of service islike below, Insert into PROPERTIES (ID,APPLICATION,PROFILE,LABEL,KEY,VALUE) values (1,'api-gateway','jdbc','jdbc','zuul.routes.api.path','/api/**'); Insert into PROPERTIES (ID,APPLICATION,PROFILE,LABEL,KEY,VALUE) values (2,'api-gateway','jdbc','jdbc','zuul.routes.api.serviceId','ACCOUNT-SERVICE'); Insert into PROPERTIES (ID,APPLICATION,PROFILE,LABEL,KEY,VALUE) values (3,'api-gateway','jdbc','jdbc','zuul.routes.api.stripPrefix','true');

ghoddg avatar Jun 15 '18 09:06 ghoddg

@spencergibb When does this function be provided?

SoftwareKing avatar Jun 22 '18 02:06 SoftwareKing

@spencergibb ,How to implement dynamic routing? When will this be solved?It's been a long time

SoftwareKing avatar Jun 26 '18 02:06 SoftwareKing

Nothing has changed.

As long as this issue is open, there is not one.

spencergibb avatar Jun 26 '18 02:06 spencergibb

Which spring cloud gateway version is planned to support? @spencergibb

SoftwareKing avatar Jun 26 '18 03:06 SoftwareKing

It is not planned

spencergibb avatar Jun 26 '18 10:06 spencergibb

And probably won't be until there is a reactive jdbc solution for spring.

spencergibb avatar Jun 26 '18 10:06 spencergibb

I'm new to Spring cloud gateway and reactivate programming. As per my understanding, routes will get loaded into heap during the server startup or whatever we call refresh API(actuator). Blocking vs Non blocking JDBC driver(reactivate), does it have huge impact on performance if we use regular JDBC driver or am I missing something? @spencergibb

kvneswar avatar Oct 29 '18 15:10 kvneswar

what about spring data r2dbc?

dominik-kovacs avatar Mar 06 '24 14:03 dominik-kovacs

yup, r2dbc would be what we use for reactive gateway server

spencergibb avatar Mar 06 '24 14:03 spencergibb

Hi, Am not sure if this is relevant to the discussion above, but am using JDBC backend to store my Spring Gateway routes and have defined as in the screenshot attached

Screenshot 2024-07-17 at 00 11 03

I added routes to my MySQL table and called the [POST] Gateway-Service/actuator/refresh API to refresh the config, and the new routes were added automatically during runtime without the need for a Gateway-service restart

sarbesh avatar Jul 16 '24 19:07 sarbesh