标签: reactive

无法连接Redis;嵌套异常是 io.lettuce.core.RedisConnectionException 使用 ReactiveRedisTemplate

我是反应式编程的新手。我需要连接到 Redis 来保存和获取一些数据。Redis 实例存在于云中。我使用 Lettuce Connection 工厂来建立连接。

与redis建立连接时,请求失败。这是我的 Redis 配置类:

package com.sap.slh.tax.attributes.determination.springwebfluxdemo.config;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.ReactiveRedisConnectionFactory;
import org.springframework.data.redis.connection.RedisPassword;
import org.springframework.data.redis.connection.RedisStandaloneConfiguration;
import org.springframework.data.redis.connection.lettuce.LettuceClientConfiguration;
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
import org.springframework.data.redis.core.ReactiveRedisOperations;
import org.springframework.data.redis.core.ReactiveRedisTemplate;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.RedisSerializationContext;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import org.springframework.scheduling.annotation.EnableAsync;

import com.sap.slh.tax.attributes.determination.springwebfluxdemo.model.TaxDetails;
import com.sap.slh.tax.attributes.determination.springwebfluxdemo.model.TaxLine;
import com.sap.slh.tax.attributes.determination.springwebfluxdemo.util.JsonUtil;

@Configuration
@EnableAsync
public class RedisConfig {
    private static final Logger log = LoggerFactory.getLogger(RedisConfig.class);

    @Value("${vcap.services.redis.credentials.hostname:10.11.241.101}")
    private String host;

    @Value("${vcap.services.redis.credentials.port:36516}")
    private int port;

    @Value("$vcap.services.redis.credentials.password:123456788")
    private String password;

