-
-
Notifications
You must be signed in to change notification settings - Fork 147
FAQ
Konstantin Pavlov edited this page Jan 22, 2022
·
3 revisions
-
Create a
MessageFactory
. It is responsible for instantiating new j8583 messages.MessageFactory<IsoMessage> messageFactory = ConfigParser.createDefault(); messageFactory.setCharacterEncoding(StandardCharsets.US_ASCII.name()); messageFactory.setUseBinaryMessages(false); messageFactory.setAssignDate(true);
-
Create a
Iso8583Server
instance:Iso8583Server server = new Iso8583Server<>(port, messageFactory);
-
Server is asynchronous by nature. To handle client messages, you should create and register a message listener which will do the job:
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;
}
});
```
In general, you can send a message to client via Netty's [`ChannelHandlerContext`](http://netty.io/4.1/api/io/netty/channel/ChannelHandlerContext.html).
- Initialize and start the server:
server.init(); server.start();
Q: I'm trying to implement a echo message rate of 120 seconds, but it seems that the connection breaks or is lost when the idleTimeout is set above 30 seconds.
Try setting idleTimeout parameter in the configuration to something less than 30 sec and make sure that echo message listener is enabled.