【问题标题】:Use Spring Integration DSL to read from Tibco EMS topic使用 Spring Integration DSL 读取 Tibco EMS 主题
【发布时间】:2019-04-12 05:23:17
【问题描述】:

我一直在尝试将 spring integration dsl 配置为从 Tibco EMS 主题中读取,对收到的消息进行一些处理,然后将其推送到 ActiveMQ 队列。我能够使用 XML 配置成功设置它,但想改用 spring 集成 dsl。我无法弄清楚,也无法在网上找到任何帮助。

我将消息推送到 ActiveMQ 的配置是这样的 -

@Bean
public IntegrationFlow toActiveMQFlow(
        MessageChannel channel,
        ActiveMQQueue queue,
        CachingConnectionFactory cachingConnectionFactory) {
    return IntegrationFlows.from(channel)
            .transform(Object::toString)
            .handle(Jms.outboundAdapter(cachingConnectionFactory).destination(queue))
            .get();
}

我认为从 Tibco EMS 主题读取的配置应该是这样的 -

@Bean
public IntegrationFlow fromTibcoTopicFlow(
        MessageChannel channel,
        ConnectionFactory tibcoEmsConnectionFactory,
        Topic tibcoTopic
) {
    return IntegrationFlows
            .from(SomeInboundAdapter(tibcoEmsConnectionFactory).destination(tibcoTopic))
            .transform(Object::toString)
            .channel(channel)
            .get();
}

由于我在后一种配置上没有找到太多帮助,所以我唯一的选择是使用 XML 配置吗?

请纠正/编辑/指出我犯的任何错误,仍在学习 Spring Integration DSL。

感谢您的帮助!

【问题讨论】:

  • tibcoEmsConnectionFactory 不也是关于 JMS 的吗? Jms.messageDrivenChannelAdapter() 不适合你吗?
  • 顺便说一句,你的 XML 是什么?
  • 我尝试使用 Jms.inboudAdapter 和 Jms.messageDrivenChannelAdapter,但不断收到此编译错误 - Cannot resolve method 'from(org.springframework.integration.dsl.jms.JmsMessageDrivenChannelAdapterSpec.JmsMessageDrivenChannelAdapterListenerContainerSpec<org.springframework.integration.dsl.jms.JmsDefaultListenerContainerSpec,org.springframework.jms.listener.DefaultMessageListenerContainer>)' 我正在使用 spring-integration-core 5.0.7.RELEASE 和 spring-integration-java- dsl 1.2.2.RELEASE
  • 从 Spring Integration 5.0 版本开始,您不应该将那个额外的工件用于 Java DSL。它现在包含在核心项目中。见github.com/spring-projects/spring-integration-java-dsl/wiki/…This project has been absorbed by Spring Integration Core starting with version 5.0.

标签: spring spring-integration spring-integration-dsl tibco-ems


【解决方案1】:

您需要使用Jms.messageDrivenChannelAdapter(ConnectionFactory connectionFactory)

不要使用spring-integration-java-dsl。从版本5.0:https://docs.spring.io/spring-integration/docs/5.0.9.RELEASE/reference/html/whats-new.html#_java_dsl开始合并到核心项目中

我们已经解决了类路径上旧 Java DSL jar 的问题:https://jira.spring.io/browse/INT-4551

【讨论】:

  • 感谢 @ArtemBilan,在删除 spring-integration-java-dsl 工件后,我能够配置为至少连接到 Tibco EMS。我用TibjmsConnectionFactoryTibjmsTopic 创建了一个DefaultMessageListenerContainer,并将它传递给Jms.messageDrivenChannelAdapter。但是现在应用程序启动后,我在日志中不断收到此错误消息 - o.s.j.l.DefaultMessageListenerContainer : Setup of JMS message listener invoker failed for destination 'Topic[tibcoTopic]' - trying to recover. Cause: Not permitted
  • Cause: Not permitted 我猜是 Tibco 特有的东西,并且已经超出了 Spring 集成的范围。
  • 与我的 Tibco 管理员核实后发现他们不允许我们创建持久订阅者,因此出现“不允许”错误。我现在必须使用 JNDI 来完成这项工作。感谢@ArtemBilan 的投入。
猜你喜欢
  • 1970-01-01
  • 2016-02-22
  • 1970-01-01
  • 2013-05-23
  • 1970-01-01
  • 2022-07-11
  • 2014-11-21
  • 2016-10-21
  • 2010-12-11
相关资源
最近更新 更多