本文整理汇总了Java中org.apache.activemq.camel.component.ActiveMQComponent类的典型用法代码示例。如果您正苦于以下问题:Java ActiveMQComponent类的具体用法?Java ActiveMQComponent怎么用?Java ActiveMQComponent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ActiveMQComponent类属于org.apache.activemq.camel.component包,在下文中一共展示了ActiveMQComponent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createCamelContext
import org.apache.activemq.camel.component.ActiveMQComponent; //导入依赖的package包/类
@Override
protected CamelContext createCamelContext() throws Exception {
SimpleRegistry registry = new SimpleRegistry();
ActiveMQConnectionFactory connectionFactory =
new ActiveMQConnectionFactory("vm://embedded?broker.persistent=false");
registry.put("connectionFactory", connectionFactory);
JmsTransactionManager jmsTransactionManager = new JmsTransactionManager();
jmsTransactionManager.setConnectionFactory(connectionFactory);
registry.put("jmsTransactionManager", jmsTransactionManager);
SpringTransactionPolicy propagationRequired = new SpringTransactionPolicy();
propagationRequired.setTransactionManager(jmsTransactionManager);
propagationRequired.setPropagationBehaviorName("PROPAGATION_REQUIRED");
registry.put("PROPAGATION_REQUIRED", propagationRequired);
SpringTransactionPolicy propagationNotSupported = new SpringTransactionPolicy();
propagationNotSupported.setTransactionManager(jmsTransactionManager);
propagationNotSupported.setPropagationBehaviorName("PROPAGATION_NOT_SUPPORTED");
registry.put("PROPAGATION_NOT_SUPPORTED", propagationNotSupported);
CamelContext camelContext = new DefaultCamelContext(registry);
ActiveMQComponent activeMQComponent = new ActiveMQComponent();
activeMQComponent.setConnectionFactory(connectionFactory);
activeMQComponent.setTransactionManager(jmsTransactionManager);
camelContext.addComponent("jms", activeMQComponent);
return camelContext;
}
示例2: activeMQComponent
import org.apache.activemq.camel.component.ActiveMQComponent; //导入依赖的package包/类
@Bean(name="activemq")
ActiveMQComponent activeMQComponent(){
// 修改为activemq component ,activemq做了调优
ActiveMQConfiguration config = new ActiveMQConfiguration();
// config.setMapJmsMessage(false); // 自动映射jms消息
config.setConcurrentConsumers(jmsMinConsumers);
config.setMaxConcurrentConsumers(jmsMaxConsumers);
config.setConnectionFactory(connectionFactory());
// config.setAcknowledgementMode(cc);
// config.setAcknowledgementMode(Session.CLIENT_ACKNOWLEDGE);
config.setAcknowledgementMode(Session.SESSION_TRANSACTED);
// 事务控制
// config.setTransactionManager(transactionManger());
config.setTransacted(true);
ActiveMQComponent component = new ActiveMQComponent(config);
component.setMessageConverter(new EventMessageConvertor());
// session 客户端确认/无事务
// component.setAcknowledgementMode(Session.AUTO_ACKNOWLEDGE);
// component.setAcknowledgementMode(Session.CLIENT_ACKNOWLEDGE);
// 针对本地事务(非XA事务的调优)
component.setCacheLevelName("CACHE_CONSUMER");
return component;
}
示例3: createActiveMQComponent
import org.apache.activemq.camel.component.ActiveMQComponent; //导入依赖的package包/类
/**
* Factory to create the {@link ActiveMQComponent} which is used in this application
* to connect to the remote ActiveMQ broker.
*/
@Produces
public static ActiveMQComponent createActiveMQComponent() {
// you can set other options but this is the basic just needed
ActiveMQComponent amq = new ActiveMQComponent();
// The ActiveMQ Broker allows anonymous connection by default
// amq.setUserName("admin");
// amq.setPassword("admin");
// the url to the remote ActiveMQ broker
amq.setBrokerURL("tcp://localhost:61616");
return amq;
}
示例4: configure
import org.apache.activemq.camel.component.ActiveMQComponent; //导入依赖的package包/类
@Override
public void configure() throws Exception {
JaxbDataFormat jaxb = new JaxbDataFormat();
jaxb.setContextPath("camelinaction");
// TODO: due activemq bug we need to configure it here also
ActiveMQComponent jms = new ActiveMQComponent(getContext());
jms.setBrokerURL("tcp://localhost:61616");
getContext().addComponent("jms", jms);
from("direct:inventory")
.log("Calling inventory service using JMS")
.hystrix()
// call the legacy system using JMS
.to("jms:queue:inventory")
// the returned data is in XML format so convert that to POJO using JAXB
.unmarshal(jaxb)
.onFallback()
.log("Circuit breaker failed so using fallback response")
// fallback and read inventory from classpath which is in XML format
.transform().constant("resource:classpath:fallback-inventory.xml");
}
示例5: newAMQInstance
import org.apache.activemq.camel.component.ActiveMQComponent; //导入依赖的package包/类
public static ActiveMQComponent newAMQInstance(){
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory();
connectionFactory.setBrokerURL("vm:localhost");
// use a pooled connection factory between the module and the queue
PooledConnectionFactory pooledConnectionFactory = new PooledConnectionFactory(connectionFactory);
// how many connections should there be in the session pool?
pooledConnectionFactory.setMaxConnections(100);
pooledConnectionFactory.setMaximumActiveSessionPerConnection(100);
pooledConnectionFactory.setCreateConnectionOnStartup(true);
pooledConnectionFactory.setBlockIfSessionPoolIsFull(false);
JmsConfiguration jmsConfiguration = new JmsConfiguration(pooledConnectionFactory);
jmsConfiguration.setDeliveryPersistent(false);
jmsConfiguration.setTimeToLive(1000*10);
ActiveMQComponent activeMQComponent = ActiveMQComponent.activeMQComponent("vm:localhost");
return activeMQComponent;
}
示例6: createCamelContext
import org.apache.activemq.camel.component.ActiveMQComponent; //导入依赖的package包/类
@Override
protected CamelContext createCamelContext() throws Exception {
SimpleRegistry registry = new SimpleRegistry();
ActiveMQConnectionFactory connectionFactory =
new ActiveMQConnectionFactory();
connectionFactory.setBrokerURL(broker.getTcpConnectorUri());
registry.put("connectionFactory", connectionFactory);
JmsTransactionManager jmsTransactionManager = new JmsTransactionManager();
jmsTransactionManager.setConnectionFactory(connectionFactory);
registry.put("jmsTransactionManager", jmsTransactionManager);
SpringTransactionPolicy policy = new SpringTransactionPolicy();
policy.setTransactionManager(jmsTransactionManager);
policy.setPropagationBehaviorName("PROPAGATION_REQUIRED");
registry.put("PROPAGATION_REQUIRED", policy);
CamelContext camelContext = new DefaultCamelContext(registry);
ActiveMQComponent activeMQComponent = new ActiveMQComponent();
activeMQComponent.setConnectionFactory(connectionFactory);
activeMQComponent.setTransactionManager(jmsTransactionManager);
camelContext.addComponent("jms", activeMQComponent);
return camelContext;
}
示例7: createActiveMQComponent
import org.apache.activemq.camel.component.ActiveMQComponent; //导入依赖的package包/类
@Produces
@Named("activemq")
public ActiveMQComponent createActiveMQComponent() {
ActiveMQComponent activeMQComponent = ActiveMQComponent.activeMQComponent();
activeMQComponent.setConnectionFactory(connectionFactory);
return activeMQComponent;
}
示例8: createActiveMQComponent
import org.apache.activemq.camel.component.ActiveMQComponent; //导入依赖的package包/类
public static ActiveMQComponent createActiveMQComponent() {
// you can set other options but this is the basic just needed
ActiveMQComponent amq = new ActiveMQComponent();
// The ActiveMQ Broker allows anonymous connection by default
// amq.setUserName("admin");
// amq.setPassword("admin");
// the url to the remote ActiveMQ broker
amq.setBrokerURL("tcp://localhost:61616");
return amq;
}
示例9: createCamelContext
import org.apache.activemq.camel.component.ActiveMQComponent; //导入依赖的package包/类
protected CamelContext createCamelContext() throws Exception {
CamelContext camelContext = super.createCamelContext();
ActiveMQComponent activemq =
activeMQComponent("vm://localhost?broker.persistent=false&broker.useJmx=false&jms.redeliveryPolicy.maximumRedeliveries=0"
+ "&jms.redeliveryPolicy.initialRedeliveryDelay=500&jms.useAsyncSend=false&jms.sendTimeout=10000"
+ "&jms.maxReconnectAttempts=1&jms.timeout=3000");
camelContext.addComponent("activemq", activemq);
return camelContext;
}
示例10: addServicesOnStartup
import org.apache.activemq.camel.component.ActiveMQComponent; //导入依赖的package包/类
@Override
protected void addServicesOnStartup(final Map<String, KeyValueHolder<Object, Dictionary>> services) {
final String jmsPort = System.getProperty("fcrepo.dynamic.jms.port", "61616");
final String webPort = System.getProperty("fcrepo.dynamic.test.port", "8080");
final ActiveMQComponent component = new ActiveMQComponent();
component.setBrokerURL("tcp://localhost:" + jmsPort);
component.setExposeAllQueues(true);
final FcrepoComponent fcrepo = new FcrepoComponent();
fcrepo.setBaseUrl("http://localhost:" + webPort + "/fcrepo/rest");
services.put("broker", asService(component, "osgi.jndi.service.name", "fcrepo/Broker"));
services.put("fcrepo", asService(fcrepo, "osgi.jndi.service.name", "fcrepo/Camel"));
}
示例11: addServicesOnStartup
import org.apache.activemq.camel.component.ActiveMQComponent; //导入依赖的package包/类
@Override
protected void addServicesOnStartup(final Map<String, KeyValueHolder<Object, Dictionary>> services) {
final String jmsPort = System.getProperty("fcrepo.dynamic.jms.port", "61616");
final String webPort = System.getProperty("fcrepo.dynamic.test.port", "8080");
final ActiveMQComponent amq = new ActiveMQComponent();
amq.setBrokerURL("tcp://localhost:" + jmsPort);
amq.setExposeAllQueues(true);
final FcrepoComponent fcrepo = new FcrepoComponent();
fcrepo.setBaseUrl("http://localhost:" + webPort + "/fcrepo/rest");
services.put("broker", asService(amq, "osgi.jndi.service.name", "fcrepo/Broker"));
services.put("fcrepo", asService(fcrepo, "osgi.jndi.service.name", "fcrepo/Camel"));
}
示例12: addServicesOnStartup
import org.apache.activemq.camel.component.ActiveMQComponent; //导入依赖的package包/类
@Override
protected void addServicesOnStartup(final Map<String, KeyValueHolder<Object, Dictionary>> services) {
final String jmsPort = System.getProperty("fcrepo.dynamic.jms.port", "61616");
final ActiveMQComponent component = new ActiveMQComponent();
component.setBrokerURL("tcp://localhost:" + jmsPort);
component.setExposeAllQueues(true);
services.put("broker", asService(component, "osgi.jndi.service.name", "fcrepo/Broker"));
}
示例13: jmsComponent
import org.apache.activemq.camel.component.ActiveMQComponent; //导入依赖的package包/类
/**
* Setup JMS component
*/
@Produces
@Named("jms")
public static JmsComponent jmsComponent() {
ActiveMQComponent jms = new ActiveMQComponent();
jms.setBrokerURL("tcp://localhost:61616");
return jms;
}
示例14: activeMq
import org.apache.activemq.camel.component.ActiveMQComponent; //导入依赖的package包/类
@Bean(name = "activeMq")
public ActiveMQComponent activeMq() {
ActiveMQComponent activeMQComponent = new ActiveMQComponent();
activeMQComponent.setUseMessageIDAsCorrelationID(true);
activeMQComponent.setConnectionFactory(activeMqConnectionFactory());
return activeMQComponent;
}
示例15: createCamelContext
import org.apache.activemq.camel.component.ActiveMQComponent; //导入依赖的package包/类
@Override
protected CamelContext createCamelContext() throws Exception {
SimpleRegistry registry = new SimpleRegistry();
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory();
connectionFactory.setBrokerURL(broker.getTcpConnectorUri());
registry.put("connectionFactory", connectionFactory);
CamelContext camelContext = new DefaultCamelContext(registry);
ActiveMQComponent activeMQComponent = new ActiveMQComponent();
activeMQComponent.setConnectionFactory(connectionFactory);
camelContext.addComponent("jms", activeMQComponent);
return camelContext;
}