本文整理汇总了Java中org.springframework.jms.core.JmsTemplate.setReceiveTimeout方法的典型用法代码示例。如果您正苦于以下问题:Java JmsTemplate.setReceiveTimeout方法的具体用法?Java JmsTemplate.setReceiveTimeout怎么用?Java JmsTemplate.setReceiveTimeout使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.jms.core.JmsTemplate
的用法示例。
在下文中一共展示了JmsTemplate.setReceiveTimeout方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildTargetResource
import org.springframework.jms.core.JmsTemplate; //导入方法依赖的package包/类
/**
* This method essentially performs initialization of this Processor by
* obtaining an instance of the {@link ConnectionFactory} from the
* {@link JMSConnectionFactoryProvider} (ControllerService) and performing a
* series of {@link ConnectionFactory} adaptations which eventually results
* in an instance of the {@link CachingConnectionFactory} used to construct
* {@link JmsTemplate} used by this Processor.
*/
private void buildTargetResource(ProcessContext context) {
if (this.targetResource == null) {
JMSConnectionFactoryProviderDefinition cfProvider = context.getProperty(CF_SERVICE).asControllerService(JMSConnectionFactoryProviderDefinition.class);
ConnectionFactory connectionFactory = cfProvider.getConnectionFactory();
UserCredentialsConnectionFactoryAdapter cfCredentialsAdapter = new UserCredentialsConnectionFactoryAdapter();
cfCredentialsAdapter.setTargetConnectionFactory(connectionFactory);
cfCredentialsAdapter.setUsername(context.getProperty(USER).getValue());
cfCredentialsAdapter.setPassword(context.getProperty(PASSWORD).getValue());
this.cachingConnectionFactory = new CachingConnectionFactory(cfCredentialsAdapter);
this.cachingConnectionFactory.setSessionCacheSize(Integer.parseInt(context.getProperty(SESSION_CACHE_SIZE).getValue()));
JmsTemplate jmsTemplate = new JmsTemplate();
jmsTemplate.setConnectionFactory(this.cachingConnectionFactory);
jmsTemplate.setPubSubDomain(TOPIC.equals(context.getProperty(DESTINATION_TYPE).getValue()));
// set of properties that may be good candidates for exposure via configuration
jmsTemplate.setReceiveTimeout(1000);
this.targetResource = this.finishBuildingTargetResource(jmsTemplate, context);
}
}
示例2: testSpringLocalTx
import org.springframework.jms.core.JmsTemplate; //导入方法依赖的package包/类
@Test
public void testSpringLocalTx() throws Exception {
ConnectionFactory cf = createCF(BROKER_URL);
JmsTemplate jms = new JmsTemplate(cf);
jms.setDefaultDestinationName(QUEUE);
jms.setReceiveTimeout(1000);
PlatformTransactionManager tm = new JmsTransactionManager(cf);
TransactionTemplate localTx = new TransactionTemplate(tm);
localTx.execute(ts -> {
jms.convertAndSend("Hello");
return null;
});
Object msg = localTx.execute(ts -> jms.receiveAndConvert());
assertEquals("Hello", msg);
localTx.execute(ts -> {
jms.convertAndSend("Hello");
ts.setRollbackOnly();
return null;
});
msg = localTx.execute(ts -> jms.receiveAndConvert());
assertNull(msg);
}
示例3: getJmsTemplate
import org.springframework.jms.core.JmsTemplate; //导入方法依赖的package包/类
public JmsTemplate getJmsTemplate() {
JmsTemplate jmsTemplate = new JmsTemplate();
jmsTemplate.setConnectionFactory(mqConnectionFactory.getFactory());
jmsTemplate.setDefaultDestination(new ActiveMQQueue(queueName));
jmsTemplate.setReceiveTimeout(600);
jmsTemplate.setMessageConverter(messageConverter);
return jmsTemplate;
}
示例4: testSpring
import org.springframework.jms.core.JmsTemplate; //导入方法依赖的package包/类
@Test
public void testSpring() throws Exception {
ConnectionFactory cf = createCF(BROKER_URL);
JmsTemplate jms = new JmsTemplate(cf);
jms.setDefaultDestinationName(QUEUE);
jms.setReceiveTimeout(100);
jms.convertAndSend("Hello");
Object msg = jms.receiveAndConvert();
assertEquals("Hello", msg);
}
示例5: createSpringJmsOperation
import org.springframework.jms.core.JmsTemplate; //导入方法依赖的package包/类
private JmsOperations createSpringJmsOperation() {
final JmsTemplate jmsTemplate = new JmsTemplate(embeddedJmsRule.connectionFactory());
jmsTemplate.setDefaultDestinationName(getClass().getSimpleName());
jmsTemplate.setReceiveTimeout(TimeUnit.SECONDS.toMillis(10L));
jmsTemplate.afterPropertiesSet();
return jmsTemplate;
}