当前位置: 首页>>代码示例>>Java>>正文


Java JmsTemplate.setConnectionFactory方法代码示例

本文整理汇总了Java中org.springframework.jms.core.JmsTemplate.setConnectionFactory方法的典型用法代码示例。如果您正苦于以下问题:Java JmsTemplate.setConnectionFactory方法的具体用法?Java JmsTemplate.setConnectionFactory怎么用?Java JmsTemplate.setConnectionFactory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.jms.core.JmsTemplate的用法示例。


在下文中一共展示了JmsTemplate.setConnectionFactory方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: execute

import org.springframework.jms.core.JmsTemplate; //导入方法依赖的package包/类
public void execute(UserRepo userRepo) {
    Map<String, Object> map = new HashMap<String, Object>();
    map.put("id", Long.toString(userRepo.getId()));
    map.put("code", userRepo.getCode());
    map.put("name", userRepo.getName());

    JmsTemplate jmsTemplate = new JmsTemplate();
    jmsTemplate.setConnectionFactory(connectionFactory);
    jmsTemplate.setPubSubDomain(true);

    try {
        jmsTemplate.convertAndSend(destinationName, jsonMapper.toJson(map));
    } catch (IOException ex) {
        logger.error(ex.getMessage());
    }
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:17,代码来源:UserRepoPublisher.java

示例2: 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

示例3: sendNotification

import org.springframework.jms.core.JmsTemplate; //导入方法依赖的package包/类
public void sendNotification(String destinationName, Object object) {
    JmsTemplate jmsTemplate = new JmsTemplate();
    jmsTemplate.setConnectionFactory(connectionFactory);
    jmsTemplate.setPubSubDomain(true);

    try {
        jmsTemplate.convertAndSend(destinationName,
                jsonMapper.toJson(object));
    } catch (IOException ex) {
        logger.error(ex.getMessage());
    }
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:13,代码来源:UserPublisher.java

示例4: afterPropertiesSet

import org.springframework.jms.core.JmsTemplate; //导入方法依赖的package包/类
@PostConstruct
public void afterPropertiesSet() {
    Assert.notNull(connectionFactory);
    jmsTemplate = new JmsTemplate();
    jmsTemplate.setConnectionFactory(connectionFactory);
    jmsTemplate.setPubSubDomain(true);
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:8,代码来源:ResourcePublisherImpl.java

示例5: sendSynchronization

import org.springframework.jms.core.JmsTemplate; //导入方法依赖的package包/类
public void sendSynchronization(String destinationName, Object object) {
    JmsTemplate jmsTemplate = new JmsTemplate();
    jmsTemplate.setConnectionFactory(connectionFactory);
    jmsTemplate.setPubSubDomain(false);

    try {
        jmsTemplate.convertAndSend(destinationName,
                jsonMapper.toJson(object));
    } catch (IOException ex) {
        logger.error(ex.getMessage());
    }
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:13,代码来源:UserPublisher.java

示例6: 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

示例7: jmsTemplate

import org.springframework.jms.core.JmsTemplate; //导入方法依赖的package包/类
@Bean
JmsTemplate jmsTemplate() {
    ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://localhost:61616");
    JmsTemplate template = new JmsTemplate();
    template.setConnectionFactory(connectionFactory);
    return template;
}
 
开发者ID:kslisenko,项目名称:java-performance,代码行数:8,代码来源:App1Main.java


注:本文中的org.springframework.jms.core.JmsTemplate.setConnectionFactory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。