项目: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");
}
@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;
}
@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",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",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;
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。