I have two services that use JPOS in spring boot and first of them sends a message and the second one receives it, saves the communication channel with the first service and sends a response. Here is the code:
@Slf4j
@Service
public class HandleMsg implements ISORequestListener {
private static ISOSource clientConnection;
@Override
public boolean process(ISOSource source, ISOMsg m) {
clientConnection = source;
try {
if ("0800".equals(m.getMTI())) {
ISOMsg r = (ISOMsg) m.clone();
r.setResponseMTI();
r.set(33, "Good Message");
source.send(r);
return true;
}
} catch (ISOException | IOException e) {
log.error(e.getMessage());
}
return false;
}
public void sendMessageToService(String message) {
try {
if (Objects.isNull(clientConnection) || !clientConnection.isConnected()) {
log.error("Client connection is null!");
return;
}
ISOMsg serverPush = new ISOMsg();
serverPush.setMTI("0210");
serverPush.set(33, message);
clientConnection.send(serverPush);
} catch (IOException | ISOException e) {
throw new RuntimeException(e);
}
}
and its .xml config for JPOS:
<server class=".jpos.q2.iso.QServer" logger="Q2" name="simulator_10000">
<attr name="port" type="java.lang.Integer">10000</attr>
<channel class=".jpos.iso.channel.XMLChannel" logger="Q2" packager=".jpos.iso.packager.XMLPackager"/>
<request-listener class="com.example.jpos.services.HandleMsg" logger="Q2"/>
<in>network-out</in>
<out>network-in</out>
</server>
As you can see, at the time of receipt, I keep the connection channel of the message source, and later I can call the class method anywhere and if the channel is still active, then send a message to the second service using it. But this approach creates problems, since in order for the second service to be able to send a message to the second, the first must first send to the second service.
My question sounds like this: At the moment when the first service connects and creates a communication channel with the first service, a message about this appears in the logs of the first service:
<log realm="simulator_10000.server.session/127.0.0.1:622222" at="2025-03-28T16:26:18.439899700">
<session-start/>
</log>
and first services .xml config for JPOS to create connection channel:
<channel-adaptor name='clientsimulator-adaptor'
class=".jpos.q2.iso.ChannelAdaptor" logger="Q2">
<channel class=".jpos.iso.channel.XMLChannel" logger="Q2"
packager=".jpos.iso.packager.XMLPackager">
<property name="host" value="${client.host}" />
<property name="port" value="${client.port}" />
<property name="keep-alive" value="${client.keep_alive}" />
</channel>
<in>my-send</in>
<out>my-receive</out>
<reconnect-delay>${client.reconnect_delay}</reconnect-delay>
</channel-adaptor>
That is, he understands that he is already connected. I need him to save the data of this channel to ISOSource so that the server(the second service) I could send messages to the first service without receiving a message from it.
I have two services that use JPOS in spring boot and first of them sends a message and the second one receives it, saves the communication channel with the first service and sends a response. Here is the code:
@Slf4j
@Service
public class HandleMsg implements ISORequestListener {
private static ISOSource clientConnection;
@Override
public boolean process(ISOSource source, ISOMsg m) {
clientConnection = source;
try {
if ("0800".equals(m.getMTI())) {
ISOMsg r = (ISOMsg) m.clone();
r.setResponseMTI();
r.set(33, "Good Message");
source.send(r);
return true;
}
} catch (ISOException | IOException e) {
log.error(e.getMessage());
}
return false;
}
public void sendMessageToService(String message) {
try {
if (Objects.isNull(clientConnection) || !clientConnection.isConnected()) {
log.error("Client connection is null!");
return;
}
ISOMsg serverPush = new ISOMsg();
serverPush.setMTI("0210");
serverPush.set(33, message);
clientConnection.send(serverPush);
} catch (IOException | ISOException e) {
throw new RuntimeException(e);
}
}
and its .xml config for JPOS:
<server class=".jpos.q2.iso.QServer" logger="Q2" name="simulator_10000">
<attr name="port" type="java.lang.Integer">10000</attr>
<channel class=".jpos.iso.channel.XMLChannel" logger="Q2" packager=".jpos.iso.packager.XMLPackager"/>
<request-listener class="com.example.jpos.services.HandleMsg" logger="Q2"/>
<in>network-out</in>
<out>network-in</out>
</server>
As you can see, at the time of receipt, I keep the connection channel of the message source, and later I can call the class method anywhere and if the channel is still active, then send a message to the second service using it. But this approach creates problems, since in order for the second service to be able to send a message to the second, the first must first send to the second service.
My question sounds like this: At the moment when the first service connects and creates a communication channel with the first service, a message about this appears in the logs of the first service:
<log realm="simulator_10000.server.session/127.0.0.1:622222" at="2025-03-28T16:26:18.439899700">
<session-start/>
</log>
and first services .xml config for JPOS to create connection channel:
<channel-adaptor name='clientsimulator-adaptor'
class=".jpos.q2.iso.ChannelAdaptor" logger="Q2">
<channel class=".jpos.iso.channel.XMLChannel" logger="Q2"
packager=".jpos.iso.packager.XMLPackager">
<property name="host" value="${client.host}" />
<property name="port" value="${client.port}" />
<property name="keep-alive" value="${client.keep_alive}" />
</channel>
<in>my-send</in>
<out>my-receive</out>
<reconnect-delay>${client.reconnect_delay}</reconnect-delay>
</channel-adaptor>
That is, he understands that he is already connected. I need him to save the data of this channel to ISOSource so that the server(the second service) I could send messages to the first service without receiving a message from it.
Share Improve this question asked Mar 28 at 11:42 shaxa 2000shaxa 2000 275 bronze badges1 Answer
Reset to default 1You can use ISOServer
's lastConnectedISOChannel
to get a hold of the ISOChannel
. However, you need to ensure that the party connecting to the ISOServer
is ready to receive messages and that the connection is not bogus—such as those generated by penetration testing attempts.