camel


import org.apache.camel.CamelContext;
import org.apache.camel.component.activemq.ActiveMQComponent;
import org.apache.camel.component.activemq.ActiveMQConfiguration;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.spring.SpringRouteBuilder;


public final class CamelJmsToRemoteExample {

    private CamelJmsToRemoteExample() {
    }

    public static void main(String args[]) throws Exception {
        CamelContext context = new DefaultCamelContext();

        final String localBrokerURL = "tcp://localhost:61616";
        final String remoteBrokerURL = "tcp://remoteip:61616";

        ActiveMQComponent localComponent = new ActiveMQComponent();
        ActiveMQConfiguration localConfiguration = new ActiveMQConfiguration();
        localConfiguration.setBrokerURL(localBrokerURL);
        localComponent.setConfiguration(localConfiguration);

        ActiveMQComponent remoteComponent = new ActiveMQComponent();
        ActiveMQConfiguration remoteConfiguration = new ActiveMQConfiguration();
        remoteConfiguration.setBrokerURL(remoteBrokerURL);
        remoteComponent.setConfiguration(remoteConfiguration);

        // context.addComponent("activemq", localComponent);
        context.addComponent("remoteActivemq", remoteComponent);

        context.addRoutes(new CamelRouteBuilder());

        context.start();
    }

}

class CamelRouteBuilder extends SpringRouteBuilder {

    @Override
    public void configure() throws Exception {
        from("activemq:TEST.FOO").to("remoteActivemq:TEST.FOO");
    }

}

你可能感兴趣的:(apache,spring,activemq)