我有一个Spring Boot应用程序,通过Spring Cloud库使用Netflix Hystrix,一切正常.
我想覆盖Hystrix的一些基本属性,例如hystrix.threadpool.default.coreSize和/或hystrix.threadpool.default.maxQueueSize.不幸的是,我找不到一些开箱即用的Spring Boot属性来执行此操作,那么在应用程序启动时我需要做些什么才能设置这些属性?
如何在spring-cloud-starter-hystrix模块中设置这些属性?
我有两个弹簧启动应用程序.一个在端口8081上运行ZuulProxy服务器,并将对/ notification的所有请求转发到在端口8086上运行的另一个Spring引导应用程序(通知服务器).
zuul配置看起来像这样
zuul:
routes:
notification:
path: /notification/**
url: http://localhost:8086
Run Code Online (Sandbox Code Playgroud)
通知服务器代码如下所示
@RestController
public class JmsController {
private Logger log = Logger.getLogger(this.getClass());
private final List<SseEmitter> emitters = new ArrayList<>();
@Autowired
private JmsService jmsService;
@RequestMapping(value = "send", method = RequestMethod.POST, consumes= MediaType.APPLICATION_JSON_VALUE)
public NotificationDTO sendMessage(@RequestBody NotificationDTO dto){
jmsService.sendMessage(dto);
return dto;
}
@RequestMapping(path = "/stream", method = RequestMethod.GET)
public SseEmitter stream() throws IOException {
SseEmitter emitter = new SseEmitter();
emitters.add(emitter);
emitter.onCompletion(() -> emitters.remove(emitter));
return emitter;
}
@JmsListener(destination = "${queue.name}", containerFactory = "myJmsContainerFactory")
public …Run Code Online (Sandbox Code Playgroud) 我们目前拥有一个包含Weblogic 11g,Java 6,Apache WL插件和ZXTM的基础架构.我们的流量如下:
ZXTM >> Apache httpd (WL plugin) >> WL cluster >> Oracle DB (RAC)
Run Code Online (Sandbox Code Playgroud)
我们想要启动微服务并评估Netflix OSS/Spring云.Weblogic上的spring netflix云是否有任何复杂性与上面介绍的基础设施?以下是我们的发现.
我们对上面的upgardes很好.
感谢您是否可以分享您的经验和想法.(如果你不回答上面的所有问题,请不要紧,请分享你所知道的:))
通常,应用程序开发人员(以 J2EE 为例)在设计应用程序时不会优先考虑与基础结构相关的问题。很难与传统的非可编程基础设施交互。传统的方法是构建一个 .war 文件,然后可以在应用程序服务器(如 JBoss)中运行该文件。Spring 等传统框架(新版 Spring Cloud 除外)都以此为前提。现在,如果有一个容错的、弹性的部署运行时可用,例如由 Kubernetes 提供,那么似乎以同样的方式编写业务应用程序会忽略运行时提供的诸如调度之类的功能。一个具体的问题:应用程序从运行时(即 Kubernetes、Mesos 等)API 中对话(并从中受益)是典型的吗?如果是这样,你能举出一个很好的例子吗?
我是Zuul作为边缘服务器.所有请求都通过此边缘服务器传递.我有一个微服务A.A的所有Web服务都受基本身份验证保护.我们如何通过Zuul代理调用A b的服务?我应该为邮件添加标题吗?
我有一个Spring Cloud应用程序,用作Zuul Server(带有@EnableZuulProxy)注释.在这个阶段,我将/ api/*请求路由到正确的middletier服务,而所有其他请求都路由到演示服务,所以从配置pov看起来如下所示:
zuul:
ignoredServices: '*'
routes:
reservation-owner:
path: /api/service1
url: http://service1.net
--- here couple of other api mappings --
ui:
path: /**
url: http://presentation-service.net/
Run Code Online (Sandbox Code Playgroud)
这很有效,直到我想检查zuul代理上的任何Actuator端点.由于它们属于/**,因此它们会被路由到演示服务.
我尝试设置特定端点以路由回到zuul服务器,但如果我是对的,我最终会有无限循环的zuul调用自己.所以,如果我是对的,我正在寻找一种方法来定义表示服务的路径,其中包括除例如/ admin/*端点之外的所有内容.可能吗?还是应该采取另一种方法?
我正在使用Spring Cloud Zuul网关放在我的春季启动应用程序前面.我在应用程序端使用基本授权.当我使用适当的授权标头呼叫网关时,我总是获得401 Unauthorized
"status": 401,
"error": "Unauthorized",
"message": "Full authentication is required to access this resource"
Run Code Online (Sandbox Code Playgroud)
但是,当我直接向应用程序提出请求时,它可以工作.
我试图使用本地云弹簧连接器在本地环境中测试我的应用程序,然后才能将其部署到基于CF的云环境中。从春季链接
我按照此过程进行操作,并在项目资源目录中创建了名称为spring-cloud-bootstrap.properties的属性文件。它具有以下内容
spring.cloud.properties文件:C:\ Users \ IBM_ADMIN \ git \ ServiceXchange5 \ ServiceXchange \ spring-cloud.properties
我在上面给出的路径中确实有文件spring-cloud.properties。
从spring configuaration bean中,我有以下内容
@EnableWebMvc
@Configuration
@EnableAspectJAutoProxy
public class CloudServiceConfig extends AbstractCloudConfig {
@Bean
public DataSource getDataSource() throws AppException {
org.springframework.cloud.service.PooledServiceConnectorConfig.PoolConfig poolConfig = new PoolConfig(50, 100, 3000);
org.springframework.cloud.service.relational.DataSourceConfig dbConfig = new DataSourceConfig(poolConfig, null);
return connectionFactory().dataSource(SX_DB_USED, dbConfig);
}
Run Code Online (Sandbox Code Playgroud)
现在,此DataSource bean被注入了其他地方。将属性文件放置在适当的位置,我希望将创建用于本地配置的云连接器bean,并且我应该能够使用该连接器为DataSource添加更多配置以用于连接池。
但是,当我访问该应用程序时,它似乎未激活本地配置连接器。
Initialization of bean failed; nested exception is org.springframework.cloud.CloudException: No suitable cloud connector found
[ERROR ] SRVE0271E: Uncaught init() exception created by servlet [appServlet] in application …Run Code Online (Sandbox Code Playgroud) spring spring-boot spring-cloud spring-cloud-connectors spring-cloud-config
我是Spring Cloud Gateway的新手。
我一直在观看SpringDeveloper频道中的一些youtube视频,并正在处理以下示例:
@Bean
public RouteLocator myRoutes(RouteLocatorBuilder builder) {
return builder.routes()
.route(r -> r.path("/get")
.addRequestHeader("X-SpringOne", "Awesome")
.uri("http://httpbin.org:80"))
.build();
}
Run Code Online (Sandbox Code Playgroud)
在研究Spring Cloud Gateway之前,我还研究过Spring Netflix Zuul。据我所知,在Netflix的Zuul,你可以通过创建一个扩展类创建过滤器ZuulFilter,并把它定义为pre,post,route,等。
但是我想知道如何使用Spring云网关创建PRE / POST过滤器?
任何帮助/建议深表感谢。
谢谢。
spring-cloud ×10
spring-boot ×4
netflix-zuul ×2
spring ×2
docker-swarm ×1
hystrix ×1
kubernetes ×1
mesos ×1
netflix ×1
oracle ×1
weblogic ×1