我正在使用WSO2 EI。

当序列失败时,我需要停用消息处理器

如何从序列中停用消息处理器?

谢谢!

对于Linux服务器,WSO2 EI-6.4.0和JDK,这是这样的:1.8.0_201

最佳答案

您可以实现简单的class mediator来访问EI的JMX端点以停用消息处理器。并按相关顺序咨询班级调解员。以下是示例类介体。在这里,我将停用名为testPro的消息处理器。

public class MsgProDeactivator extends AbstractMediator {

    public boolean mediate(MessageContext context) {
        try {
            Map<String, Object> env = new HashMap<String, Object>();
            String[] credentials = new String[]{"admin", "admin"};
            env.put("jmx.remote.credentials", credentials);

            String url = "service:jmx:rmi://localhost:11111/jndi/rmi://localhost:9999/jmxrmi";
            JMXServiceURL target = new JMXServiceURL(url);
            JMXConnector connector = JMXConnectorFactory.connect(target, env);
            MBeanServerConnection remote = connector.getMBeanServerConnection();

            String beanDef = "org.apache.synapse:Type=Message Forwarding Processor view,Name=testPro";
            ObjectName bean = new ObjectName(beanDef);

            remote.invoke(bean, "deactivate", null, null);
            connector.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return true;
    }
}


有关更多信息:http://imesh.github.io/how-to-activatedeactivate-message-processors-in-wso2-esb-with-mbeans/

10-06 01:58