當前位置: 首頁>>代碼示例>>Java>>正文


Java JmsTemplate.setReceiveTimeout方法代碼示例

本文整理匯總了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);
    }
}
 
開發者ID:lsac,項目名稱:nifi-jms-jndi,代碼行數:32,代碼來源:AbstractJMSProcessor.java

示例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);
}
 
開發者ID:ops4j,項目名稱:org.ops4j.pax.transx,代碼行數:25,代碼來源:ActiveMQTest.java

示例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;
}
 
開發者ID:phpdragon,項目名稱:JavaSamples,代碼行數:11,代碼來源:MqProducer.java

示例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);
}
 
開發者ID:ops4j,項目名稱:org.ops4j.pax.transx,代碼行數:12,代碼來源:ActiveMQTest.java

示例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;
}
 
開發者ID:zapodot,項目名稱:embedded-jms-junit,代碼行數:8,代碼來源:EmbeddedJmsRuleSpringJmsTest.java


注:本文中的org.springframework.jms.core.JmsTemplate.setReceiveTimeout方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。