【问题标题】:How to create Class Mediator in wso2 esb /如何在 wso2 esb 中创建 Class Mediator /
【发布时间】:2013-12-13 08:48:01
【问题描述】:

我想创建类中介。我尝试使用放入 components/lib 文件夹的普通 java 类,然后重新启动该系统。

谁能告诉我一步一步的过程。

【问题讨论】:

    标签: wso2 esb


    【解决方案1】:
    1. 编写一个实现 org.apache.synapse.Mediator 的类并覆盖 mediate(MessageContext mc) 方法并创建一个 jar 文件。

      public class SimpleClassMediator implements Mediator {
        private String varible1="10";
        private String varible2="10";
      
      public boolean mediate(MessageContext mc) {
      
      //To test you can print something here
      return true;
      
      }
      
       //getters and setters
      
      }
      
    2. 将 jar 复制到 ESB_HOME/repository/components/lib 并启动 ESB。

    3. 然后在突触配置中,您可以将此调解器称为follow

      class name="packageName.ClassName"
      

    【讨论】:

    【解决方案2】:
    1. 您可以通过扩展“AbstractMediator”轻松创建类中介。

    2. Mediator 可以是 OSGI 构建文件或 jar 文件。两者都可以使用 WSO2 ESB 进行部署。如果您需要将 Jar 文件部署到 /repository/components/lib 目录中。如果是 OSGI 包,则必须将其部署到 /repository/components/dropins 目录。如果有外部依赖库,可以放到/repository/components/lib目录下

    3. 使用全限定类名更新突触配置

    您可以从here 找到更多详细信息。它包含一个示例中介代码,您可以查看。

    【讨论】:

      【解决方案3】:
      1. First create a Maven module e.g org.wso2.carbon.mediator and then  create e.g ESBMessageMediator class  which is extended from AbstractMediator. 
      
      2. Above maven module can be configured as OSGI budle or jar file.
      
      3. Build the module using maven.
      
      4. If it is OSGI bundle put it in to the /repository/components/dropins else put it to the 
         /repository/components/lib
      
      5. configure synapse.xml file located in the "/repository/deployment/server/synapse-configs/default"
        e.g <class name="org.wso2.carbon.mediator.ESBMessageMediator">
          <property name="defaultPercentage" value="10"/>
      </class>
      6.Run the ESB and try to create a proxy service by adding the above meaditor as class mediator.if it load succesfully it is done. 
      

      【讨论】:

        【解决方案4】:

        您可以在本网站 [1] 中了解 WSO2 中的类调解器

        你可以在 mediate() 方法中编写逻辑:)

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2013-09-10
          • 2013-11-14
          • 1970-01-01
          • 1970-01-01
          • 2017-12-25
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多