Integration / Apache Camel Interview Questions
How does the Camel JMS/ActiveMQ component work?
The camel-jms component wraps the Spring JMS template and listener container, providing JMS connectivity via the standard javax.jms API. It supports queues and topics, durable subscriptions, message selectors, and transacted sessions. camel-activemq extends camel-jms with ActiveMQ-specific optimisations including in-JVM broker embedding.
// Spring Boot configuration:
spring.activemq.broker-url=tcp://localhost:61616
spring.activemq.user=admin
spring.activemq.password=admin
// Route: consume with JMS transactions:
from("jms:queue:orders?transacted=true&concurrentConsumers=5")
.process(new OrderProcessor())
.to("jms:topic:order-events");
// Request-reply over JMS (InOut pattern):
from("direct:calcPrice")
.to("jms:queue:pricing-service?exchangePattern=InOut&replyTo=pricing-replies");
// Durable topic subscription:
from("jms:topic:product-updates?subscriptionDurable=true&clientId=app1&durableSubscriptionName=app1-sub")
.to("direct:handleUpdate");Key options: transacted=true wraps the consumer in a JMS local transaction (rolled back on route exception), concurrentConsumers sets the thread pool size, acknowledgementModeName controls ack mode. For request-reply, exchangePattern=InOut blocks until a reply arrives on the replyTo queue. camel-activemq can embed a broker in-process using the vm://localhost transport, which is invaluable for testing.
More Related questions...