Package org.mokai.impl.camel

Source Code of org.mokai.impl.camel.RoutingEngineMBean

package org.mokai.impl.camel;

import net.gescobar.jmx.annotation.Impact;
import net.gescobar.jmx.annotation.ManagedAttribute;
import net.gescobar.jmx.annotation.ManagedOperation;

import org.mokai.Message;
import org.mokai.persist.MessageCriteria;

/**
* This class will be exposed as an JMX Bean wrapping a {@link CamelRoutingEngine} and exposing some of its methods
* and operations.
*
* @author German Escobar
*/
public class RoutingEngineMBean {

  private CamelRoutingEngine routingEngine;

  public RoutingEngineMBean(CamelRoutingEngine routingEngine) {
    this.routingEngine = routingEngine;
  }

  @ManagedOperation(description="Starts all the applications and connections that are stopped.", impact=Impact.ACTION)
  public void start() {
    routingEngine.start();
  }

  @ManagedOperation(description="Stops all the applications and connections that are started.", impact=Impact.ACTION)
  public void stop() {
    routingEngine.stop();
  }

  @ManagedAttribute(description="Number of messages that failed or are being retried.")
  public int getNumFailedMessages() {
    MessageCriteria criteria = new MessageCriteria()
      .addStatus(Message.STATUS_FAILED)
      .addStatus(Message.STATUS_RETRYING);

    return routingEngine.getMessageStore().list(criteria).size();
  }

}
TOP

Related Classes of org.mokai.impl.camel.RoutingEngineMBean

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.