Java 类org.apache.camel.component.jms.JmsComponent 实例源码

项目:hacep    文件:CamelRouter.java   
@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);
        }
    }
}
项目:Camel    文件:Client.java   
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();
}
项目:Camel    文件:LoanBroker.java   
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();
}
项目:Camel    文件:LoanBrokerQueueTest.java   
@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();
}
项目:camelinaction2    文件:FtpToJMSExample.java   
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();
}
项目:camelinaction2    文件:FtpToJMSWithPropertyPlaceholderTest.java   
@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;
}
项目:camelinaction    文件:FtpToJMSExample.java   
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();
}
项目:t4f-data    文件:FtpToJMSExample.java   
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();
}
项目:eds    文件:ActiveMQWithCamelTest.java   
protected CamelContext createCamelContext() throws Exception {
  CamelContext camelContext = super.createCamelContext();

  ConnectionFactory connectionFactory = CamelJmsTestHelper.createConnectionFactory();
  camelContext
      .addComponent("activemq", JmsComponent.jmsComponentAutoAcknowledge(connectionFactory));

  return camelContext;
}
项目:wildfly-camel-examples    文件:JmsComponentProducer.java   
@Produces
@Named("jms")
public JmsComponent createJmsComponent() {
    JmsComponent component = new JmsComponent();
    component.setConnectionFactory(connectionFactory);
    return component;
}
项目:wildfly-camel-examples    文件:JmsRouteBuilder.java   
@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}");
}
项目:Camel    文件:MyApplication.java   
@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);
}
项目:Camel    文件:RemoveEndpointsTest.java   
@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;
}
项目:Camel    文件:NettyAsyncRequestReplyTest.java   
@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;
}
项目:Camel    文件:ShiroOverJmsTest.java   
@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;
}
项目:Camel    文件:JmsIntegrationTest.java   
@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;
}
项目:Camel    文件:JmsValidatorTest.java   
@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;
}
项目:Camel    文件:JmsHttpPostIssueTest.java   
@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;
}
项目:Camel    文件:JmsPollEnrichTest.java   
@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;
}
项目:Camel    文件:JmsResequencerTest.java   
@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;
}
项目:Camel    文件:JmsJaxbTest.java   
@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;
}
项目:Camel    文件:JmsJettyAsyncTest.java   
@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;
}
项目:Camel    文件:JmsPerformanceTest.java   
@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;
}
项目:Camel    文件:DynamicRouteTest.java   
@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;
}
项目:Camel    文件:JmsHttpJmsTest.java   
@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;
}
项目:Camel    文件:JmsHttpPostIssueWithMockTest.java   
@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;
}
项目:Camel    文件:HttpJmsAsyncTimeoutTest.java   
@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;
}
项目:Camel    文件:HttpAsyncDslTest.java   
@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;
}
项目:Camel    文件:JmsComponentAutoConfiguration.java   
@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;
}
项目:Camel    文件:JmsPassThroughtJmsKeyFormatStrategyUsingJmsConfigurationTest.java   
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;
}
项目:Camel    文件:JmsAnotherCustomJMSReplyToTest.java   
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;
}
项目:Camel    文件:JmsJMSReplyToEndpointUsingInOutTest.java   
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;
}
项目:Camel    文件:JmsTransactedOnExceptionRollbackOnExceptionTest.java   
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;
}
项目:Camel    文件:JmsCustomJMSReplyToIssueTest.java   
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;
}
项目:Camel    文件:JmsTransactedDeadLetterChannelHandlerRollbackOnExceptionTest.java   
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;
}
项目:Camel    文件:JmsPassThroughtJmsKeyFormatStrategyTest.java   
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;
}
项目:hawkular-apm    文件:ClientCamelJMSITest.java   
@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);
}
项目:camelinaction2    文件:InventoryRoute.java   
/**
 * Setup JMS component
 */
@Produces
@Named("jms")
public static JmsComponent jmsComponent() {
    ActiveMQComponent jms = new ActiveMQComponent();
    jms.setBrokerURL("tcp://localhost:61616");
    return jms;
}
项目:camelinaction2    文件:InventoryRoute.java   
/**
 * Setup JMS component
 */
@Produces
@Named("jms")
public static JmsComponent jmsComponent() {
    ActiveMQComponent jms = new ActiveMQComponent();
    jms.setBrokerURL("tcp://localhost:61616");
    return jms;
}
项目:camelinaction2    文件:OrderRouterSimpleTest.java   
@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;
}