问题标签 [mediator]

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.

0 投票
2 回答
3606 浏览

wso2 - wso2 ESB : Split / Gather Pattern - Single Response

This is not a question but rather an answer. I am quite new to wso2 ESB and wanted to make a test run implementing the split/gather EIP as part of a POC. I followed the examples I found and immediately got a working config that returned a single response. However to get all the responses back took quite some amount of time to figure out. Most given samples seemed to create the same unexpected result. I hope that if you run into the same kind of problem these lines will be helpfull to you.

Setup

I used the soapUI sample service (search operation) as service backend. I sent a combined message searching for two items to the proxy server (see artefact below) The iterate mediator splits the message and forwards it to the endpoint that's calling the soapUI mockup. The aggregate mediator waits for all responses and tries to put it into one result message.

Problem

Although the splitter was working correctly, the aggregator returned only one result element not a list of elements as expected. All logs showed that everything was fine, several requests were sent to the corresponding endpoints but still only the first response that returned was visible in the final response.

Solution

After setting the log level of the proxy to TRACE I realized that the aggregator worked just fine, only it created a message that wasn't really SOAP conform. All aggregated elements were added directly beneath the soap body. So the question was how to add one root element between body and result tags. I tried XSLT first but it also could read only the first child element of the body. Finally I found some deeply buried hint to use the enrich mediator (or rather a series of that) and that did the trick. The following list explains the part of the config (code shown below) that is not to be found in most examples.

  1. Use first Enrich to capture all relevant items into a property
  2. Forget about the current message - rewrite the complete envelope with the body containing only the new payload root element
  3. Attach the elements stored in the property to the new payload root.
  4. If required capture the soap header into a property and attach it into the new msg (not in the config below)

Artefacts

Demo Request

Config

Finally a question

If someone could hint me to some documentation or give me some working config for the correlateOn attribute of the aggregate mediator I'd really appreciate it.

0 投票
2 回答
893 浏览

groovy - WS02 ESB - 如何在类路径上获取自定义 java 类属性文件

我通过将自定义 jar 文件放入 /repository/components/lib 目录,将其加载到 WSO2 中,并执行重新启动。然后,我使用内联 groovy 从脚本中介调用该类。groovy 脚本识别类,但是自定义类正在尝试加载必须在类路径上的属性文件。我已经将该属性文件放在几乎所有地方,但我一直收到一个错误,它无法在类路径中找到该文件。

我正在运行独立的 WSO2 ESB 4.7.0。我已将该文件作为 jar 的一部分,我还尝试将其放置在 WSO2 文件结构中的多个目录中。一切尽在掌握。

0 投票
1 回答
1016 浏览

design-patterns - 在 Model-GUI-Mediator 模式中委托事件(可能也是 MVP?)

当一个事件触发应该作用于焦点控件(而不是触发事件的控件)时,您如何在 Model-GUI-Mediator (MGM) 模式中处理这个问题?如果您有多个模型,我怀疑这个问题也适用于密切相关的MVP 模式。

我将此命名为“委托事件”,因为我认为事件发起控件的中介必须将事件委托给选定控件(或其模型)的中介 - 但问题是,“如何?”

背景

MGM 模式有点像MVP Passive View,除了每个控件都有一个单独的“中介”(而不是每个表单一个演示者)。控件的事件全部由其中介处理,中介调用其特定模型的方法作为响应。中介者是模型的观察者,当模型改变时更新它的控制。它特别适用于您的控件没有数据绑定并且您不想对它们进行子类化的 RAD 环境。与被动视图不同,它还有一个优点是连接事件的样板代码很少。这里有两个更详细的描述:

问题示例

  1. 一个表单包含许多控件,这些控件提供了许多模型对象的视图。一次只能选择其中一个视图。(如果你想要一些具体的东西,想象一个多文档编辑器。)

  2. 用户从菜单调用命令。这将调用特定菜单项的中介对象中的 Execute 方法。(菜单项是一个控件,所以它有一个对应的中介。)

  3. 该命令应该对当前选定的控件执行操作。

  4. 因此,菜单项的中介需要找到属于所选控件的中介并在那里委托操作,或者需要找到与所选控件的中介关联的模型并直接调用它。

但是菜单项的中介者是如何找到选中控件的中介者的呢?

在 MGM 中,中介对象应该是自包含的,所以不知道其他中介对象。不允许控件了解有关模型的任何信息(以保持关注点的清晰分离)。控件唯一了解其中介者的是事件处理程序。

