我是 spring webflux 的初学者。在研究时我发现了一些代码,例如:
Mono result = someMethodThatReturnMono().cache();
Run Code Online (Sandbox Code Playgroud)
“缓存”这个名字告诉我关于缓存某些东西,但是缓存在哪里以及如何检索缓存的东西?是咖啡因之类的东西吗?
caching reactive-programming project-reactor spring-webflux webflux
我正在对 pdf 文件进行签名,但我有些担心。从 pdfbox 示例中,我看到了两种签署 pdf 的方法。第一个是:
document.saveIncremental(output);
Run Code Online (Sandbox Code Playgroud)
第二种方式:
ExternalSigningSupport externalSigning = doc.saveIncrementalForExternalSigning(fos);
// invoke external signature service
byte[] cmsSignature = sign(externalSigning.getContent());
if (isLateExternalSigning()) {
// this saves the file with a 0 signature
externalSigning.setSignature(new byte[0]);
// remember the offset (add 1 because of "<")
int offset = signature.getByteRange()[1] + 1;
// now write the signature at the correct offset without any PDFBox methods
RandomAccessFile raf = new RandomAccessFile(signedFile, "rw");
raf.seek(offset);
raf.write(Hex.getBytes(cmsSignature));
raf.close();
} else {
// set signature bytes …Run Code Online (Sandbox Code Playgroud) 我是 Spring WebFlux 反应式新手。我使用 R2DBC postgresql。我有一个这样的存储库:
public interface BookRepository extends ReactiveCrudRepository<Book, Long> {
}
Run Code Online (Sandbox Code Playgroud)
现在我想添加自定义方法来通过许多复杂的条件进行查询:
public interface CustomBookRepository extends BookRepository {
Flux<Book> findByVeryComplicatedCondition(MyCriteriaDto criteria);
}
Run Code Online (Sandbox Code Playgroud)
我的实现:
public class CustomBookRepositoryImpl extends CustomBookRepository {
//How to get it?
EntityManager em;
@Override
public Flux<Book> findByVeryComplicatedCondition(MyCriteriaDto criteria) {
Query query = em.createQuery("SELECT b from Book b WHERE (VERY COMPLICATED CONDITIONS)");
//What next?
}
}
Run Code Online (Sandbox Code Playgroud)
我的问题在上面的代码中:
当我问这些问题时,我的意思是“如何使用 Spring React/r2dbc 方式做到这一点”,而不是“如何使用 JDBC 做到这一点”
不久,我使用GOOGLE COMPUTE ENGINE(外部IP:34.73.89.55,所有端口和协议都打开),然后我安装Docker,minikube,kubectl。然后:
minikube start --driver=docker
minikube tunnel
kubectl create deployment hello-minikube1 --image=k8s.gcr.io/echoserver:1.4
kubectl expose deployment hello-minikube1 --type=LoadBalancer --port=8080
kubectl get svc
Run Code Online (Sandbox Code Playgroud)
我得到:
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
hello-minikube1 LoadBalancer 10.110.130.109 10.110.130.109 8080:31993/TCP 9m22s
Run Code Online (Sandbox Code Playgroud)
我的问题是,为什么 EXTERNAL-IP 与主机的外部 IP:34.73.89.55 不匹配?如何通过主机的外部IP远程访问此服务(例如:我在家并通过浏览器访问)?
Ps:我想使用GOOGLE COMPUTE ENGINE。
编辑:我也尝试:
sudo minikube start --driver=none
sudo kubectl create deployment hello-minikube1 --image=k8s.gcr.io/echoserver:1.4
sudo kubectl expose deployment hello-minikube1 --type=NodePort --port=8080
wget 127.0.0.1:8080
Run Code Online (Sandbox Code Playgroud)
=>不工作
如果我们提供相同的数据源,所有这些方法都会产生相同的结果。那么它们之间有什么区别呢?
java reactive-programming project-reactor reactive-streams spring-webflux