在 JPOS 中放置自定义逻辑的正确位置是什么?

What is the right place to put custom logic in JPOS?

我在一个项目中工作,其中 请求(ISO 8583) 需要通过 JPOS 服务器 发送到支持的(远程根据官方文档托管)通过 SOAP api.

我们的系统实现如下:

我们在中间件(spring 引导项目)中实现了 ISOListner,它将 传入的 ISO 消息 转换为 SOAP 请求。

是否可以将中间件代码嵌入到 JPOS 服务器本身并省略 mw?

如果可能的话,放置转换逻辑的正确位置是什么? 是 ChannelAdaptor 还是 TransactionManager

很少有博客建议我们可以将所有逻辑放在TransactionManager 或ChannelAdaptor 中。如果是真的 那么为什么我们需要多路复用器和通道?或者我们的架构可以进一步进行?

为了完整起见,我将包括在 jPOS 用户组 (https://groups.google.com/forum/#!topic/jpos-users/PGzb4syQRzs) 中也提出的这个问题的答案:

We usually implement a custom participant doing the SOAP/REST thing.

In the case of REST, we use Apache's HTTP Client (org.apache.httpcomponents:httpclient:4.5.5) that provides a nice async interface that works great with the TransactionManager's PAUSE.

Here is an example:

public int prepare (long id, Serializable o) {
        Context ctx = (Context) o;
        String url = getURL (ctx);
        HttpPost post = new HttpPost(url);
        StringEntity entity = new StringEntity(ctx.getString(JSON_REQUEST.name()),ContentType.create("application/json", Consts.UTF_8));
        post.setEntity(entity);

        try {
            client.execute(post, response -> {
                int sc = response.getStatusLine().getStatusCode();
                if (sc == HttpStatus.SC_CREATED || sc == HttpStatus.SC_OK)
                    ctx.put (JSON_RESPONSE.name(), EntityUtils.toString(response.getEntity()));
                ctx.resume();
                return null;
            });
            return PREPARED | PAUSE | NO_JOIN | READONLY;
        } catch (IOException e) {
            warn (e);
        }
        return ABORTED;
    }

TransactionManager 是添加自定义逻辑的正确位置。我猜您正在使用 mux 和 channel 将 iso 消息发送到 MW 套接字侦听器组件。这可以通过使用像 rabbitmq 这样的中间件连接到后端服务器来避免。

例如事务管理器中的 isomesage 可以转换为 json 并使用 mq 将其发送到后端服务器。