    @Bean
    public ReactiveRedisConnectionFactory reactiveRedisConnectionFactory() { …
Run Code Online (Sandbox Code Playgroud)

redis lettuce spring-data-redis reactive spring-data-redis-reactive

5
推荐指数
1
解决办法
9万
查看次数

如何在没有Reactive东西的情况下使用Spring Cloud Gateway?

我想使用 Spring Cloud Gateway 创建一个新项目,但我不想要所有反应式功能。对我来说,如果其他微服务阻塞 I/O 而不是响应式的,那就没问题了。

  1. 我怎样才能做到这一点?
  2. 假设我将云网关实现为响应式,而所有其他 MS 实现为阻塞式,这是一个好方法吗?这样做有什么缺点?

spring reactive spring-webflux spring-cloud-gateway

5
推荐指数
1
解决办法
5509
查看次数

从外部库触发时,反应状态不反应

在这里反应初学者。

我的代码

import Head from 'next/head';
import styles from '../styles/Home.module.css';
import { useState, useEffect } from 'react';
import Mousetrap from 'mousetrap';

export default function Home() {
  const [count, setCount] = useState(0);

  const triggerSomething = () => {
    console.log(count);
  };

  useEffect(() => {
    Mousetrap.bind(['ctrl+s', 'command+s'], e => {
      e.preventDefault();
      triggerSomething();
    });

    return () => {
      Mousetrap.unbind(['ctrl+s', 'command+s']);
    };
  }, []);

  return (
    <div className={styles.container}>
      <main className={styles.main}>
        <h1 className={styles.title}>count: {count}</h1>

        <p className={styles.description}>
          <button onClick={() => setCount(count + 1)}>increment</button>
          <br />
          <br /> …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs reactive

5
推荐指数
1
解决办法
938
查看次数

R 点的闪亮重新着色

我想要单击选择点并根据颜色对它们进行分组。

我可以将带有颜色信息的选定点保存到新的数据框中并绘制它,但是我想跟踪并查看交互式绘图上已选择的内容。

如何在“添加选择”后显示/标记已选择的点或使其永久化?

library(shiny)
library(tidyverse)
library(DT)
library(colourpicker)

ui = fluidPage(
    colourInput("col", "Select colour", "purple"),
    actionButton("addToDT", "Add selection", icon = icon("plus")), hr(),
    plotOutput("plot", click = "plot_click", dblclick = "plot_reset"),
    DT::dataTableOutput('plot_DT'), hr(),
    textOutput("clickcoord"),
    DT::dataTableOutput('final_DT'),
    plotOutput("plotSelected")
)

server = function(input, output, session) {
    
    selectedPoint = reactiveVal(rep(FALSE, nrow(mtcars)))
    
    output$clickcoord <- renderPrint({
        print(input$plot_click)
    })
    
    observeEvent(input$plot_click, {
        clicked = nearPoints(mtcars, input$plot_click, allRows = TRUE)$selected_
        selectedPoint(clicked | selectedPoint())
    })
    
    observeEvent(input$plot_reset, {
        selectedPoint(rep(FALSE, nrow(mtcars)))
    })
    
    output$plot_DT = DT::renderDataTable({
        mtcars$sel = selectedPoint()
        mtcars = dplyr::filter(mtcars, sel == TRUE) %>% …
Run Code Online (Sandbox Code Playgroud)

r event-handling ggplot2 shiny reactive

5
推荐指数
1
解决办法
264
查看次数

具有Reactive Extensions的组的缓冲区组,嵌套订阅

我有一个事件源,生成属于某些组的事件.我想缓冲这些组并将组(分批)发送到存储.到目前为止我有这个:

eventSource
    .GroupBy(event => event.GroupingKey)
    .Select(group => new { group.Key, Events = group })
    .Subscribe(group => group.Events
                            .Buffer(TimeSpan.FromSeconds(60), 100)
                            .Subscribe(list => SendToStorage(list)));
Run Code Online (Sandbox Code Playgroud)

所以有一个嵌套订阅组中的事件.不知怎的,我认为有更好的方法,但我还没有弄清楚.

.net c# system.reactive reactive

4
推荐指数
1
解决办法
803
查看次数

Angular2反应形式选择多个属性?

我在我的应用程序中使用以下代码与反应形式.

如果我取消注释该[multiple]行,则选择...选项不会将dformControl表单控件对象设置回状态INVALID.

dformControl.multiple顺便回来false.即使我将注释行更改为[multiple]="false",仍然切换回选择...选项不会将表单控件状态设置为INVALID.

<select class="form-control"
        [id]="dformControl.key"
        [formControlName]="dformControl.key"
        /*[multiple]="dformControl.multiple"*/>

  <option *ngIf="!dformControl.value"
          value="">
    Choose ...
  </option>

  <option *ngFor="let opt of dformControl.options"
          [value]="opt.value"
          [selected]="dformControl.value == opt.value">
    {{opt.label}}
  </option>

</select>
Run Code Online (Sandbox Code Playgroud)

forms select reactive angular

4
推荐指数
1
解决办法
4346
查看次数

是否可以将 MongoDB 用于 Lagom 持久性?

Lagom文档没有提及的MongoDB支持什么,但Lagom似乎有JPA和JDBC支持。

可以休眠OGM作为MongoDB的&Lagom之间的JPA接口?

ReactiveMongo驱动程序是一个很好的候选者,它甚至可以与 Playframework 一起使用。有可能将它与 Lagom 一起使用吗?

有没有其他方法可以实现相同的目标?

hibernate jpa mongodb lagom reactive

4
推荐指数
1
解决办法
913
查看次数

为什么Flowables不是Observables

为什么Flowables不能观察到; 可观察接口几乎是Flowable的一个子集,它们的实现几乎相同.

为什么它们不实现通用接口,所以我们可以直接将Flowable转换为Observable?

rx-java reactive rx-java2

4
推荐指数
2
解决办法
605
查看次数

如何在春季以被动方式提供文件/ PDF文件

我有以下端点代码可提供PDF文件。

@RequestMapping
ResponseEntity<byte[]> getPDF() {
  File file = ...;
  byte[] contents = null;
  try {
    try (FileInputStream fis = new FileInputStream(file)) {
      contents = new byte[(int) file.length()];
      fis.read(contents);
    }
  } catch(Exception e) {
    // error handling
  }
  HttpHeaders headers = new HttpHeaders();
  headers.setContentDispositionFormData(file.getName(), file.getName());
  headeres.setCacheControl("must-revalidate, post-check=0, pre-check=0");
  return new ResponseEntity<>(contents, headers, HttpStatus.OK);
}
Run Code Online (Sandbox Code Playgroud)

我如何才能将上面转换为反应类型Flux/MonoDataBuffer

我有支票,DataBufferUtils但似乎没有提供我需要的东西。我也没有找到任何例子。

java spring-boot reactive spring-webflux

4
推荐指数
1
解决办法
2797
查看次数

WebFlux和Kotlin在没有ReactiveCrud存储库的情况下

我正在开发一个使用Kotlin,Spring Boot,Hibernate(均为最新版本)的项目,我想使其与Spring的WebFlux框架进行交互。

问题是我无法使用,ReactiveCrudRepository因为Web应用程序必须使用Oracle数据库,因此必须使用Hibernate。因此,我想不出一种方法来使用对Oracle SQL数据库的非阻塞访问(仅免费框架)。

我的问题是:

是否可以这样使用:

  • 休闲CrudRepository阻碍
  • 使用corountines并返回所有内容的服务 Mono

服务示例代码:

fun getAllLanguages(): Mono<Collection<ProgrammingLanguage>> = async { repository.findAll() }.asMono()
Run Code Online (Sandbox Code Playgroud)

之后,控制器将具有:

fun listProgrammingLanguagesReactive() = mono(Unconfined) {
    service.also { logger.info { "requesting list of programming languages" } }
            .getAllLanguages()
            .also { logger.info { "responding with list of programming languages" } }
}
Run Code Online (Sandbox Code Playgroud)

这种方法有效,但我不确定它是否始终有效,并且这种做法是否可怕等等。

kotlin reactive spring-webflux kotlinx.coroutines

4
推荐指数
1
解决办法
440
查看次数