- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
面对 spring integration java-dsl 问题,我被卡住了。这是我的流声明代码:
@Bean
public IntegrationFlow orchestrationFlow() {
return IntegrationFlows.from(
Jms.messageDrivenChannelAdapter(queueConnectionFactory())
.destination(bookingQueue())
.outputChannel(bookingChannel()))
.<String, BookingRequest>transform(s -> {
Ticket t = new Gson().fromJson(s, Ticket.class);
return new BookingRequest()
.setMovieId(t.getMovie().getId())
.setRow(t.getSeat().getRow())
.setSeat(t.getSeat().getNumber())
.setScreenNumber(t.getScreenNumber()
);
})
// HTTP part goes here
.<BookingRequest, HttpEntity>transform(HttpEntity::new)
.handle(
Http.outboundChannelAdapter(bookingServerUrl)
.httpMethod(HttpMethod.POST)
.extractPayload(true)
.expectedResponseType(BookStatus.class)
)
// and here HTTP part ends
.handle(
Jms.outboundAdapter(responseDestinationTemplate())
)
.get();
}
在我使用 HTTP 出站 channel 适配器之前一切正常。我需要调用简单的 RESTful 接口(interface),上面的代码做得很好。但是,在 Jms.outboundAdapter(responseDestinationTemplate())
行之后没有任何结果,成功调用 http 后没有执行任何操作。
如果我删除 http 流程部分(被注释包围)- 它会起作用。实现了这么多东西,几乎理解并看到了集成的美丽和简单......就是这样。我陷入的另一个地方。
这里是 REST 调用成功后的日志:
2016-02-08 21:01:22.155 DEBUG 18209 --- [enerContainer-1] o.s.web.client.RestTemplate : POST request for "http://localhost:9052/api/book" resulted in 200 (OK)
2016-02-08 21:01:22.156 DEBUG 18209 --- [enerContainer-1] o.s.web.client.RestTemplate : Reading [class c.e.m.integration.domain.BookStatus] as "application/json;charset=UTF-8" using [org.springframework.http.converter.json.MappingJackson2HttpMessageConverter@6b9469bd]
2016-02-08 21:01:22.168 DEBUG 18209 --- [enerContainer-1] i.h.o.HttpRequestExecutingMessageHandler : handler 'org.springframework.integration.http.outbound.HttpRequestExecutingMessageHandler#0' produced no reply for request Message: GenericMessage [payload=<BookingRequest(movieId=0, row=1, seat=1, screenNumber=1),{}>, headers={jms_redelivered=false, jms_replyTo=queue://statusChannel, jms_correlationId=5021291a-d4d5-47ca-b591-b6f311378688, correlationId=1d41f05a-3695-4adb-87b0-d75c17bbc3ad, id=a1fb2a2f-5d78-3183-d409-3f60aae74a20, priority=4, jms_timestamp=1454950877264, jms_messageId=ID:ins-laptop-31198-1454948247657-1:9:1:1:1, timestamp=1454950877352}]
2016-02-08 21:01:22.168 DEBUG 18209 --- [enerContainer-1] o.s.integration.channel.DirectChannel : postSend (sent=true) on channel 'inboundFlow.channel#2', message: GenericMessage [payload=<BookingRequest(movieId=0, row=1, seat=1, screenNumber=1),{}>, headers={jms_redelivered=false, jms_replyTo=queue://statusChannel, jms_correlationId=5021291a-d4d5-47ca-b591-b6f311378688, correlationId=1d41f05a-3695-4adb-87b0-d75c17bbc3ad, id=a1fb2a2f-5d78-3183-d409-3f60aae74a20, priority=4, jms_timestamp=1454950877264, jms_messageId=ID:ins-laptop-31198-1454948247657-1:9:1:1:1, timestamp=1454950877352}]
2016-02-08 21:01:22.168 DEBUG 18209 --- [enerContainer-1] o.s.integration.channel.DirectChannel : postSend (sent=true) on channel 'inboundFlow.channel#1', message: GenericMessage [payload=BookingRequest(movieId=0, row=1, seat=1, screenNumber=1), headers={jms_redelivered=false, jms_replyTo=queue://statusChannel, jms_correlationId=5021291a-d4d5-47ca-b591-b6f311378688, correlationId=1d41f05a-3695-4adb-87b0-d75c17bbc3ad, id=859af23d-214f-4400-e9cb-7d40308755cd, priority=4, jms_timestamp=1454950877264, jms_messageId=ID:ins-laptop-31198-1454948247657-1:9:1:1:1, timestamp=1454950877350}]
2016-02-08 21:01:22.168 DEBUG 18209 --- [enerContainer-1] o.s.integration.channel.DirectChannel : postSend (sent=true) on channel 'inboundFlow.channel#0', message: GenericMessage [payload={"screenNumber":1,"seat":{"row":1,"number":1},"movie":{"id":0,"name":"The Matrix"}}, headers={jms_redelivered=false, jms_replyTo=queue://statusChannel, jms_correlationId=5021291a-d4d5-47ca-b591-b6f311378688, correlationId=1d41f05a-3695-4adb-87b0-d75c17bbc3ad, id=636638ed-aec2-082e-6181-0484999fd807, priority=4, jms_timestamp=1454950877264, jms_messageId=ID:ins-laptop-31198-1454948247657-1:9:1:1:1, timestamp=1454950877331}]
没有错误,根本没有警告。
最佳答案
Spring Integration 提供两种 MessageHandler
类型:单向 - 只处理消息并停止。另一个类似:处理请求消息并产生对输出 channel 的回复。
第一个被称为outboundChannelAdapter
,对于您的 HTTP 案例,您只需发送一个 POST 请求而不必担心回复。
由于消息流在 outboundChannelAdapter
上停止,因此在集成链中不可能有任何进一步的操作。就像您的情况一样,下一个 Jms.outboundAdapter
将无法到达。
如果您真的希望从您的 REST 服务得到回复
,您应该使用Http.outboundGateway
。并且您的 BookStatus
将按照您希望的方式通过流中的最后一个 .handle()
发送到 JMS。
关于java - Spring 集成 dsl : http outbound gateway,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35275056/
我们有一个系统,其行为由许多 XML 文件定义。(大约 50 个不同的 XML 文件,每个文件管理子系统的行为。) 出于遗留原因,XML 文件采用自定义格式,旨在方便系统中的各种组件使用。 自定义格式
我发送的 json 请求是: Given url applicationURL And path 'applications' And header Authorization = subscribe
默认情况下,生成的 XText 工件会从我的 DSL 生成代码到默认 socket (默认为 src-gen 文件夹)。我知道您可以在 fsa.generateFile("myfile.txt", "
我的论文主题一般是关于领域特定语言的,我想专注于外部或内部 DSL 的设计或实现,但我什至无法思考或开始,因为我在理解 DSL 的概念方面遇到了问题.. 我已经阅读并收集了很多关于这个问题的论文和调查
我有一个 Xtext 项目和几个示例 DSL 文件。我可以使用“示例 Ecore 模型编辑器”打开这些文件并验证它是否符合 Xtext 生成的元模型。但是,由于 DSL 文件未被识别为 Ecore,我
当我学习一些 DSL 时,我意识到 Rebol 中的 Parse 方言可以是一个很好的词法分析器和解析器。 the Parse tutorial 有一个很好的例子: expr: [ter
我正在考虑使用亚马逊云服务(EC2、S3 等)进行托管。我一直在查看可以指定用于配置各种实例的 JSON 元数据,我担心它的复杂性。是否有一个 dsl 可以生成有效的 JSON 元数据并且更重要的是验
我可能会因为这个而被否决,但无论如何我都会试试运气。 我真的找不到 Elastic Search 查询 DSL 的完整形式“DSL”的任何链接,甚至在 Elastic Search 网站上也找不到 h
这个问题可能是复合的,让我扩展一下: 是否存在设计器( stub /框架/元设计器)来创建基于 .NET 对象公共(public) bool 属性的 AND/OR 规则?保存为任何 DSL/Boo/.
与 anko 一样你可以这样写回调函数: alert { title = "" message = "" yesButton { toast("Yes")
我有一个像下面这样的原始聚合脚本,但是很难将其转换为elasticsearch dsl。 我已阅读该文档并找到描述,说我们可以使用.bucket()、. metric()和.pipeline()方法来
如何将这个 gradle groovy 片段转换为 gradle kotlin dsl 而不是非常冗长? test { systemProperties System.getPropertie
这个问题是 ANY operator with jOOQ 的衍生问题和 Are arrays optimized in jOOQ & PostgreSQL? . 我有一个Field field和Lis
我创建了内部 DSL,并且会重载 DefaultGroovyMethods 中的 any() 方法。 class RulesProcessor { } Any live cell with fewer
我正在尝试使用 Gradle 使用 Kotlin 和 Java 11 构建一个简单的 JavaFX 11 程序,按照说明 here .但是,此页面使用 Gradle 的 Groovy DSL,而我正在
如何将这个 gradle groovy 片段转换为 gradle kotlin dsl 而不是非常冗长? test { systemProperties System.getPropertie
我是 Camel 的新手,我仍在学习它,根据我的理解,你可以在 Spring DSL 中做与 Java DSL 相同的事情。我想知道如何将一种转换为另一种?我经常看到 Java 中的例子,但想要 最佳
我正在尝试通过 Groovy 代码为 Jenkins Job DSL 插件创建 ListView 。运行后, View 已创建,但不会添加任何作业。以下代码段之前的代码创建了构建和部署作业,并且在调用
对于 Jenkins 作业 DSL,我试图为作业选择特定的 ssh 代理(插件)键(在包装器上下文中使用 sshAgent 关键字)。我们安装了 Jenkins ssh 代理插件并设置了几个 key
我必须为非程序员(我们公司的客户)创建一个 DSL,它需要提供一些更高级别的语言功能(循环、条件表达式、变量...... - 所以它不仅仅是一个“简单”的 DSL)。 使用 DSL 应该很容易;人们应
我是一名优秀的程序员,十分优秀!