Java 类org.apache.camel.component.sjms.SjmsComponent 实例源码

项目:Camel    文件:TransactedConsumerSupport.java   
@Override
protected CamelContext createCamelContext() throws Exception {
    CamelContext camelContext = super.createCamelContext();

    ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(getBrokerUri());
    // use low redelivery delay to speed
    connectionFactory.getRedeliveryPolicy().setInitialRedeliveryDelay(100);
    connectionFactory.getRedeliveryPolicy().setRedeliveryDelay(100);
    connectionFactory.getRedeliveryPolicy().setUseCollisionAvoidance(false);
    connectionFactory.getRedeliveryPolicy().setUseExponentialBackOff(false);

    SjmsComponent component = new SjmsComponent();
    component.setConnectionFactory(connectionFactory);
    camelContext.addComponent("sjms", component);

    return camelContext;
}
项目:Camel    文件:SjmsBatchConsumerTest.java   
@Override
public CamelContext createCamelContext() throws Exception {
    SimpleRegistry registry = new SimpleRegistry();
    registry.put("testStrategy", new ListAggregationStrategy());
    ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(broker.getTcpConnectorUri());

    SjmsComponent sjmsComponent = new SjmsComponent();
    sjmsComponent.setConnectionFactory(connectionFactory);

    SjmsBatchComponent sjmsBatchComponent = new SjmsBatchComponent();
    sjmsBatchComponent.setConnectionFactory(connectionFactory);

    CamelContext context = new DefaultCamelContext(registry);
    context.addComponent("sjms", sjmsComponent);
    context.addComponent("sjms-batch", sjmsBatchComponent);
    return context;
}
项目:Camel    文件:SjmsBatchEndpointTest.java   
@Override
protected CamelContext createCamelContext() throws Exception {
    SimpleRegistry registry = new SimpleRegistry();
    registry.put("aggStrategy", AggregationStrategies.groupedExchange());

    ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory();
    connectionFactory.setBrokerURL(broker.getTcpConnectorUri());

    SjmsComponent sjmsComponent = new SjmsComponent();
    sjmsComponent.setConnectionFactory(connectionFactory);

    SjmsBatchComponent sjmsBatchComponent = new SjmsBatchComponent();
    sjmsBatchComponent.setConnectionFactory(connectionFactory);

    CamelContext context = new DefaultCamelContext(registry);
    context.addComponent("sjms-batch", sjmsBatchComponent);
    context.addComponent("sjms", sjmsComponent);

    return context;
}
项目:devnation2014    文件:CamelSjmsConsumerRoute.java   
@Activate
public void activate() throws RuntimeException {
    LOGGER.info("Spinning up the Camel JMS Consumer Route");

    try {
        context = new DefaultCamelContext();
        context.setName("consumer-context");

        SjmsComponent sjms = new SjmsComponent();
        sjms.setConnectionFactory(connectionFactory);
        context.addComponent("sjms", sjms);

        context.addRoutes(new RouteBuilder() {

            @Override
            public void configure() throws Exception {
                from("sjms:queue:test.queue")
                    .routeId("consumer-route-1")
                    .log("Consumer message received : ${body}");
            }
        });
        context.start();
    } catch (Exception e) {
        throw new RuntimeCamelException("Error Adding Route to the Camel Context", e);
    }
    LOGGER.info("Spinning up the Camel JMS Consumer Route: SUCCESS");
}
项目:syndesis    文件:AbstractActiveMQConnector.java   
@Override
public String createEndpointUri(String scheme, Map<String, String> options) throws URISyntaxException {

    // validate url
    if (ObjectHelper.isEmpty(this.brokerUrl)) {
        throw new IllegalArgumentException("Missing required property brokerUrl");
    }

    // create ActiveMQ Connection Factory
    final ActiveMQConnectionFactory connectionFactory = ActiveMQUtil.createActiveMQConnectionFactory(this.brokerUrl, username, this.password, this.brokerCertificate, clientCertificate, skipCertificateCheck);
    SjmsComponent delegate = getCamelContext().getComponent(scheme, SjmsComponent.class);
    delegate.setConnectionFactory(connectionFactory);

    return super.createEndpointUri(scheme, options);
}
项目:Camel    文件:Jms.java   
@Produces
@Named("sjms")
@ApplicationScoped
SjmsComponent sjms() {
    SjmsComponent component = new SjmsComponent();
    component.setConnectionFactory(new ActiveMQConnectionFactory("vm://broker?broker.persistent=false&broker.useShutdownHook=false&broker.useJmx=false"));
    component.setConnectionCount(maxConnections);
    return component;
}
项目:Camel    文件:SjmsComponentAutoConfiguration.java   
@Bean
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(SjmsComponent.class)
public SjmsComponent configureSjmsComponent(CamelContext camelContext,
        SjmsComponentConfiguration configuration) throws Exception {
    SjmsComponent component = new SjmsComponent();
    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    文件:TransactedQueueProducerTest.java   
@Override
protected CamelContext createCamelContext() throws Exception {
    ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://broker?broker.persistent=false&broker.useJmx=false");
    CamelContext camelContext = super.createCamelContext();
    SjmsComponent component = new SjmsComponent();
    component.setConnectionFactory(connectionFactory);
    camelContext.addComponent("sjms", component);
    return camelContext;
}
项目:Camel    文件:BatchTransactedProducerSupport.java   
@Override
protected CamelContext createCamelContext() throws Exception {
    CamelContext camelContext = super.createCamelContext();

    ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(getBrokerUri());
    SjmsComponent component = new SjmsComponent();
    component.setConnectionFactory(connectionFactory);
    camelContext.addComponent("sjms", component);

    return camelContext;
}
项目:Camel    文件:TransactedTopicProducerTest.java   
@Override
protected CamelContext createCamelContext() throws Exception {
    ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://broker?broker.persistent=false&broker.useJmx=false");
    ConnectionFactoryResource connectionResource = new ConnectionFactoryResource();
    connectionResource.setConnectionFactory(connectionFactory);
    connectionResource.setClientId("test-connection-1");
    CamelContext camelContext = super.createCamelContext();
    SjmsComponent component = new SjmsComponent();
    component.setConnectionResource(connectionResource);
    component.setConnectionCount(1);
    camelContext.addComponent("sjms", component);
    return camelContext;
}
项目:Camel    文件:AsyncTopicProducerTest.java   
protected CamelContext createCamelContext() throws Exception {
    CamelContext camelContext = super.createCamelContext();

    ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(
            "vm://broker?broker.persistent=false&broker.useJmx=false");
    SjmsComponent component = new SjmsComponent();
    component.setConnectionFactory(connectionFactory);
    camelContext.addComponent("sjms", component);

    return camelContext;
}
项目:Camel    文件:AsyncQueueProducerTest.java   
protected CamelContext createCamelContext() throws Exception {
    CamelContext camelContext = super.createCamelContext();

    ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(
            "vm://broker?broker.persistent=false&broker.useJmx=false");
    SjmsComponent component = new SjmsComponent();
    component.setConnectionFactory(connectionFactory);
    camelContext.addComponent("sjms", component);

    return camelContext;
}
项目:Camel    文件:InOnlyTopicDurableConsumerTest.java   
@Override
protected CamelContext createCamelContext() throws Exception {
    ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(BROKER_URI);
    ConnectionFactoryResource connectionResource = new ConnectionFactoryResource();
    connectionResource.setConnectionFactory(connectionFactory);
    connectionResource.setClientId(CONNECTION_ID);
    CamelContext camelContext = super.createCamelContext();
    SjmsComponent component = new SjmsComponent();
    component.setConnectionResource(connectionResource);
    component.setConnectionCount(1);
    camelContext.addComponent("sjms", component);
    return camelContext;
}
项目:Camel    文件:AsyncConsumerInOutTest.java   
protected CamelContext createCamelContext() throws Exception {
    CamelContext camelContext = super.createCamelContext();

    camelContext.addComponent("async", new MyAsyncComponent());

    ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(
            "vm://broker?broker.persistent=false&broker.useJmx=false");
    SjmsComponent component = new SjmsComponent();
    component.setConnectionFactory(connectionFactory);
    camelContext.addComponent("sjms", component);

    return camelContext;
}
项目:Camel    文件:AsyncConsumerFalseTest.java   
protected CamelContext createCamelContext() throws Exception {
    CamelContext camelContext = super.createCamelContext();

    camelContext.addComponent("async", new MyAsyncComponent());

    ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(
            "vm://broker?broker.persistent=false&broker.useJmx=false");
    SjmsComponent component = new SjmsComponent();
    component.setConnectionFactory(connectionFactory);
    camelContext.addComponent("sjms", component);

    return camelContext;
}
项目:Camel    文件:JmsTestSupport.java   
@Override
protected CamelContext createCamelContext() throws Exception {
    CamelContext camelContext = super.createCamelContext();
    ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(brokerUri);
    connection = connectionFactory.createConnection();
    connection.start();
    session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    SjmsComponent component = new SjmsComponent();
    component.setConnectionCount(1);
    component.setConnectionFactory(connectionFactory);
    camelContext.addComponent("sjms", component);
    return camelContext;
}
项目:Camel    文件:ConnectionResourceIT.java   
@Override
protected CamelContext createCamelContext() throws Exception {
    CamelContext camelContext = new DefaultCamelContext();
    AMQConnectionResource pool = new AMQConnectionResource("tcp://localhost:33333", 1);
    SjmsComponent component = new SjmsComponent();
    component.setConnectionResource(pool);
    camelContext.addComponent("sjms", component);
    return camelContext;
}
项目:Camel    文件:CAMEL6820Test.java   
@Test
public void testCamelGenericFileConverterMessage() throws Exception {
    File f = new File(TEST_DATA_DIR);

    // First make sure the directories are empty or purged so we don't get bad data on a 
    // test that is run against an uncleaned target directory
    if (f.exists()) {
        FileUtils.deleteDirectory(new File(TEST_DATA_DIR));

    }

    // Then add the directory back
    f.mkdirs();

    // Make sure the SjmsComponent is available
    SjmsComponent component = context.getComponent("sjms", SjmsComponent.class);
    assertNotNull(component);

    // Create the test String
    final String expectedBody = "Hello World";

    // Create the Mock endpoint
    MockEndpoint mock = getMockEndpoint(MOCK_RESULT_URI);
    mock.expectedMessageCount(1);
    mock.expectedBodiesReceived(expectedBody);

    // Send the message to a file to be read by the file component
    template.sendBody(FILE_OUTPUT_URI, expectedBody);

    // Verify that it is working correctly
    mock.assertIsSatisfied();
}
项目:camel-cdi    文件:Jms.java   
@Produces
@Named("sjms")
@ApplicationScoped
SjmsComponent sjms() {
    SjmsComponent component = new SjmsComponent();
    component.setConnectionFactory(new ActiveMQConnectionFactory("vm://broker?broker.persistent=false&broker.useShutdownHook=false&broker.useJmx=false"));
    component.setConnectionCount(maxConnections);
    return component;
}
项目:devnation2014    文件:CamelSjmsProducerRoute.java   
@Activate
public void activate() {
    LOGGER.info("Spinning up the Camel JMS Producer Route");

    try {
        context = new DefaultCamelContext();
        context.setName("producer-context");

        SjmsComponent sjms = new SjmsComponent();
        sjms.setConnectionFactory(connectionFactory);
        context.addComponent("sjms", sjms);
        context.addRoutes(new RouteBuilder() {

            @Override
            public void configure() throws Exception {
                from("timer://producer-route-timer?fixedRate=true&period=10s")
                    .routeId("producer-route-1")
                    .process(new Processor() {

                        @Override
                        public void process(Exchange exchange) throws Exception {
                            Date date = new Date();
                            String datestamp = date.toString();
                            exchange.getIn().setBody(datestamp);
                            exchange.getIn().removeHeader("firedTime");
                        }
                    })
                    .log("Producer message sent     : ${body}")
                    .to("sjms:queue:test.queue");
            }
        });
        context.start();
    } catch (Exception e) {
        throw new RuntimeCamelException("Error Adding Route to the Camel Context", e);
    }
    LOGGER.info("Spinning up the Camel JMS Producer Route: SUCCESS");
}
项目:camel-sjms-demo    文件:CamelContextProducer.java   
@Produces
@ApplicationScoped
public CamelContext camelContext() throws Exception {
    DefaultCamelContext context = new DefaultCamelContext();
    context.getManagementStrategy().setStatisticsLevel(ManagementStatisticsLevel.Off);

    SjmsComponent jmsComponent = new SjmsComponent();
    jmsComponent.setConnectionFactory(cf);

    context.addComponent("sjms", jmsComponent);
    context.addComponent("ejb", new EjbComponent());

    context.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            from("direct:calculatorProxy").routeId("calculatorSource")
                .log("calculator proxy called")
                .to("sjms:calculator-queue?exchangePattern=InOut&responseTimeOut=10000");
            from("sjms:calculator-queue?exchangePattern=InOut").routeId("calculatorSink")
                .log("calling calculator impl")
                .to("ejb://java:global/sjms-demo1/CalculatorImpl");
        }

    });
    context.start();
    return context;
}
项目:camel-sjms-demo    文件:CamelContextProducer.java   
@Produces
@ApplicationScoped
public CamelContext camelContext() throws Exception {
    DefaultCamelContext context = new DefaultCamelContext();
    context.getManagementStrategy().setStatisticsLevel(ManagementStatisticsLevel.Off);

    SjmsComponent jmsComponent = new SjmsComponent();
    jmsComponent.setConnectionFactory(cf);

    context.addComponent("sjms", jmsComponent);
    context.addComponent("ejb", new EjbComponent());

    context.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            from("direct:calculatorProxy")
                .routeId("calculatorSource")
                .log("calculator proxy called")
                .to("sjms:calculator-queue?exchangePattern=InOut&responseTimeOut=1000000&synchronous=false");
            from("sjms:calculator-queue?exchangePattern=InOut").routeId("calculatorSink")
                .log("calling calculator impl")
                .to("ejb://java:global/sjms-demo2/CalculatorImpl");
        }

    });
    context.start();
    return context;
}