org.apache.camel.component.jms.JmsComponent Java Examples
The following examples show how to use
org.apache.camel.component.jms.JmsComponent.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractContextAwareRepoEvent.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
private void configRoute() throws Exception { final ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(BROKER_URL); CAMEL_CONTEXT.addComponent("jms", JmsComponent.jmsComponentAutoAcknowledge(connectionFactory)); CAMEL_CONTEXT.addRoutes(new RouteBuilder() { @Override public void configure() { from(CAMEL_ROUTE).id("RepoEvent2Test") .unmarshal(dataFormat) .process(EVENT_CONTAINER); } }); CAMEL_CONTEXT.start(); }
Example #2
Source File: CamelRouter.java From hacep with Apache License 2.0 | 6 votes |
@Override public void start(JmsConfiguration jmsConfiguration, HACEP hacep) { if (started.compareAndSet(false, true)) { try { JmsComponent component = JmsComponent.jmsComponent(jmsConfiguration.getConnectionFactory()); camelContext.addComponent("jms", component); camelContext.addRoutes(new LoadFactFromJmsRoute(CAMEL_ROUTE, jmsConfiguration.getQueueName(), jmsConfiguration.getMaxConsumers())); camelContext.addRoutes(new InsertFactInGridRoute(hacep)); camelContext.addRoutes(new ExecuteCommandsFromJmsRoute(jmsConfiguration.getCommandsQueueName())); camelContext.addRoutes(new ResponseToJSONRoute()); camelContext.addRoutes(new UpgradeCommandRoute(hacep)); camelContext.addRoutes(new InfoCommandRoute(hacep)); camelContext.addRoutes(new StatusCommandRoute(hacep)); camelContext.start(); } catch (Exception e) { throw new RuntimeException(e); } } }
Example #3
Source File: FtpToJMSExample.java From camelinaction with Apache License 2.0 | 6 votes |
public static void main(String args[]) throws Exception { // create CamelContext CamelContext context = new DefaultCamelContext(); // connect to embedded ActiveMQ JMS broker ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost"); context.addComponent("jms", JmsComponent.jmsComponentAutoAcknowledge(connectionFactory)); // add our route to the CamelContext context.addRoutes(new RouteBuilder() { @Override public void configure() { from("ftp://rider.com/orders?username=rider&password=secret").to("jms:incomingOrders"); } }); // start the route and let it do its work context.start(); Thread.sleep(10000); // stop the CamelContext context.stop(); }
Example #4
Source File: FtpToJMSExample.java From camelinaction2 with Apache License 2.0 | 6 votes |
public static void main(String args[]) throws Exception { // create CamelContext CamelContext context = new DefaultCamelContext(); // connect to embedded ActiveMQ JMS broker ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost"); context.addComponent("jms", JmsComponent.jmsComponentAutoAcknowledge(connectionFactory)); // add our route to the CamelContext context.addRoutes(new RouteBuilder() { @Override public void configure() { from("ftp://rider.com/orders?username=rider&password=secret").to("jms:incomingOrders"); } }); // start the route and let it do its work context.start(); Thread.sleep(10000); // stop the CamelContext context.stop(); }
Example #5
Source File: FtpToJMSWithPropertyPlaceholderTest.java From camelinaction2 with Apache License 2.0 | 6 votes |
@Override protected CamelContext createCamelContext() throws Exception { // create CamelContext CamelContext camelContext = super.createCamelContext(); // connect to embedded ActiveMQ JMS broker ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost"); camelContext.addComponent("jms", JmsComponent.jmsComponentAutoAcknowledge(connectionFactory)); // setup the properties component to use the test file PropertiesComponent prop = camelContext.getComponent("properties", PropertiesComponent.class); prop.setLocation("classpath:rider-test.properties"); return camelContext; }
Example #6
Source File: TransactedJMSIntegrationTest.java From wildfly-camel with Apache License 2.0 | 5 votes |
@Before public void setUp() throws Exception { JtaTransactionManager jtaTransactionManager = new JtaTransactionManager(userTransaction, transactionManager); TransactionTemplate template = new TransactionTemplate(jtaTransactionManager, new DefaultTransactionDefinition(TransactionDefinition.PROPAGATION_REQUIRED)); SpringTransactionPolicy transactionPolicy = new SpringTransactionPolicy(); transactionPolicy.setTransactionTemplate(template); transactionPolicy.setTransactionManager(jtaTransactionManager); initialctx.bind("PROPAGATION_REQUIRED", transactionPolicy); initialctx.bind("transactionManager", jtaTransactionManager); jmsComponent = JmsComponent.jmsComponentTransacted(connectionFactory, jtaTransactionManager); }
Example #7
Source File: JmsComponentAutoConfiguration.java From camel-spring-boot with Apache License 2.0 | 5 votes |
@Lazy @Bean(name = "jms-component") @ConditionalOnMissingBean(JmsComponent.class) public JmsComponent configureJmsComponent() throws Exception { JmsComponent component = new JmsComponent(); component.setCamelContext(camelContext); Map<String, Object> parameters = new HashMap<>(); IntrospectionSupport.getProperties(configuration, parameters, null, false); CamelPropertiesHelper.setCamelProperties(camelContext, component, parameters, false); if (ObjectHelper.isNotEmpty(customizers)) { for (ComponentCustomizer<JmsComponent> customizer : customizers) { boolean useCustomizer = (customizer instanceof HasId) ? HierarchicalPropertiesEvaluator.evaluate( applicationContext.getEnvironment(), "camel.component.customizer", "camel.component.jms.customizer", ((HasId) customizer).getId()) : HierarchicalPropertiesEvaluator.evaluate( applicationContext.getEnvironment(), "camel.component.customizer", "camel.component.jms.customizer"); if (useCustomizer) { LOGGER.debug("Configure component {}, with customizer {}", component, customizer); customizer.customize(component); } } } return component; }
Example #8
Source File: OrderRouterWithWireTap.java From camelinaction with Apache License 2.0 | 5 votes |
public static void main(String args[]) throws Exception { // create CamelContext CamelContext context = new DefaultCamelContext(); // connect to embedded ActiveMQ JMS broker ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost"); context.addComponent("jms", JmsComponent.jmsComponentAutoAcknowledge(connectionFactory)); // add our route to the CamelContext context.addRoutes(new RouteBuilder() { @Override public void configure() { // load file orders from src/data into the JMS queue from("file:src/data?noop=true").to("jms:incomingOrders"); // content-based router from("jms:incomingOrders") .wireTap("jms:orderAudit") .choice() .when(header("CamelFileName").endsWith(".xml")) .to("jms:xmlOrders") .when(header("CamelFileName").regex("^.*(csv|csl)$")) .to("jms:csvOrders") .otherwise() .to("jms:badOrders"); } }); // start the route and let it do its work context.start(); Thread.sleep(2000); // stop the CamelContext context.stop(); }
Example #9
Source File: FtpToJMSWithProcessorExample.java From camelinaction with Apache License 2.0 | 5 votes |
public static void main(String args[]) throws Exception { // create CamelContext CamelContext context = new DefaultCamelContext(); // connect to embedded ActiveMQ JMS broker ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost"); context.addComponent("jms", JmsComponent.jmsComponentAutoAcknowledge(connectionFactory)); // add our route to the CamelContext context.addRoutes(new RouteBuilder() { @Override public void configure() { from("ftp://rider.com/orders?username=rider&password=secret"). process(new Processor() { public void process(Exchange exchange) throws Exception { System.out.println("We just downloaded: " + exchange.getIn().getHeader("CamelFileName")); } }). to("jms:incomingOrders"); } }); // start the route and let it do its work context.start(); Thread.sleep(10000); // stop the CamelContext context.stop(); }
Example #10
Source File: OrderRouterWithRecipientListAnnotationTest.java From camelinaction2 with Apache License 2.0 | 5 votes |
@Override protected CamelContext createCamelContext() throws Exception { // create CamelContext CamelContext camelContext = super.createCamelContext(); // connect to embedded ActiveMQ JMS broker ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost"); camelContext.addComponent("jms", JmsComponent.jmsComponentAutoAcknowledge(connectionFactory)); return camelContext; }
Example #11
Source File: OrderRouterWithRecipientListTest.java From camelinaction2 with Apache License 2.0 | 5 votes |
@Override protected CamelContext createCamelContext() throws Exception { // create CamelContext CamelContext camelContext = super.createCamelContext(); // connect to embedded ActiveMQ JMS broker ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost"); camelContext.addComponent("jms", JmsComponent.jmsComponentAutoAcknowledge(connectionFactory)); return camelContext; }
Example #12
Source File: OrderRouterWithFilterTest.java From camelinaction2 with Apache License 2.0 | 5 votes |
@Override protected CamelContext createCamelContext() throws Exception { // create CamelContext CamelContext camelContext = super.createCamelContext(); // connect to embedded ActiveMQ JMS broker ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost"); camelContext.addComponent("jms", JmsComponent.jmsComponentAutoAcknowledge(connectionFactory)); return camelContext; }
Example #13
Source File: OrderRouterWithWireTapTest.java From camelinaction2 with Apache License 2.0 | 5 votes |
@Override protected CamelContext createCamelContext() throws Exception { // create CamelContext CamelContext camelContext = super.createCamelContext(); // connect to embedded ActiveMQ JMS broker ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost"); camelContext.addComponent("jms", JmsComponent.jmsComponentAutoAcknowledge(connectionFactory)); return camelContext; }
Example #14
Source File: OrderRouterWithMulticastSOETest.java From camelinaction2 with Apache License 2.0 | 5 votes |
@Override protected CamelContext createCamelContext() throws Exception { // create CamelContext CamelContext camelContext = super.createCamelContext(); // connect to embedded ActiveMQ JMS broker ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost"); camelContext.addComponent("jms", JmsComponent.jmsComponentAutoAcknowledge(connectionFactory)); return camelContext; }
Example #15
Source File: OrderRouterWithParallelMulticastTest.java From camelinaction2 with Apache License 2.0 | 5 votes |
@Override protected CamelContext createCamelContext() throws Exception { // create CamelContext CamelContext camelContext = super.createCamelContext(); // connect to embedded ActiveMQ JMS broker ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost"); camelContext.addComponent("jms", JmsComponent.jmsComponentAutoAcknowledge(connectionFactory)); return camelContext; }
Example #16
Source File: OrderRouterWithMulticastTest.java From camelinaction2 with Apache License 2.0 | 5 votes |
@Override protected CamelContext createCamelContext() throws Exception { // create CamelContext CamelContext camelContext = super.createCamelContext(); // connect to embedded ActiveMQ JMS broker ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost"); camelContext.addComponent("jms", JmsComponent.jmsComponentAutoAcknowledge(connectionFactory)); return camelContext; }
Example #17
Source File: FtpToJMSWithDynamicToTest.java From camelinaction2 with Apache License 2.0 | 5 votes |
@Override protected CamelContext createCamelContext() throws Exception { // create CamelContext CamelContext camelContext = super.createCamelContext(); // connect to embedded ActiveMQ JMS broker ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost"); camelContext.addComponent("jms", JmsComponent.jmsComponentAutoAcknowledge(connectionFactory)); return camelContext; }
Example #18
Source File: FtpToJMSWithProcessorExample.java From camelinaction2 with Apache License 2.0 | 5 votes |
public static void main(String args[]) throws Exception { // create CamelContext CamelContext context = new DefaultCamelContext(); // connect to embedded ActiveMQ JMS broker ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost"); context.addComponent("jms", JmsComponent.jmsComponentAutoAcknowledge(connectionFactory)); // add our route to the CamelContext context.addRoutes(new RouteBuilder() { @Override public void configure() { from("ftp://rider.com/orders?username=rider&password=secret"). process(new Processor() { public void process(Exchange exchange) throws Exception { System.out.println("We just downloaded: " + exchange.getIn().getHeader("CamelFileName")); } }). to("jms:incomingOrders"); } }); // start the route and let it do its work context.start(); Thread.sleep(10000); // stop the CamelContext context.stop(); }
Example #19
Source File: OrderRouterWithStopTest.java From camelinaction2 with Apache License 2.0 | 5 votes |
@Override protected CamelContext createCamelContext() throws Exception { // create CamelContext CamelContext camelContext = super.createCamelContext(); // connect to embedded ActiveMQ JMS broker ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost"); camelContext.addComponent("jms", JmsComponent.jmsComponentAutoAcknowledge(connectionFactory)); return camelContext; }
Example #20
Source File: OrderRouterTest.java From camelinaction2 with Apache License 2.0 | 5 votes |
@Override protected CamelContext createCamelContext() throws Exception { // create CamelContext CamelContext camelContext = super.createCamelContext(); // connect to embedded ActiveMQ JMS broker ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost"); camelContext.addComponent("jms", JmsComponent.jmsComponentAutoAcknowledge(connectionFactory)); return camelContext; }
Example #21
Source File: OrderRouterOtherwiseTest.java From camelinaction2 with Apache License 2.0 | 5 votes |
@Override protected CamelContext createCamelContext() throws Exception { // create CamelContext CamelContext camelContext = super.createCamelContext(); // connect to embedded ActiveMQ JMS broker ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost"); camelContext.addComponent("jms", JmsComponent.jmsComponentAutoAcknowledge(connectionFactory)); return camelContext; }
Example #22
Source File: OrderRouterSimpleTest.java From camelinaction2 with Apache License 2.0 | 5 votes |
@Override protected CamelContext createCamelContext() throws Exception { // create CamelContext CamelContext camelContext = super.createCamelContext(); // connect to embedded ActiveMQ JMS broker ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost"); camelContext.addComponent("jms", JmsComponent.jmsComponentAutoAcknowledge(connectionFactory)); return camelContext; }
Example #23
Source File: InventoryRoute.java From camelinaction2 with Apache License 2.0 | 5 votes |
/** * Setup JMS component */ @Produces @Named("jms") public static JmsComponent jmsComponent() { ActiveMQComponent jms = new ActiveMQComponent(); jms.setBrokerURL("tcp://localhost:61616"); return jms; }
Example #24
Source File: InventoryRoute.java From camelinaction2 with Apache License 2.0 | 5 votes |
/** * Setup JMS component */ @Produces @Named("jms") public static JmsComponent jmsComponent() { ActiveMQComponent jms = new ActiveMQComponent(); jms.setBrokerURL("tcp://localhost:61616"); return jms; }
Example #25
Source File: ClientCamelJMSITest.java From hawkular-apm with Apache License 2.0 | 5 votes |
@Override protected void initContext(CamelContext context) throws Exception { ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false"); // Note we can explicit name the component context.addComponent("jms", JmsComponent.jmsComponentAutoAcknowledge(connectionFactory)); template = context.createProducerTemplate(); super.initContext(context); }
Example #26
Source File: JmsRouteBuilder.java From wildfly-camel-examples with Apache License 2.0 | 5 votes |
@Override public void configure() throws Exception { /** * Configure the JMSComponent to use the connection factory * injected into this class */ JmsComponent component = new JmsComponent(); component.setConnectionFactory(connectionFactory); getContext().addComponent("jms", component); /** * This route uses the timer component to generate a message which is sent to * the JMS OrdersQueue */ from("timer:produceJMSMessage?period=5s&delay=0&fixedRate=true") .process(new Processor() { @Override public void process(Exchange exchange) throws Exception { Integer count = exchange.getProperty(Exchange.TIMER_COUNTER, Integer.class); Date date = exchange.getProperty(Exchange.TIMER_FIRED_TIME, Date.class); exchange.getOut().setBody(String.format("Message %d created at %s", count, date.toString())); } }) .to("jms:queue:OrdersQueue"); /** * This route is invoked by the {@link MessageDrivenBean} message consumer and outputs * the message payload to the console log */ from("direct:jmsIn") .log("Received message: ${body}"); }
Example #27
Source File: JmsComponentProducer.java From wildfly-camel-examples with Apache License 2.0 | 5 votes |
@Produces @Named("jms") public JmsComponent createJmsComponent() { JmsComponent component = new JmsComponent(); component.setConnectionFactory(connectionFactory); return component; }
Example #28
Source File: OrderRouterWithOutputProcessor.java From camelinaction with Apache License 2.0 | 4 votes |
public static void main(String args[]) throws Exception { // create CamelContext CamelContext context = new DefaultCamelContext(); // connect to embedded ActiveMQ JMS broker ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost"); context.addComponent("jms", JmsComponent.jmsComponentAutoAcknowledge(connectionFactory)); // add our route to the CamelContext context.addRoutes(new RouteBuilder() { @Override public void configure() { // load file orders from src/data into the JMS queue from("file:src/data?noop=true").to("jms:incomingOrders"); // content-based router from("jms:incomingOrders") .process(new Processor() { public void process(Exchange exchange) throws Exception { System.out.println("Received order: " + exchange.getIn().getBody(String.class)); } }) .choice() .when(header("CamelFileName").endsWith(".xml")) .to("jms:xmlOrders") .when(header("CamelFileName").regex("^.*(csv|csl)$")) .to("jms:csvOrders") .otherwise() .to("jms:badOrders"); } }); // start the route and let it do its work context.start(); Thread.sleep(2000); // stop the CamelContext context.stop(); }
Example #29
Source File: JmsComponentProducer.java From wildfly-camel-examples with Apache License 2.0 | 4 votes |
@Produces @Named("jms") public JmsComponent createJmsComponent(PlatformTransactionManager transactionManager) { return JmsComponent.jmsComponentTransacted(connectionFactory, transactionManager); }
Example #30
Source File: OrderRouterWithFilter.java From camelinaction with Apache License 2.0 | 4 votes |
public static void main(String args[]) throws Exception { // create CamelContext CamelContext context = new DefaultCamelContext(); // connect to embedded ActiveMQ JMS broker ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost"); context.addComponent("jms", JmsComponent.jmsComponentAutoAcknowledge(connectionFactory)); // add our route to the CamelContext context.addRoutes(new RouteBuilder() { @Override public void configure() { // load file orders from src/data into the JMS queue from("file:src/data?noop=true").to("jms:incomingOrders"); // content-based router from("jms:incomingOrders") .choice() .when(header("CamelFileName").endsWith(".xml")) .to("jms:xmlOrders") .when(header("CamelFileName").regex("^.*(csv|csl)$")) .to("jms:csvOrders") .otherwise() .to("jms:badOrders"); // lets filter out the test messages from("jms:xmlOrders").filter(xpath("/order[not(@test)]")) .process(new Processor() { public void process(Exchange exchange) throws Exception { System.out.println("Received XML order: " + exchange.getIn().getHeader("CamelFileName")); } }); } }); // start the route and let it do its work context.start(); Thread.sleep(10000); // stop the CamelContext context.stop(); }