简体   繁体   English

MicroProfile LRA - 如何在 WildFly JEE 应用程序上定义自定义参与者 URI?

[英]MicroProfile LRA - How to define custom participant URI on a WildFly JEE application?

When MicroProfile LRA coordinator and participants run on different Docker containers, it is needed to define a custom URI for each participant.当 MicroProfile LRA 协调器和参与者运行在不同的 Docker 容器上时,需要为每个参与者定义一个自定义的 URI。

Otherwise the LRA coordinator tries to call participant compensate/complete APIs by referring them with "localhost" based URI.否则,LRA 协调器会尝试通过使用基于“本地主机”的 URI 引用参与者来调用参与者补偿/完成 API。

Is it possible, on WildFly environment, to define a custom URI for a participant?是否可以在 WildFly 环境中为参与者定义自定义 URI? And ingeneral is it possible to define a how participants can register with any LRA?一般来说,是否可以定义参与者如何在任何 LRA 注册?

By default, the participant endpoints are derived from the caller information provided in the JAX-RS UriInfo class. This class contains the base URI of the caller of the participant.默认情况下,参与者端点派生自 JAX-RS UriInfo class 中提供的调用者信息。此 class 包含参与者调用者的基本 URI。 The idea is that coordinator should be able to call the participant on the same URI as the original request to the participant came in.这个想法是协调器应该能够在与参与者的原始请求相同的 URI 上调用参与者。

I've created a simple docker image https://hub.docker.com/repository/docker/xstefank/uriinfo-wildfly which will on path /uriinfo/ping return the the base URI that will be used for participant URLs.我创建了一个简单的 docker 图像https://hub.docker.com/repository/docker/xstefank/uriinfo-wildfly ,它将在路径/uriinfo/ping上返回将用于参与者 URL 的基本 URI。

Calling this locally gives you - Base URI is http://localhost:8080/uriinfo/ which is expected called from the local machine.在本地调用它会给你 - Base URI is http://localhost:8080/uriinfo/预计从本地机器调用。 Deploying this image to OpenShift/Kube.netes and exposing a route for this application gives you Base URI is http://uriinfo-wildfly-testing.6923.rh-us-east-1.openshiftapps.com/uriinfo/ .将此映像部署到 OpenShift/Kube.netes 并公开此应用程序的路由后,您的Base URI is http://uriinfo-wildfly-testing.6923.rh-us-east-1.openshiftapps.com/uriinfo/ And finally, calling it from a different pod deployed in the same project gives you Base URI is http://uriinfo-wildfly:8080/uriinfo/ which corresponds to the actual calls:最后,从部署在同一个项目中的不同 pod 调用它会得到Base URI is http://uriinfo-wildfly:8080/uriinfo/这对应于实际调用:

$ curl localhost:8080/uriinfo/ping
Base URI is http://localhost:8080/uriinfo/

$ curl http://uriinfo-wildfly-testing.6923.rh-us-east-1.openshiftapps.com/uriinfo/ping
Base URI is http://uriinfo-wildfly-testing.6923.rh-us-east-1.openshiftapps.com/uriinfo/

# called from different pod in the same openshift project
$ curl http://uriinfo-wildfly:8080/uriinfo/ping
Base URI is http://uriinfo-wildfly:8080/uriinfo/

Another option is to manually register the URLs you require through NarayanaLRAClient#joinLRA methods which either take individual URLs for different LRA endpoints or a base URI that will derive the URLs as mentioned above .另一种选择是通过NarayanaLRAClient#joinLRA方法手动注册您需要的 URL,该方法采用不同 LRA 端点的单独 URL将派生上述 URL 的基本 URI

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM