ISO 8583消息的虚拟后端

时间:2014-08-13 12:20:13

标签: iso iso8583

我想为ISO 8583消息创建虚拟后端。这个问题的必要条件是“针对此后端运行jPos /其他ATM测试套件”。

1 个答案:

答案 0 :(得分:1)

您可以尝试简单的jReactive-iso8583 server

查看client-server integration test

用法示例:

Spring config:

@Configuration
public class Iso8583ServerConfig {

    @Value("${iso8583.connection.port}")
    int port;

    @Bean
    public org.jreactive.iso8583.server.Iso8583Server iso8583Server() throws IOException {
        return new org.jreactive.iso8583.server.Iso8583Server(port, serverMessageFactory());
    }

    @Bean
    MessageFactory serverMessageFactory() throws IOException {
        MessageFactory messageFactory = ConfigParser.createDefault();
        messageFactory.setCharacterEncoding(StandardCharsets.US_ASCII.name());
        messageFactory.setUseBinaryMessages(false);
        messageFactory.setAssignDate(true);
        return messageFactory;
    }

}

在某处添加自定义消息侦听器:

server.addMessageListener(new IsoMessageListener() {

        @Override
        public boolean applies(IsoMessage isoMessage) {
            return isoMessage.getType() ==  0x200;
        }

        @Override
        public boolean onMessage(ChannelHandlerContext ctx, IsoMessage isoMessage) {
            capturedRequest = isoMessage;
            final IsoMessage response = server.getIsoMessageFactory().createResponse(isoMessage);
            response.setField(39, IsoType.ALPHA.value("00", 2));
            response.setField(60, IsoType.LLLVAR.value("XXX", 3));
            ctx.writeAndFlush(response);
            return false;
        }
    });

然后运行服务器:

 server.init();
 server.start();

关机服务器:

 server.shutdown();