ArchivesMqRouter.java 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. package camel.central.archives.route;
  2. import com.yihu.hos.web.framework.constant.ArchivesConstant;
  3. import org.apache.activemq.ActiveMQConnectionFactory;
  4. import org.apache.camel.builder.RouteBuilder;
  5. import org.apache.camel.component.jms.JmsComponent;
  6. import org.apache.camel.model.ModelCamelContext;
  7. import org.springframework.beans.factory.annotation.Value;
  8. import org.springframework.stereotype.Component;
  9. import javax.jms.ConnectionFactory;
  10. /**
  11. * 档案入库-消息接收服务
  12. * @author HZY
  13. * @vsrsion 1.0
  14. * Created at 2017/3/13.
  15. */
  16. @Component
  17. public class ArchivesMqRouter extends RouteBuilder {
  18. @Value("${spring.activemq.broker-url}")
  19. private String brokerURL;
  20. @Value("${spring.activemq.user}")
  21. private String user;
  22. @Value("${spring.activemq.password}")
  23. private String password;
  24. @Override
  25. public void configure() throws Exception {
  26. ModelCamelContext context = this.getContext();
  27. ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(
  28. user, password, brokerURL);
  29. // Note we can explicit name the component
  30. context.addComponent(ArchivesConstant.CAMEL_COMPONENT, JmsComponent.jmsComponentAutoAcknowledge(connectionFactory));
  31. from(ArchivesConstant.CAMEL_ENDPOINT)
  32. .to("bean:archivesService?method=storageArchive");
  33. }
  34. }