@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); } } }
public static void main(String args[]) throws Exception { CamelContext context = new DefaultCamelContext(); // Set up the ActiveMQ JMS Components ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://localhost:51616"); // Note we can explicit name of the component context.addComponent("jms", JmsComponent.jmsComponentAutoAcknowledge(connectionFactory)); context.start(); ProducerTemplate template = context.createProducerTemplate(); String out = template.requestBodyAndHeader("jms:queue:loan", null, Constants.PROPERTY_SSN, "Client-A", String.class); System.out.println(out); template.stop(); context.stop(); }
public static void main(String... args) throws Exception { // setup an embedded JMS broker JmsBroker broker = new JmsBroker(); broker.start(); // create a camel context CamelContext context = new DefaultCamelContext(); // Set up the ActiveMQ JMS Components ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://localhost:51616"); // Note we can explicitly name the component context.addComponent("jms", JmsComponent.jmsComponentAutoAcknowledge(connectionFactory)); // add the route context.addRoutes(new LoanBrokerRoute()); // start Camel context.start(); System.out.println("Server is ready"); // let it run for 5 minutes before shutting down Thread.sleep(5 * 60 * 1000); context.stop(); Thread.sleep(1000); broker.stop(); }
@Before public void startServices() throws Exception { deleteDirectory("activemq-data"); camelContext = new DefaultCamelContext(); broker = new JmsBroker("vm://localhost"); broker.start(); // Set up the ActiveMQ JMS Components ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost"); // Note we can explicitly name the component camelContext.addComponent("jms", JmsComponent.jmsComponentAutoAcknowledge(connectionFactory)); camelContext.addRoutes(new LoanBrokerRoute()); template = camelContext.createProducerTemplate(); camelContext.start(); }
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(); }
@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; }
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(); }
protected CamelContext createCamelContext() throws Exception { CamelContext camelContext = super.createCamelContext(); ConnectionFactory connectionFactory = CamelJmsTestHelper.createConnectionFactory(); camelContext .addComponent("activemq", JmsComponent.jmsComponentAutoAcknowledge(connectionFactory)); return camelContext; }
@Produces @Named("jms") public JmsComponent createJmsComponent() { JmsComponent component = new JmsComponent(); component.setConnectionFactory(connectionFactory); return component; }
@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}"); }
@Override protected void setupCamelContext(CamelContext camelContext) throws Exception { // setup the ActiveMQ component ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(); connectionFactory.setBrokerURL("vm://localhost?broker.persistent=false&broker.useJmx=false"); // and register it into the CamelContext JmsComponent answer = new JmsComponent(); answer.setConnectionFactory(connectionFactory); camelContext.addComponent("jms", answer); }
@Override protected Context createJndiContext() throws Exception { JndiContext answer = new JndiContext(); // add ActiveMQ with embedded broker ConnectionFactory connectionFactory = CamelJmsTestHelper.createConnectionFactory(); JmsComponent amq = jmsComponentAutoAcknowledge(connectionFactory); amq.setCamelContext(context); answer.bind("jms", amq); return answer; }
@Override protected Context createJndiContext() throws Exception { JndiContext answer = new JndiContext(); // add ActiveMQ with embedded broker ConnectionFactory connectionFactory = CamelJmsTestHelper.createConnectionFactory(); JmsComponent amq = jmsComponentAutoAcknowledge(connectionFactory); amq.setCamelContext(context); answer.bind("activemq", amq); return answer; }
@Override protected Context createJndiContext() throws Exception { JndiContext answer = new JndiContext(); answer.bind("myBean", myBean); // add ActiveMQ with embedded broker ConnectionFactory connectionFactory = CamelJmsTestHelper.createConnectionFactory(); JmsComponent amq = jmsComponentAutoAcknowledge(connectionFactory); amq.setCamelContext(context); answer.bind("jms", amq); return answer; }
@Override protected Context createJndiContext() throws Exception { deleteDirectory("activemq-data"); JndiContext answer = new JndiContext(); // add ActiveMQ with embedded broker which must be persistent ConnectionFactory connectionFactory = CamelJmsTestHelper.createPersistentConnectionFactory(); JmsComponent amq = jmsComponentAutoAcknowledge(connectionFactory); amq.setCamelContext(context); answer.bind("jms", amq); return answer; }
@Override protected Context createJndiContext() throws Exception { JndiContext answer = new JndiContext(); // add ActiveMQ with embedded broker ConnectionFactory connectionFactory = CamelJmsTestHelper.createConnectionFactory(); JmsComponent amq = jmsComponentAutoAcknowledge(connectionFactory); amq.setCamelContext(context); answer.bind("activemq", amq); answer.bind("myBean1", b1); answer.bind("myBean2", b2); answer.bind("myBean3", b3); return answer; }
@Override protected Context createJndiContext() throws Exception { JndiContext answer = new JndiContext(); answer.bind("myBean", new MyBean()); // add AMQ client and make use of connection pooling we depend on because of the (large) number // of the JMS messages we do produce // add ActiveMQ with embedded broker ConnectionFactory connectionFactory = CamelJmsTestHelper.createConnectionFactory(); JmsComponent amq = jmsComponentAutoAcknowledge(connectionFactory); amq.setCamelContext(context); answer.bind("activemq", amq); return answer; }
@Override protected Context createJndiContext() throws Exception { JndiContext answer = new JndiContext(); // add ActiveMQ with embedded broker ConnectionFactory connectionFactory = CamelJmsTestHelper.createConnectionFactory(); JmsComponent amq = jmsComponentAutoAcknowledge(connectionFactory); amq.setCamelContext(context); answer.bind("jms", amq); answer.bind("myBean", new MyBean()); return answer; }
@Bean @ConditionalOnClass(CamelContext.class) @ConditionalOnMissingBean(JmsComponent.class) public JmsComponent configureJmsComponent(CamelContext camelContext, JmsComponentConfiguration configuration) throws Exception { JmsComponent component = new JmsComponent(); component.setCamelContext(camelContext); Map<String, Object> parameters = new HashMap<>(); IntrospectionSupport.getProperties(configuration, parameters, null, false); IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), component, parameters); return component; }
protected CamelContext createCamelContext() throws Exception { CamelContext camelContext = super.createCamelContext(); ConnectionFactory connectionFactory = CamelJmsTestHelper.createConnectionFactory(); camelContext.addComponent("activemq", jmsComponentAutoAcknowledge(connectionFactory)); JmsComponent jms = camelContext.getComponent("activemq", JmsComponent.class); jms.getConfiguration().setJmsKeyFormatStrategy(new PassThroughJmsKeyFormatStrategy()); return camelContext; }
protected CamelContext createCamelContext() throws Exception { CamelContext camelContext = super.createCamelContext(); ConnectionFactory connectionFactory = CamelJmsTestHelper.createConnectionFactory(); camelContext.addComponent("activemq", jmsComponentAutoAcknowledge(connectionFactory)); amq = camelContext.getComponent("activemq", JmsComponent.class); return camelContext; }
protected CamelContext createCamelContext() throws Exception { CamelContext camelContext = super.createCamelContext(); // no redeliveries ConnectionFactory connectionFactory = CamelJmsTestHelper.createConnectionFactory(null, 0); JmsComponent component = jmsComponentTransacted(connectionFactory); camelContext.addComponent("activemq", component); return camelContext; }
protected CamelContext createCamelContext() throws Exception { CamelContext camelContext = super.createCamelContext(); ConnectionFactory connectionFactory = CamelJmsTestHelper.createConnectionFactory(); // configure to use passthrough JmsComponent activemq = jmsComponentAutoAcknowledge(connectionFactory); activemq.setJmsKeyFormatStrategy("passthrough"); camelContext.addComponent("activemq", activemq); return camelContext; }
@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); }
/** * Setup JMS component */ @Produces @Named("jms") public static JmsComponent jmsComponent() { ActiveMQComponent jms = new ActiveMQComponent(); jms.setBrokerURL("tcp://localhost:61616"); return jms; }
@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; }