问题标签 [spring-integration-http]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
spring-integration - 为什么没有根据成功建议复制原始标题
为什么没有根据成功建议复制原始标题。使用 http 出站适配器发送消息后,我希望收到原始消息头,但没有收到。只能访问 originalMessagePayload。如果我不使用建议并且在网关适配器调用我的 post 处理程序之后,我会看到所有标题。不可能添加带有建议的标题吗?
java - Spring Boot 和 Spring 集成。问题
我有一个 SpringBoot 应用程序。我有一个专用服务器,我将通过 HTTP GET 请求读取数据。我为 Spring Integration 模块配置了 http-outbound-config.xml 文件。 当我运行以下代码时,一切都很好:
http-outbound-config.xml
主要应用类:
集成类:
但是,当我尝试 Autowire MessageChannel 和 PollableChannel 时,我收到一个空指针异常。
集成类(不工作示例):
- 问题 1:为什么自动装配不起作用?
- 问题2:从专用服务器获取数据并将其保存到数据库的最佳方法是什么?这样的配置好吗?我将为响应创建一个模型类,然后通过 JPA 将其保存到数据库中。
- 问题 3:我需要在异步模式下从服务器读取。如何在 Spring Boot 中实现它?所以这里的主要想法是我将从 UI 接收一个 POST 方法,并启动与 Web 服务的集成。集成完成后,我需要通知用户。
- 问题 4:也许 Camel 会是这里最好的解决方案?
堆栈:Java 11、Spring Boot、thymeleaf + bootstrap。
感谢您提前回答。
spring-integration - 线接头作为异步通道?
使用“窃听”作为二线逻辑通道是否正确?
或者我应该使用其他方法?我没有找到任何合适的东西(pubSubChannel?)
例如:
java - 出站 Http Enpoint 的 Spring 集成测试
我是 Spring Integration 项目的新手,现在我需要使用 Java DSL 创建一个流并对其进行测试。我想出了这些流程。第一个应该由 cron 运行并调用第二个,它调用 HTTP 端点并将 XML 响应转换为 POJO:
现在我想测试流程和模拟 HTTP 调用,但努力模拟 HTTP 处理程序,我尝试这样做:
但我总是收到一个错误,即在线:
mockIntegrationContext.substituteMessageHandlerFor("bulkEndpoint", mockHandler);
我在这里做错了吗?我假设我的 IntegrationFlow 本身有问题,或者我的测试方法有问题。
spring-integration - 如何让 Spring Integration Http.inboundGateway 返回 HAL Json?
我将以下属性设置为 true "spring.hateoas.use-hal-as-default-json-media-type' 并添加 org.springframework.boot:spring-boot-starter-hateoas 作为依赖项。
代码
回复
我希望以 HAL 格式返回响应,例如
为什么不是这样?我怎样才能做到这一点?
java - IneligibleMethodException: Found more than one parameter type candidate - Spring Integration
I am using
I have this controller where I received a path variable and request body
I init the process using a gateway so I pass it the 2 values
But I got the follow error
What I am missing?
spring-integration - 从 Spring Integration 的 @Gateway 方法返回 ResponseEntity
我有IntegrationFlow
我称之为 HTTP 端点的地方:
此流程在getInformation
被调用时执行,这要归功于Gateway
上面的代码抛出以下异常:
杰克逊试图反序列化成ResponseEntity
而不是Information
类
我的目标是首先检查状态代码,并可选择检查Information
字段
是否可以从注释的方法返回 ResponseEntity @Gateway
?
spring-integration - Spring Integration - http outboundAdapter 中的控制重试逻辑
我在 Spring Integration 5.4.4 中配置了一个从 AMQP 队列读取并写入 http 出站适配器的路由。例如,当我以编程方式为 http 出站适配器声明错误的 http 主机名(原因 java.net.UnknownHostException)时,我无法控制重试。
即使我在 amqpInboundAdapter 中配置了 RetryTemplate 逻辑,这似乎会生成无限重试(RabbitMQ 容器上未确认消息)。
我的目标应该是:在http出站适配器出错的情况下将消息重新排队N次,否则丢弃消息并且不要再次重新排队。
代码在这里:
Spring集成路线
AmqpInboundChannelAdapterSMLCSpec
有任何想法吗?
非常感谢
java - 无法从 Spring 集成出站网关调用 HTTPS 端点
我有两个微服务和一个网关。一个微服务是用JHipster和spring boot(Service1)开发的,另一个是spring集成框架(IntegrationService)。现在我需要从 IntegrationService 调用 service1 API。我在这两个微服务中都使用 HTTPS 进行通信。但是当调用 API 时,我得到了以下错误日志。
2021-05-05 11:05:45.503 INFO 22105 --- [XNIO-1 task-4] cmasIntegrationService:IntegrationService org.springframework.messaging.MessageHandlingException 中的异常:URI [https://<server_ip> 的 HTTP 请求执行失败/gateway/services/service1/api/viewrecords?id=100100100100157] 在 [bean 'outboundGateway'; 定义在:'类路径资源 [com/esi/app/service/IntegrationService.class]'; 来源:'org.springframework.core.type.classreading.SimpleMethodMetadata@3fa2213'];嵌套异常是 org.springframework.web.client.ResourceAccessException: I/O error on GET request for "https://<server_ip>/gateway/services/service1/api/viewrecords":PKIX 路径构建失败:sun.security.provider.certpath.SunCertPathBuilderException:无法找到请求目标的有效证书路径;嵌套异常是 javax.net.ssl.SSLHandshakeException:PKIX 路径构建失败:sun.security.provider.certpath.SunCertPathBuilderException:无法找到请求目标的有效证书路径, failedMessage=GenericMessage [payload={custId=100100100100157},headers= {http_requestMethod=GET, errorChannel=org.springframework.messaging.core.GenericMessagingTemplate$TemporaryReplyChannel@703c6baf, Connection=Keep-Alive, Host=<server_ip>: port , accept= /, authorization=Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsImF1dGgiOiJST0xFX0FETUlOLFJPTEVfVVNFUiIsImV4cCI6MTYyMDI3ODk4NH0.-4ByR7OQY-G_dZh7XUHYOSo3FRS2Ug6JxVOkq6XOmhUV05LnQj10puEGotcJk1EUlYDvt4n2dAJFSuR3evnvHA, replyChannel=org.springframework.messaging.core.GenericMessagingTemplate$TemporaryReplyChannel@703c6baf, http_requestUrl=http://<server_ip>:/api/getrecordsfromservice1?transactionId=1111111111&id=100100100100157, id=1eec8d00-4040-c9b2-cdb1-4f2d8743d007, Content-Length=0, http_userPrincipal=org.springframework.security.authentication.UsernamePasswordAuthenticationToken@143b9e60: 主体: org.springframework.security.core.userdetails.User@586034f: 用户名: 行政; 密码保护]; 启用:真;AccountNonExpired:真;凭据非过期:真;AccountNonLocked:真;授予权限:ROLE_ADMIN,ROLE_USER;凭证:[受保护];已认证:真实;详细信息:空;授予权限:ROLE_ADMIN、ROLE_USER、accept-encoding=gzip、deflate、br、user-agent=PostmanRuntime/7.28.0、timestamp=1620192945487}]
我用来调用 IntegrationService 的 API 端点是,
https://<server_ip>/gateway/services/integration/api/getrecordsfromservice1?transactionId=1111111111&id=100100100100157
integration是在 IntegrationService 的网关中注册的服务名称。同样,service1用于 Service1。
我无法理解的事情是:
- “http_requestUrl”如何更改为日志中的那个,而不是我正在点击的端点?
- 即使我在两个微服务中都使用 HTTPS,为什么会发生“SunCertPathBuilderException”?
- 要获取“主机”消息头,spring 框架是否在配置文件 application.yml 上查找 IP 和端口,而不是检查 URL?
有人可以帮忙吗?@artem
我的入站和出站网关如下:
spring-integration - Spring Integration - 管理 http 出站适配器调用中的 401 错误
我是春季集成的新手。
我有一个流程,我需要根据某些条件执行 http 或 tcp 调用。我关注的问题与 http 调用有关。调用的其余端点需要一个 accessToken 作为用于身份验证的标头参数,该参数由具有 2 个方法getCurrentAccessToken()
和refreshAccessToken()
. 我只想在过期accessToken
时调用方法刷新。currentAccessToken
我想做的是在执行对rest api的调用时添加以下逻辑:
如果令牌已过期,其余端点将返回 401,我想在流程中拦截此错误并通过添加刷新的访问令牌重试请求。
我尝试通过添加requestHandlerRetry
建议并将其重定向到 a recoveryChannel
,但我无法将某些内容返回给调用者流以获取带有状态代码的响应并使用新的accessToken
.
关于如何实现这一点的任何想法?