本文整理了Java中org.springframework.data.redis.core.RedisTemplate.convertAndSend
方法的一些代码示例,展示了RedisTemplate.convertAndSend
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RedisTemplate.convertAndSend
方法的具体详情如下:
包路径:org.springframework.data.redis.core.RedisTemplate
类名称:RedisTemplate
方法名:convertAndSend
暂无
代码示例来源:origin: spring-projects/spring-integration
@Override
protected boolean doSend(Message<?> message, long arg1) {
Object value = this.messageConverter.fromMessage(message, Object.class);
this.redisTemplate.convertAndSend(this.topicName, value); // NOSONAR - null can be sent
return true;
}
代码示例来源:origin: spring-projects/spring-integration
@Override
@SuppressWarnings("unchecked")
protected void handleMessageInternal(Message<?> message) {
String topic = this.topicExpression.getValue(this.evaluationContext, message, String.class);
Object value = this.messageConverter.fromMessage(message, Object.class);
// TODO: 5.2 assert both not null
if (value instanceof byte[]) {
this.template.convertAndSend(topic, value); // NOSONAR
}
else {
this.template.convertAndSend(topic, ((RedisSerializer<Object>) this.serializer).serialize(value)); // NOSONAR
}
}
代码示例来源:origin: spring-projects/spring-integration
protected void awaitFullySubscribed(RedisMessageListenerContainer container, RedisTemplate<?, ?> redisTemplate,
String redisChannelName, QueueChannel channel, Object message) throws Exception {
awaitContainerSubscribedNoWait(container);
drain(channel);
long now = System.currentTimeMillis();
Message<?> received = null;
while (received == null && System.currentTimeMillis() - now < 30000) {
redisTemplate.convertAndSend(redisChannelName, message);
received = channel.receive(1000);
}
drain(channel);
assertNotNull("Container failed to fully start", received);
}
代码示例来源:origin: org.springframework.integration/spring-integration-redis
@Override
protected boolean doSend(Message<?> message, long arg1) {
Object value = this.messageConverter.fromMessage(message, Object.class);
this.redisTemplate.convertAndSend(this.topicName, value); // NOSONAR - null can be sent
return true;
}
代码示例来源:origin: sentilo/sentilo
public void publishPing() {
redisTemplate.convertAndSend(monitorTopic.getTopic(), "PING SUBSCRIPTION");
lock.lock();
try {
countPendingEvents++;
} finally {
lock.unlock();
}
}
代码示例来源:origin: org.springframework.integration/spring-integration-redis
@Override
@SuppressWarnings("unchecked")
protected void handleMessageInternal(Message<?> message) {
String topic = this.topicExpression.getValue(this.evaluationContext, message, String.class);
Object value = this.messageConverter.fromMessage(message, Object.class);
// TODO: 5.2 assert both not null
if (value instanceof byte[]) {
this.template.convertAndSend(topic, value); // NOSONAR
}
else {
this.template.convertAndSend(topic, ((RedisSerializer<Object>) this.serializer).serialize(value)); // NOSONAR
}
}
代码示例来源:origin: xiaolyuh/layering-cache
/**
* 发布消息到频道(Channel)
*
* @param redisTemplate redis客户端
* @param channelTopic 发布预订阅的频道
* @param message 消息内容
*/
public static void publisher(RedisTemplate<String, Object> redisTemplate, ChannelTopic channelTopic, Object message) {
redisTemplate.convertAndSend(channelTopic.toString(), message);
logger.debug("redis消息发布者向频道【{}】发布了【{}】消息", channelTopic.toString(), message.toString());
}
}
代码示例来源:origin: spring-projects/spring-integration
template.convertAndSend(redisChannelName, message.getBytes());
代码示例来源:origin: com.github.xiaolyuh/layering-cache-core
/**
* 发布消息到频道(Channel)
*
* @param redisTemplate redis客户端
* @param channelTopic 发布预订阅的频道
* @param message 消息内容
*/
public static void publisher(RedisTemplate<String, Object> redisTemplate, ChannelTopic channelTopic, Object message) {
redisTemplate.convertAndSend(channelTopic.toString(), message);
logger.debug("redis消息发布者向频道【{}】发布了【{}】消息", channelTopic.toString(), message.toString());
}
}
代码示例来源:origin: choerodon/choerodon-starters
public void sendToChannel(Set<String> channels, Msg msg){
String realChannel;
for (String channel : channels){
realChannel = msg.getMsgType() == Msg.PIPE || msg.getMsgType() == Msg.PIPE_EXEC? "log"+channel:channel;
redisTemplate.convertAndSend(realChannel,msg);
}
}
}
代码示例来源:origin: alibaba/tac
@Override
public Boolean offline(TacInst tacInst) {
String msCode = tacInst.getMsCode();
// 1. update data
TacMsPublishMeta publishMeta = new TacMsPublishMeta(tacInst, TacMsConstants.INST_STATUS_OFFLINE);
hashOperations.put(getMainKey(), msCode, publishMeta);
// 2. send message
redisTopicTemplate.convertAndSend(getPublishChannel(), JSONObject.toJSONString(publishMeta));
return true;
}
代码示例来源:origin: com.alibaba/tac-engine
@Override
public Boolean offline(TacInst tacInst) {
String msCode = tacInst.getMsCode();
// 1. update data
TacMsPublishMeta publishMeta = new TacMsPublishMeta(tacInst, TacMsConstants.INST_STATUS_OFFLINE);
hashOperations.put(getMainKey(), msCode, publishMeta);
// 2. send message
redisTopicTemplate.convertAndSend(getPublishChannel(), JSONObject.toJSONString(publishMeta));
return true;
}
代码示例来源:origin: alibaba/tac
@Override
public Boolean publish(TacInst tacInst, byte[] data) {
byte[] instanceFile = data;
tacInst.setJarVersion(TacFileService.getMd5(data));
tacInst.setStatus(TacInst.STATUS_PUBLISH);
// 1 save data
redisMsInstFileService.saveInstanceFile(tacInst, instanceFile);
// 2. save meta data
String msCode = tacInst.getMsCode();
TacMsPublishMeta publishMeta = new TacMsPublishMeta(tacInst);
hashOperations.put(getMainKey(), msCode, publishMeta);
// 3. send message
redisTopicTemplate.convertAndSend(getPublishChannel(), JSONObject.toJSONString(publishMeta));
TacMsDO ms = msService.getMs(tacInst.getMsCode());
// 4 update ms
Long oldPublishId = ms.getPublishedInstId();
ms.setPublishedInstId(tacInst.getId());
msService.updateMs(tacInst.getMsCode(), ms);
// 5 update instance
msInstService.updateTacMsInst(tacInst.getId(), tacInst);
if (oldPublishId != null && !oldPublishId.equals(tacInst.getId())) {
TacInst tacMsInst = msInstService.getTacMsInst(oldPublishId);
if (tacMsInst != null) {
tacMsInst.setStatus(TacInst.STATUS_PRE_PUBLISH);
msInstService.updateTacMsInst(oldPublishId, tacMsInst);
}
}
return true;
}
代码示例来源:origin: com.alibaba/tac-engine
@Override
public Boolean publish(TacInst tacInst, byte[] data) {
byte[] instanceFile = data;
tacInst.setJarVersion(TacFileService.getMd5(data));
tacInst.setStatus(TacInst.STATUS_PUBLISH);
// 1 save data
redisMsInstFileService.saveInstanceFile(tacInst, instanceFile);
// 2. save meta data
String msCode = tacInst.getMsCode();
TacMsPublishMeta publishMeta = new TacMsPublishMeta(tacInst);
hashOperations.put(getMainKey(), msCode, publishMeta);
// 3. send message
redisTopicTemplate.convertAndSend(getPublishChannel(), JSONObject.toJSONString(publishMeta));
TacMsDO ms = msService.getMs(tacInst.getMsCode());
// 4 update ms
Long oldPublishId = ms.getPublishedInstId();
ms.setPublishedInstId(tacInst.getId());
msService.updateMs(tacInst.getMsCode(), ms);
// 5 update instance
msInstService.updateTacMsInst(tacInst.getId(), tacInst);
if (oldPublishId != null && !oldPublishId.equals(tacInst.getId())) {
TacInst tacMsInst = msInstService.getTacMsInst(oldPublishId);
if (tacMsInst != null) {
tacMsInst.setStatus(TacInst.STATUS_PRE_PUBLISH);
msInstService.updateTacMsInst(oldPublishId, tacMsInst);
}
}
return true;
}
代码示例来源:origin: mploed/ddd-strategic-design-spring-boot
@PayloadRoot(namespace = NAMESPACE_URI, localPart = "saveCustomerRequest")
@ResponsePayload
public SaveCustomerResponse saveCustoemr(@RequestPayload SaveCustomerRequest request) {
SaveCustomerResponse response = new SaveCustomerResponse();
Customer customer = request.getCustomer();
Kunde kunde = new Kunde();
kunde.setNachname(customer.getLastName());
kunde.setVorname(customer.getFirstName());
kunde.setStrasse(customer.getStreet());
kunde.setPlz(customer.getPostCode());
kunde.setStadt(customer.getCity());
Kunde savedKunde = kundeRepository.saveAndFlush(kunde);
redisTemplate.convertAndSend("customer-created-events", new CustomerCreatedEvent(savedKunde));
customer.setId(savedKunde.getId());
response.setCustomer(customer);
return response;
}
}
内容来源于网络,如有侵权,请联系作者删除!