本文整理匯總了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());
}
}
示例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);
}
}
示例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());
}
}
示例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);
}
示例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());
}
}
示例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;
}
示例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;
}