黑客解决方法

到目前为止,我想出的最好方法是检查所选控件中的事件字段,该字段将是指向该控件中介的对象方法指针。在 Delphi 中,我可以将其转换为 TMethod,从而为控件的中介提取对象指针。然后我可以将其转换为中介的类型并调用所需的方法。

但这似乎严重依赖于语言特性(TMethod),并且还创建了中介类之间的依赖关系。

也许我完全走错了路……</p>

(PS 可以比我有更多代表的人创建一个“model-gui-mediator”标签吗?谢谢。)

0 投票
1 回答
1088 浏览

json - wso2esb payloadfactory 构建 JSON 消息

我正在尝试使用 wso2esb 4.7.0 REST API 来实现以下用例:

公开一个 REST 资源,当您执行 GET 请求时,它会构建 JSON 消息并向后端服务发出 POST 请求,并接收将返回给客户端的 JSON 响应。

我在构建 JSON 消息时遇到问题。我正在使用payloadfactory 调解器来构建我的JSON 请求,但我的后端服务上只收到一条空的soap 消息。

这是我正在使用的 REST API 源配置:

0 投票
2 回答
6558 浏览

filter - 如何比较 wso2 esb 中过滤器中介中的整数属性?

我是 wso2 esb 的新手,定义了 3 个服务,它们返回整数值并使用过滤器调解器从一个路由到另一个,但工作不正确,在过滤器模式下总是返回 false 我的来源是:

0 投票
1 回答
1293 浏览

javascript - javascript 中介者与观察者

首先我想说我已经用谷歌搜索javascript mediator vs observer并阅读了近十个链接。

我也在 statckoverflow 中搜索,我得到了这个Mediator Vs Observer Object-Oriented Design Patternsmediator-vs-observer

但是,我仍然不清楚它们之间的区别。

所以我想知道是否有人可以更清楚地解释它们?

也许是一个活生生的例子。:)

谢谢。


我尝试创建一个示例,这是一种中介模式吗?

代码:

在这里我想知道是否Mediator应该知道触发消息的对象的存在?

0 投票
2 回答
798 浏览

c++ - Qt中的MultiSelectable和Non Multiselectable复选框

我写了一个简单的小部件,它有一个 QCheckBoxes 列表。另外,我的类有一个名为 的成员isMultiselectable,它在构造函数中初始化。当此选项为 TRUE 时,我希望小部件是多选的(即用户可以设置多个 QCheckBox)。否则,它必须防止 QCheckBoxes 的多重选择。

推荐的实施方式是什么?谢谢你。

0 投票
1 回答
803 浏览

python - WSO2 Python 脚本中介

我正在尝试在 WSO2 中使用具有以下定义的脚本调解器:

我不得不将“py”硬编码为语言,因为 Javascript、Ruby 和 Groovy 是语言下拉列表中唯一可用的选项,尽管 WSO2 ScriptMediator 文档声明支持 Python。

当我尝试保存代理更改时,我收到错误“错误 - ScriptMediator No script engine found for language: py”

实际上,ScriptMediator 中的 WSO2 是否不支持 Python?还是我需要在某处修改某些内容以启用 Python 脚本的处理?

谢谢你。

0 投票
1 回答
391 浏览

rest - WSO2 配置直通代理

嗨,我想在以下用例中构建代理定义:

1)我有一个客户

2) WSO2 ESB 4.7.0

3) 2 个 REST 服务:R1 和 R2

我希望这发生:

1) 客户端向 ESB 代理发送请求

2)代理将请求转发给R1

3) 如果 R1 的响应没有出现任何错误,则应向客户端和 R2 发送相同的响应,否则应将故障消息发送回客户端。

谁能帮我写这个condifuration?非常感谢

0 投票
1 回答
110 浏览

php - 对象如何订阅事件?

我有一个实现EventSubscriberInterface的订阅者。但是,在Event dispatcher 组件文档中,据说要订阅一个事件,我应该调用$dispatcher->addSubscriber().

现在,对于我的示例,假设您有一个Mailer订阅某些事件并发送电子邮件的类。我的基本问题是,我在哪里可以将它添加到应用程序中,以便将该对象添加为应用程序范围的侦听器?$dispatcher->addSubscriber()换句话说,在事件发生之前我应该​​在哪里调用它?