@Override protected void addServicesOnStartup( final Map<String, KeyValueHolder<Object, Dictionary>> services) { final String jmsPort = System.getProperty("fcrepo.dynamic.jms.port", "61616"); final String webPort = System.getProperty("fcrepo.dynamic.test.port", "8080"); final ActiveMQComponent amq = new ActiveMQComponent(); amq.setBrokerURL("tcp://localhost:" + jmsPort); amq.setExposeAllQueues(true); final FcrepoComponent fcrepo = new FcrepoComponent(); fcrepo.setBaseUrl("http://localhost:" + webPort + "/fcrepo/rest"); services.put("broker", asService(amq, "osgi.jndi.service.name", "fcrepo/Broker")); services.put("fcrepo", asService(fcrepo, "osgi.jndi.service.name", "fcrepo/Camel")); }
public ForwardExpressTestApplication() throws Exception { final SimpleRegistry registry = new SimpleRegistry(); this.context = new DefaultCamelContext(registry); context.setTracing(true); this.producerTemplate = new DefaultProducerTemplate(context); final ActiveMQComponent jmsComponent = new ActiveMQComponent(); jmsComponent.setBrokerURL("tcp://localhost:61616"); context.addComponent("jms", jmsComponent); context.addRoutes(new Routes()); context.start(); producerTemplate.start(); this.ui = new UI(); }
private void createCamelContext() throws Exception { log.info("creating context and sending message"); camelContext = new DefaultCamelContext(); camelContext.addComponent("activemq", ActiveMQComponent.activeMQComponent(BROKER_URL)); final String queueEndpointName = "activemq:queue" + QUEUE_NAME; camelContext.addRoutes( new RouteBuilder() { @Override public void configure() throws Exception { from(queueEndpointName).bean(Consumer.class, "consume"); } }); camelContext.start(); final ProducerTemplate producerTemplate = camelContext.createProducerTemplate(); producerTemplate.sendBody(queueEndpointName, "message"); }
public void pollCurrentLog() { try { CamelContext camelContext = new DefaultCamelContext(); camelContext.addComponent( "jms", org.apache.activemq.camel.component.ActiveMQComponent.activeMQComponent( "tcp://localhost:61616")); ConsumerTemplate consumerTemplate = camelContext.createConsumerTemplate(); Message message = consumerTemplate.receive("jms:queue:maven-logs").getIn(); if (message != null && message.getBody() != null) { if (currentLog == null) { currentLog = message.getBody().toString(); } else { currentLog += "\n" + message.getBody(); } } } catch (Exception e) { logger.error("Error:", e); } }