简体   繁体   English

使用 CAR 将自定义中介部署到 WSO2 ESB

[英]Deploy a custom mediator to WSO2 ESB using a CAR

I'm trying to deploy a custom class mediator packed in a .car file.我正在尝试部署一个打包在.car文件中的自定义类介体。 The WSO2 documentation on the subject isn't very specific and there's no example available.关于该主题的WSO2 文档不是很具体,也没有可用的示例。

What I've done is:我所做的是:

  1. Wrote a custom class mediator, which works, if deployed as a .jar to $CARBON_HOME/repository/components/lib/编写了一个自定义类中介器,如果将其作为.jar部署到$CARBON_HOME/repository/components/lib/
  2. Packaged the above JAR into a .car , which is then manually uploaded to the ESB using Management Console.将上述 JAR 打包成.car ,然后使用 Management Console 手动上传到 ESB。

The problem: the server fails to find the mediator's class:问题:服务器找不到中介的类:

[2017-01-30 18:12:37,810]  WARN - SynapseXMLConfigurationFactory Proxy Service configuration: test cannot be built - Continue in fail-safe mode
org.apache.synapse.SynapseException: Error loading class : nl.my.mediators.HashMediator - Class not found
    at org.apache.synapse.config.xml.ClassMediatorFactory.createSpecificMediator(ClassMediatorFactory.java:107)
    at org.apache.synapse.config.xml.AbstractMediatorFactory.createMediator(AbstractMediatorFactory.java:94)
...

The .car file does contain the .jar in question: .car文件确实包含有问题的.jar

Archive:  mediators-v1_1_1.1.3-SNAPSHOT.car
  Length      Date    Time    Name
---------  ---------- -----   ----
...
        0  2017-01-30 18:07   ca-mediators_1.1.3-SNAPSHOT/
     5399  2017-01-30 18:07   ca-mediators_1.1.3-SNAPSHOT/ca-mediators-1.1.3-SNAPSHOT.jar
      257  2017-01-30 18:07   ca-mediators_1.1.3-SNAPSHOT/artifact.xml
...

But, apparently, it's not picked up by the ESB.但是,显然,它没有被 ESB 接收。 The artifact.xml file generated by the maven-car-plugin (which lacks documentation completely, by the way):maven-car-plugin生成的artifact.xml文件(顺便说一下,它完全没有文档):

<?xml version="1.0" encoding="UTF-8"?><artifact name="ca-mediators" version="1.1.3-SNAPSHOT" type="lib/library/bundle" serverRole="EnterpriseServiceBus">
    <file>ca-mediators-1.1.3-SNAPSHOT.jar</file>
</artifact>

How can I make ESB pick up the classes in my JAR?如何让 ESB 获取 JAR 中的类?

This problem is described in WSO2 documentation on extending the ESB:关于扩展 ESB 的WSO2 文档中描述了这个问题:

When we ship the mediator through a CAR file, the mediator is accessible only to the artifacts (sequences, proxy services, APIs) available in the same CAR file.当我们通过 CAR 文件发送中介时,中介只能访问同一 CAR 文件中可用的工件(序列、代理服务、API)。 The mediator is not available globally.调解器在全球范围内不可用。

The solution is proposed on the same page further on:该解决方案在同一页面上进一步提出:

  • Write a sequence which engages the class mediator编写一个让类中介参与的序列
  • Pack the sequence from the same CAR file which contains the class mediator从包含类中介器的同一个 CAR 文件中打包序列
  • Call the sequence from other artifacts从其他工件调用序列

I tried that and it worked out.我试过了,结果成功了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM