How to Activate/Deactivate Message Processors in WSO2 ESB with MBeans

What is a Message Processor?

WSO2 ESB provides message processors for delivering messages that have been temporarily stored in a message store. This approach is useful for serving traffic to back-end services that can only accept messages at a given rate, whereas incoming traffic to the ESB arrives at different rates [1]. Please refer [2] for sample use cases of message processors.

How to Implement a MBeans Client?

The below sample code demonstrates how to talk to the JMX endpoint of the ESB and actiavate and deactivate a message processor. Here update the JMX URL and the bean definition accordingly.

import java.util.HashMap;
import java.util.Map;

public class Main {
    public static void main(String[] args) {
        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=MessageForwardingProcessor";
            ObjectName bean = new ObjectName(beanDef);

            remote.invoke(bean, "activate", null, null);
        } catch (Exception e) {

[1] [2]

Imesh Gunaratne

Read more posts by this author.

Colombo, LK