An Apache Camel & ActiveMQ Performance Test
An Apache Camel & ActiveMQ Performance Test
Join the DZone community and get the full member experience.
Join For FreeDiscover how you can get APIs and microservices to work at true enterprise scale.
However, results will vary dramatically depending on thread and AMQ performance/QoS configurations. Refer to the AMQ performance page and the camel-jms page for more information...
private static final Logger logger = Logger.getLogger(AMQRouteTest.class.getName()); @EndpointInject(uri = "mock:mock") protected MockEndpoint mock; protected CamelContext createCamelContext() throws Exception { CamelContext camelContext = super.createCamelContext(); String url ="vm://test-broker?broker.persistent=false&broker.useJmx=false"; ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(url); camelContext.addComponent("activemq", JmsComponent.jmsComponentAutoAcknowledge(connectionFactory)); return camelContext; } @Test public void test() throws Exception { int messageCnt = 10000, poolSize = 5; mock.setMinimumExpectedMessageCount(messageCnt); ExecutorService executor = Executors.newFixedThreadPool(poolSize); for (int i = 0; i < messageCnt; i++) { executor.submit(new Callable() { public Object call() throws Exception { template.sendBody("activemq:queue:test",System.currentTimeMillis()); return null; } }); } mock.assertIsSatisfied(); } @Override protected RouteBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { @Override public void configure() throws Exception { from("activemq:queue:test?concurrentConsumers=10") .process(new Processor() { long totalLatency, msgCnt; public void process(Exchange exch) throws Exception { totalLatency += (System.currentTimeMillis() - exch.getIn().getBody(Long.class)); if(++msgCnt % 1000 == 0) { logger.info("avgLatency=" + (totalLatency/msgCnt)); } } }) .to("mock:mock"); } }; }
APIs and microservices are maturing, quickly. Learn what it takes to manage modern APIs and microservices at enterprise scale.
Published at DZone with permission of Ben O'Day , DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
{{ parent.title || parent.header.title}}
{{ parent.tldr }}
{{ parent.linkDescription }}
{{ parent.urlSource.name }}