|
@ -0,0 +1,36 @@
|
|
|
package camel.central.archives.route;
|
|
|
|
|
|
import com.yihu.hos.web.framework.constant.ArchivesConstant;
|
|
|
import org.apache.activemq.ActiveMQConnectionFactory;
|
|
|
import org.apache.camel.builder.RouteBuilder;
|
|
|
import org.apache.camel.component.jms.JmsComponent;
|
|
|
import org.apache.camel.model.ModelCamelContext;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import javax.jms.ConnectionFactory;
|
|
|
|
|
|
/**
|
|
|
* @created Airhead 2016/8/1.
|
|
|
*/
|
|
|
@Component
|
|
|
public class ArchivesMqRouter extends RouteBuilder {
|
|
|
|
|
|
@Value("${spring.activemq.broker-url}")
|
|
|
private String brokerURL;
|
|
|
@Value("${spring.activemq.user}")
|
|
|
private String user;
|
|
|
@Value("${spring.activemq.password}")
|
|
|
private String password;
|
|
|
|
|
|
@Override
|
|
|
public void configure() throws Exception {
|
|
|
ModelCamelContext context = this.getContext();
|
|
|
ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(
|
|
|
user, password, brokerURL);
|
|
|
// Note we can explicit name the component
|
|
|
context.addComponent(ArchivesConstant.CAMEL_COMPONENT, JmsComponent.jmsComponentAutoAcknowledge(connectionFactory));
|
|
|
from(ArchivesConstant.CAMEL_ENDPOINT)
|
|
|
.to("bean:archivesService?method=storageArchive");
|
|
|
}
|
|
|
}
|