【问题标题】:Channels for request-reply pattern using http-outbound-gateway使用 http-outbound-gateway 的请求-回复模式通道
【发布时间】:2014-08-01 05:51:27
【问题描述】:

我需要在多线程环境(多个线程做同样的事情)中使用 http-outbound-gateway 同步发送请求和接收响应(在同一个线程中)。

我正在考虑使用 DirectChannel 作为 http-outbound-gateway 中的请求和响应通道。如果我这样做,是否会出现以下情况:

  1. thread1 将 request1 推送到通道中
  2. thread1 使用subscriber1 和request1 的上下文订阅响应
  3. thread2 将 resquest2 推送到频道中
  4. thread2 使用 subsciber2 和 request2 的上下文订阅响应
  5. response2 由 thread2 使用subscriber1 和 request1 上下文接收和处理

注意:两个线程的请求/响应通道相同。

如果发生这种情况如何解决此问题。我的要求是,始终生成请求的线程应该处理相应的响应。

【问题讨论】:

    标签: java spring spring-integration


    【解决方案1】:

    没有;它是完全线程安全的; thread1 将得到它的响应; thread2 将得到它的响应;不可能有串扰。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-03-23
      • 1970-01-01
      • 2018-04-11
      • 1970-01-01
      • 1970-01-01
      • 2015-06-25
      • 1970-01-01
      相关资源
      最近更新 更多