Problem with sending iso message using ChannelAdaptor & QMUX - java

I am using a channel adaptor and qmux to send iso8583 message to a socket server.
I write 2 maven project Jpos client & server in netbeans.
The server accepts the connection but doesnt receive the message (or the client doesnt send message) but when I cancel process of the client project, the server receives
Plz correct me if i wrong.
Following are my configuration files (Refered to http://jpos.org/doc/proguide-draft.pdf)
10_channel.xml
<?xml version="1.0" encoding="UTF-8"?>
<channel-adaptor name='test-channel'
class="org.jpos.q2.iso.ChannelAdaptor" logger="Q2">
<channel class="org.jpos.iso.channel.ASCIIChannel" logger="Q2" realm="test-channel"
packager="org.jpos.iso.packager.GenericPackager">
<property name="packager-config" value="src/main/resources/iso8583.xml" />
<property name="host" value="127.0.0.1" />
<property name="port" value="9090" />
<property name="connection-timeout" value="15000" />
<property name="timeout" value="3000000" />
<property name="keep-alive" value="true" />
</channel>
<!-- <ignore-iso-exceptions>yes</ignore-iso-exceptions>-->
<in>client-send</in>
<out>client-receive</out>
<reconnect-delay>10000</reconnect-delay>
</channel-adaptor>
20_mux.xml
<?xml version="1.0" encoding="UTF-8"?>
<mux class="org.jpos.q2.iso.QMUX" logger="Q2" name="test-mux">
<in>client-receive</in>
<out>client-send</out>
<ready>test-channel.ready</ready>
<unhandled>myunhandledqueue</unhandled>
<key>2 7</key>
</mux>
JPos Client code
Q2 q2 = new Q2("src/main/deploy/");
q2.start();
QMUX mux = (QMUX)NameRegistrar.getIfExists("mux.test-mux");
if (mux != null && mux.isConnected()) {
ISOMsg request = new IsoMessage().build(); //dump iso message
ISOMsg response = mux.request(request, REQUEST_TIMEOUT);
if (response != null) {
ISOMsg receivedIsoMsg = new ISOMsg();
receivedIsoMsg.setPackager(new GenericPackager("path_to_file_xml"));
receivedIsoMsg.unpack(response.getBytes());
receivedIsoMsg.dump(System.out, "");
}
}
Socket Server Code
ServerSocket serverSocket;
try {
System.out.println("Binding to port " + SERVER_PORT + ", please wait ...");
serverSocket = new ServerSocket(SERVER_PORT);
System.out.println("Server started: " + serverSocket);
System.out.println("Waiting for a client ...");
while (true) {
try {
Socket socket = serverSocket.accept();
DataInputStream dis = new DataInputStream(socket.getInputStream());
String message = (String) dis.readLine();
System.out.println("Message Received: " + message);
ISOMsg receivedIsoMsg = new ISOMsg();
receivedIsoMsg.setPackager(new GenericPackager("path_to_file_xml"));
receivedIsoMsg.unpack(message.getBytes());
receivedIsoMsg.setMTI("0110");
receivedIsoMsg.set(39,"00");
receivedIsoMsg.dump(System.out, "");
DataOutputStream dos = new DataOutputStream(socket.getOutputStream());
//write object to Socket
dos.writeUTF(new String(receivedIsoMsg.pack()));
} catch (IOException | ISOException ex) {
System.err.println(ex);
}
}
} catch (IOException e1) {
try {
serverSocket.close();
} catch (IOException ex) {
System.err.println(ex);
}
}
Trace log
Client:
--- exec-maven-plugin:1.2.1:exec (default-cli) # JposTest ---
<log realm="Q2.system" at="2020-07-30T10:45:25.638">
<info>
Q2 started, deployDir=/Users/lap/NetBeansProjects/JposTest/src/main/deploy, environment=default
</info>
</log>
<log realm="Q2.system" at="2020-07-30T10:45:26.160" lifespan="507ms">
<version>
jPOS 2.1.3 master/95b8dce (2019-06-16 15:16:57 ART)
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
jPOS Community Edition, licensed under GNU AGPL v3.0.
This software is probably not suitable for commercial use.
Please see http://jpos.org/license for details.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Darwin)
iQEcBAEBAgAGBQJMolHDAAoJEOQyeO71nYtFv74H/3OgehDGEy1VXp2U3/GcAobg
HH2eZjPUz53r38ARPiU3pzm9LwDa3WZgJJaa/b9VrJwKvbPwe9+0kY3gScDE1skT
ladHt+KHHmGQArEutkzHlpZa73RbroFEIa1qmN6MaDEHGoxZqDh0Sv2cpvOaVYGO
St8ZaddLBPC17bSjAPWo9sWbvL7FgPFOHhnPmbeux8SLtnfWxXWsgo5hLBanKmO1
1z+I/w/6DL6ZYZU6bAJUk+eyVVImJqw0x3IEElI07Nh9MC6BA4iJ77ejobj8HI2r
q9ulRPEqH9NR79619lNKVUkE206dVlXo7xHmJS1QZy5v/GT66xBxyDVfTduPFXk=
=oP+v
-----END PGP SIGNATURE-----
</version>
</log>
<log realm="Q2.system" at="2020-07-30T10:45:26.168" lifespan="5ms">
<info>
deploy: /Users/lap/NetBeansProjects/JposTest/src/main/deploy/10_zp_channel.xml
</info>
</log>
<log realm="Q2.system" at="2020-07-30T10:45:26.199" lifespan="30ms">
<info>
deploy: /Users/lap/NetBeansProjects/JposTest/src/main/deploy/20_zp_qmux.xml
</info>
</log>
<log realm="Q2.system" at="2020-07-30T10:45:26.207" lifespan="8ms">
<info>
deploy: /Users/lap/NetBeansProjects/JposTest/src/main/deploy/99_sysmon.xml
</info>
</log>
<log realm="org.jpos.q2.qbean.SystemMonitor" at="2020-07-30T10:45:26.225">
<info>
Starting SystemMonitor
</info>
</log>
<log realm="org.jpos.q2.qbean.SystemMonitor" at="2020-07-30T10:45:26.225">
<info>
......
thread count: 10
peak threads: 10
user threads: 7
Thread[Reference Handler,10,system]
Thread[Finalizer,8,system]
Thread[Signal Dispatcher,9,system]
Thread[main,5,main]
Thread[pool-1-thread-1,5,main]
Thread[Q2-dd666708-34a1-46dc-9a10-4df253d9249a,5,main]
Thread[Thread-1,5,main]
Thread[channel-sender-client-send,5,main]
Thread[channel-receiver-client-receive,5,main]
Thread[SystemMonitor,5,main]
name-registrar:
tspace:default: org.jpos.space.TSpace
key-count: 0
gcinfo: 0,0
Q2: org.jpos.q2.Q2
test-channel: org.jpos.q2.iso.ChannelAdaptor
tx=0, rx=0, connects=0, last=0
logger.Q2: org.jpos.util.Logger
channel.test-channel: org.jpos.iso.channel.ASCIIChannel
mux.test-mux: org.jpos.q2.iso.QMUX
tx=0, rx=0, tx_expired=0, tx_pending=0, rx_expired=0, rx_pending=0, rx_unhandled=0, rx_forwarded=0, connected=false, last=0
logger.: org.jpos.util.Logger
</info>
</log>
<log realm="test-channel/127.0.0.1:9090" at="2020-07-30T10:45:36.309" lifespan="10084ms">
<connect>
Try 0 127.0.0.1:9090
</connect>
</log>
<log realm="test-channel/127.0.0.1:9090" at="2020-07-30T10:45:55.579" lifespan="1ms">
<send>
<isomsg direction="outgoing">
<!-- org.jpos.iso.packager.GenericPackager[src/main/resources/iso8583.xml] -->
<field id="0" value="0100"/>
<field id="2" value="123456"/>
<field id="3" value="000010"/>
<field id="4" value="1500"/>
<field id="7" value="1206041200"/>
<field id="11" value="000001"/>
<field id="41" value="12340001"/>
<field id="49" value="840"/>
</isomsg>
</send>
</log>
Server:
--- exec-maven-plugin:1.2.1:exec (default-cli) # AppTest ---
Binding to port 9090, please wait ...
Server started: ServerSocket[addr=0.0.0.0/0.0.0.0,localport=9090]
Waiting for a client ...
Client accepted: Socket[addr=/127.0.0.1,port=58902,localport=9090]
=> the Client cannot send message
But if I cancel process of client project, the Server receives message & print log:
Message Received: 00730100722000000080800006123456000010000000001500120604120000000112340001840
<isomsg>
<!-- org.jpos.iso.packager.GenericPackager -->
<field id="0" value="0110"/>
<field id="8" value="80000612"/>
<field id="18" value="3456"/>
<field id="19" value="000"/>
<field id="20" value="010"/>
<field id="23" value="000"/>
<field id="27" value="0"/>
<field id="39" value="00"/>
<field id="57" value=""/>
</isomsg>

Problem is you are trying to receive the message using readLine and iso messages are not strings ended with an EOL.
I believe what's happening is that when the client disconnects the readLine method returns, because the input stream is closed.
It would be better to use ISOServer on your server, or even better a full q2 to implement it.
Otherwise you should first read the message length and then read that amount of bytes from the input stream, instead of waiting for a new line character that may or may not be part of the message itself
You can follow the first two jpos tutorials here http://www.jpos.org/tutorials, to get an idea on how to configure a Server with a request listener to process requests.

Related

Problem unpacking field 54 when ISO Server and ISO Client has the same packager

I am making a jPOS Client and a ISO Server program, in which I'm trying to hit the server from the client.
I got this exception on my client, my server successfully returned this response (both using the same packager).
ISO Server response
<log realm="xml-server-8000/127.0.0.1:54830" at="2023-02-13T09:30:02.218720900">
<send>
<isomsg direction="outgoing">
<!-- org.jpos.iso.packager.GenericPackager[cfg/iso87ascii.xml] -->
<header>49534F303136303030303135</header>
<field id="0" value="0210"/>
<field id="2" value="1818180000000001"/>
<field id="3" value="011000"/>
<field id="4" value="000020000000"/>
<field id="5" value="000020000000"/>
<field id="6" value="000020000000"/>
<field id="7" value="0713085819"/>
<field id="9" value="61000000"/>
<field id="10" value="61000000"/>
<field id="11" value="000017"/>
<field id="12" value="155819"/>
<field id="13" value="0713"/>
<field id="17" value="0713"/>
<field id="18" value="6011"/>
<field id="32" value="11"/>
<field id="35" value="1818180000000001=9912"/>
<field id="37" value="1039 "/>
<field id="38" value="000017"/>
<field id="39" value="00"/>
<field id="41" value="00001641"/>
<field id="43" value="RPC MAKASSAR UJUNG PANDANG ID "/>
<field id="49" value="360"/>
<field id="50" value="360"/>
<field id="51" value="360"/>
<field id="54" value="1002360C000268000980"/>
<field id="60" value="BDANPRO1+000"/>
<field id="61" value="CBDAPRO10000P"/>
<field id="100" value="888"/>
<field id="102" value="003600108017"/>
<field id="126" value="& 0000200122! QJ00100 081278329015 123456 47059965 5577911488052911 "/>
</isomsg>
</send>
</log>
ISOClient packager log after receiving response
<log realm="debug" at="2023-02-13T09:30:02.210741800">
<pack>
30323030463233384330303132384130383031383030303030303030313430303030303431363138313831383030303030303030303130313130303030303030323030303030303030373133303835383139303030303137313535383139303731333037313336303131303231313231313831383138303030303030303030313D393931323130333920202020202020203030303031363431525043204D414B415353415220202020202020202020554A554E472050414E44414E47202020494420202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020203336303031324244414E50524F312B3030303031334342444150524F313030303050303338383831323030333630303130383031373132322620303030303230303132322120514A30303130302030383132373833323930313520202031323334353620202020202034373035393936352020202035353737393131343838303532393131202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020
</pack>
</log>
<log realm="debug" at="2023-02-13T09:30:02.221712900" lifespan="2ms">
<unpack>
49534F3031363030303031353032313046454638433030313245413045343138303030303030303031343030303030343136313831383138303030303030303030313031313030303030303032303030303030303030303032303030303030303030303032303030303030303037313330383538313936313030303030303631303030303030303030303137313535383139303731333037313336303131303231313231313831383138303030303030303030313D3939313231303339202020202020202030303030313730303030303031363431525043204D414B415353415220202020202020202020554A554E472050414E44414E472020204944202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202033363033363033363030323031303032333630433030303236383030303938303031324244414E50524F312B3030303031334342444150524F313030303050303338383831323030333630303130383031373132322620303030303230303132322120514A30303130302030383132373833323930313520202031323334353620202020202034373035393936352020202035353737393131343838303532393131202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020
<bitmap>{4, 6, 7, 28, 30, 32, 39, 44, 49, 50, 51, 52, 53, 54, 55, 57, 58, 59, 60, 61}</bitmap>
<unpack fld="4" packager="org.jpos.iso.IFA_NUMERIC">
<!-- AMOUNT, TRANSACTION -->
<value>C0012EA0E418</value>
</unpack>
<unpack fld="6" packager="org.jpos.iso.IFA_NUMERIC">
<!-- AMOUNT, CARDHOLDER BILLING -->
<value>000000001400</value>
</unpack>
<unpack fld="7" packager="org.jpos.iso.IFA_NUMERIC">
<!-- TRANSMISSION DATE AND TIME -->
<value>0004161818</value>
</unpack>
<unpack fld="28" packager="org.jpos.iso.IFA_AMOUNT">
<!-- AMOUNT, TRANSACTION FEE -->
<value>180000000</value>
</unpack>
<unpack fld="30" packager="org.jpos.iso.IFA_AMOUNT">
<!-- AMOUNT, TRANSACTION PROCESSING FEE -->
<value>001011000</value>
</unpack>
<unpack fld="32" packager="org.jpos.iso.IFA_LLNUM">
<!-- ACQUIRING INSTITUTION IDENT CODE -->
<value></value>
</unpack>
<unpack fld="39" packager="org.jpos.iso.IF_CHAR">
<!-- RESPONSE CODE -->
<value>00</value>
</unpack>
<unpack fld="44" packager="org.jpos.iso.IFA_LLCHAR">
<!-- ADITIONAL RESPONSE DATA -->
<value>00000000002000000000</value>
</unpack>
<unpack fld="49" packager="org.jpos.iso.IF_CHAR">
<!-- CURRENCY CODE, TRANSACTION -->
<value>002</value>
</unpack>
<unpack fld="50" packager="org.jpos.iso.IF_CHAR">
<!-- CURRENCY CODE, SETTLEMENT -->
<value>000</value>
</unpack>
<unpack fld="51" packager="org.jpos.iso.IF_CHAR">
<!-- CURRENCY CODE, CARDHOLDER BILLING -->
<value>000</value>
</unpack>
<unpack fld="52" packager="org.jpos.iso.IFA_BINARY">
<!-- PIN DATA -->
<value type='binary'>0071308581961000</value>
</unpack>
<unpack fld="53" packager="org.jpos.iso.IFA_NUMERIC">
<!-- SECURITY RELATED CONTROL INFORMATION -->
<value>0006100000000001</value>
</unpack>
error unpacking field 54 consumed=139
<iso-exception>
org.jpos.iso.IFA_LLLCHAR: Problem unpacking field 54
<iso-exception>
Field length 715 too long. Max: 120
org.jpos.iso.ISOException: Field length 715 too long. Max: 120
at org.jpos.iso.ISOStringFieldPackager.unpack(ISOStringFieldPackager.java:179)
at org.jpos.iso.ISOBasePackager.unpack(ISOBasePackager.java:306)
at org.jpos.iso.ISOMsg.unpack(ISOMsg.java:479)
at org.jpos.iso.BaseChannel.unpack(BaseChannel.java:978)
at org.jpos.iso.BaseChannel.receive(BaseChannel.java:748)
at com.taskincomplete.jpos.SampleRequestB24Channel.main(SampleRequestB24Channel.java:103)
</iso-exception>
org.jpos.iso.ISOException: org.jpos.iso.IFA_LLLCHAR: Problem unpacking field 54 (org.jpos.iso.ISOException: Field length 715 too long. Max: 120)
at org.jpos.iso.ISOStringFieldPackager.unpack(ISOStringFieldPackager.java:187)
at org.jpos.iso.ISOBasePackager.unpack(ISOBasePackager.java:306)
at org.jpos.iso.ISOMsg.unpack(ISOMsg.java:479)
at org.jpos.iso.BaseChannel.unpack(BaseChannel.java:978)
at org.jpos.iso.BaseChannel.receive(BaseChannel.java:748)
at com.taskincomplete.jpos.SampleRequestB24Channel.main(SampleRequestB24Channel.java:103)
Nested:org.jpos.iso.ISOException: Field length 715 too long. Max: 120
at org.jpos.iso.ISOStringFieldPackager.unpack(ISOStringFieldPackager.java:179)
at org.jpos.iso.ISOBasePackager.unpack(ISOBasePackager.java:306)
at org.jpos.iso.ISOMsg.unpack(ISOMsg.java:479)
at org.jpos.iso.BaseChannel.unpack(BaseChannel.java:978)
at org.jpos.iso.BaseChannel.receive(BaseChannel.java:748)
at com.taskincomplete.jpos.SampleRequestB24Channel.main(SampleRequestB24Channel.java:103)
</iso-exception>
<iso-exception>
org.jpos.iso.IFA_LLLCHAR: Problem unpacking field 54 (org.jpos.iso.ISOException: Field length 715 too long. Max: 120) unpacking field=54, consumed=139
org.jpos.iso.ISOException: org.jpos.iso.IFA_LLLCHAR: Problem unpacking field 54 (org.jpos.iso.ISOException: Field length 715 too long. Max: 120) unpacking field=54, consumed=139
at org.jpos.iso.ISOBasePackager.unpack(ISOBasePackager.java:341)
at org.jpos.iso.ISOMsg.unpack(ISOMsg.java:479)
at org.jpos.iso.BaseChannel.unpack(BaseChannel.java:978)
at org.jpos.iso.BaseChannel.receive(BaseChannel.java:748)
at com.taskincomplete.jpos.SampleRequestB24Channel.main(SampleRequestB24Channel.java:103)
</iso-exception>
</unpack>
</log>
this is the ISO Client Code i used
public static void main(String[] args) throws IOException, ISOException {
// Create Packager based on XML that contain DE type
GenericPackager packager = new GenericPackager("iso87ascii.xml");
// Create ISO Message
ISOMsg isoMsg = new ISOMsg();
isoMsg.setPackager(packager);
//isoMsg.setHeader("6003560000".getBytes());
isoMsg.setHeader("ISO016000010".getBytes());
isoMsg.setMTI("0200");
isoMsg.set(2, "1818180000000001");
isoMsg.set(3, "011000");
isoMsg.set(4, "000020000000");
isoMsg.set(7, "0713085819");
isoMsg.set(11, "000017");
isoMsg.set(12, "155819");
isoMsg.set(13, "0713");
isoMsg.set(17,"0713");
isoMsg.set(18,"6011");
isoMsg.set(32,"11");
isoMsg.set(35, "1818180000000001=9912");
isoMsg.set(37, "1039");
isoMsg.set(41, "00001641");
isoMsg.set(43, "RPC MAKASSAR UJUNG PANDANG ID");
isoMsg.set(49, "360");
isoMsg.set(60, "BDANPRO1+000");
isoMsg.set(61, "CBDAPRO10000P");
isoMsg.set(100, "888");
isoMsg.set(102, "003600108017");
isoMsg.set(126, "& 0000200122! QJ00100 081278329015 123456 47059965 5577911488052911 ");
BASE24Channel c = new BASE24Channel("localhost", 8000, packager/*
* , ISOUtil.str2bcd("600356", false)
*/);
logISOMsg(isoMsg);
System.out.println(ISOUtil.hexdump(isoMsg.pack()));
c.connect();
c.send(isoMsg);
ISOMsg response = c.receive();
System.out.println(ISOUtil.hexdump(response.pack()));
System.out.println("****************Response *********************");
logISOMsg(response);
the current jpos server xml i use using the same ISOChannelType as the client
<server class="org.jpos.q2.iso.QServer" logger="Q2" name="xml-server-8000" realm="xml-server-8000">
<attr name="port" type="java.lang.Integer">8000</attr>
<channel class="org.jpos.iso.channel.BASE24Channel"
packager="org.jpos.iso.packager.GenericPackager"
type="server"
logger="Q2"
realm="xml-server-8000"
header= "ISO016000010">
<property name="timeout" value="180000"/>
<property name="packager-config" value="cfg/iso87ascii.xml" />
</channel>
<request-listener class="org.jpos.tutorial.LogonRequest" />
</server>
last the packager
myPackager both server and client using the same packager, but still the client can't parse the message, any idea? Also just noticed my ISOClient received different bitmap with my ISOServer response bitmap
The issue was solved the issue by setting a header on the client channel, this is because the channel needs to know how many of the incoming bytes are for the header.
Here isthe fixed code
public static void main(String[] args) throws IOException, ISOException {
// Create Packager based on XML that contain DE type
GenericPackager packager = new GenericPackager("iso87ascii.xml");
// Create ISO Message
ISOMsg isoMsg = new ISOMsg();
isoMsg.setPackager(packager);
//isoMsg.setHeader("6003560000".getBytes());
isoMsg.setHeader("ISO016000010".getBytes());
isoMsg.setMTI("0200");
isoMsg.set(2, "1818180000000001");
isoMsg.set(3, "011000");
isoMsg.set(4, "000020000000");
isoMsg.set(7, "0713085819");
isoMsg.set(11, "000017");
isoMsg.set(12, "155819");
isoMsg.set(13, "0713");
isoMsg.set(17,"0713");
isoMsg.set(18,"6011");
isoMsg.set(32,"11");
isoMsg.set(35, "1818180000000001=9912");
isoMsg.set(37, "1039");
isoMsg.set(41, "00001641");
isoMsg.set(43, "RPC MAKASSAR UJUNG PANDANG ID");
isoMsg.set(49, "360");
isoMsg.set(60, "BDANPRO1+000");
isoMsg.set(61, "CBDAPRO10000P");
isoMsg.set(100, "888");
isoMsg.set(102, "003600108017");
isoMsg.set(126, "& 0000200122! QJ00100 081278329015 123456 47059965 5577911488052911 ");
BASE24Channel c = new BASE24Channel("localhost", 8000, packager);
c.setHeader("ISO016000010");
logISOMsg(isoMsg);
System.out.println(ISOUtil.hexdump(isoMsg.pack()));
c.connect();
c.send(isoMsg);
ISOMsg response = c.receive();
System.out.println(ISOUtil.hexdump(response.pack()));
System.out.println("****************Response *********************");
logISOMsg(response);

unable to unpack request sent from client. It keeps complaining of my packager although i am able to send successful request to their server

I have two way implementation where i send and also receive request from a remote server. I am able to successfully send request and always get successful response. However when the client sends request to me, my packager complains. Updating the packager causes sending request to the client to fail. Below is my error and configuration.
<log realm="post-channel/XXX.XXX.XXX.XXX:7777" at="2020-10-19T18:45:05.561" lifespan="5248ms">
<receive>
<iso-exception>
org.jpos.iso.IFA_LLCHAR: Problem unpacking field 94 (org.jpos.iso.ISOException: Invalid character found. Expected digit.) unpacking field=94, consumed=324
org.jpos.iso.ISOException: org.jpos.iso.IFA_LLCHAR: Problem unpacking field 94 (org.jpos.iso.ISOException: Invalid character found. Expected digit.) unpacking field=94, consumed=324
at org.jpos.iso.ISOBasePackager.unpack(ISOBasePackager.java:340)
at org.jpos.iso.ISOMsg.unpack(ISOMsg.java:479)
at org.jpos.iso.BaseChannel.unpack(BaseChannel.java:976)
at org.jpos.iso.BaseChannel.receive(BaseChannel.java:746)
at org.jpos.q2.iso.ChannelAdaptor$Receiver.run(ChannelAdaptor.java:332)
at java.lang.Thread.run(Thread.java:748)
</iso-exception>
10_channel.xml
<?xml version="1.0" encoding="UTF-8"?>
<channel-adaptor name="pesalink-channel" logger="Q2">
<channel class="org.jpos.iso.channel.ASCIIChannel" type="client" connect="yes" logger="Q2" realm="post-channel" packager="org.jpos.iso.packager.GenericPackager">
<property name="packager-config" value="cfg/customize.xml" />
<property name="host" value="XXX.XXX.XXX.XXX" />
<property name="port" value="7777" />
<property name="length-digits" value="6" />
<property name="connection-timeout" value="30000" />
<property name="timeout" value="300000" />
</channel>
<in>pesalink-channel-send</in>
<out>pesalink-channel-receive</out>
<reconnect-delay>10000</reconnect-delay>
<keep-alive>yes</keep-alive>
</channel-adaptor>
20_server.xml
<?xml version="1.0" ?>
<server name="server-receiving" class="org.jpos.q2.iso.QServer" logger="Q2">
<attr name="port" type="java.lang.Integer">7777</attr>
<channel name="channel-receive" class="org.jpos.iso.channel.NACChannel" packager="org.jpos.iso.packager.GenericPackager" logger="Q2">
<property name="packager-config" value="cfg/customize2.xml" />
</channel>
<request-listener class="com.test.linkListener" logger="Q2" realm="incoming-request-listener">
</request-listener>
<in>NETWORK_IN</in>
<out>NETWORK_OUT</out>
</server>
code to receive request
public class linkListener implements ISORequestListener{
private static final String FTREQUEST = "1200";
private static final String REVADVICE = "1420";
private static final String NETWORKREQ = "1804";
#Autowired
HttpHandler httpHandler;
Log log1;
#Override
public boolean process(ISOSource source, ISOMsg m) {
System.out.println("::::: Waiting :::::");
log.info("::::: Inside Listener :::::");
try {
String mti = m.getMTI();
System.out.println("mti ::: " + mti);
log.info("mti ::: " + mti);
switch (mti) {
case FTREQUEST:
log.info("Inside Financial Transaction Request");
String amt = m.getString(4);
Double amount1 = Double.parseDouble(amt);
Double amount2 = amount1 / 100;
String amount = String.format("%.2f", amount2);
log.info("amount formated ::: " + amount);
String stan = m.getString(11);
log.info("stan ::: " + stan);
String rrn = m.getString(37);
log.info("rrn ::: " + rrn);
String senderAccountNo = m.getString(102);
log.info("senderAccountNo ::: " + senderAccountNo);
String beneficiaryAccountNo = m.getString(103);
log.info("senderAccountNo ::: " + beneficiaryAccountNo);
m.set(39, "100");
m.setMTI("1210");
m.set(2, m.getString(2));
m.set(3, m.getString(3));
m.set(4, m.getString(4));
m.set(11, m.getString(11));
m.set(12, m.getString(12));
source.send(m);
break;
case REVADVICE:
log.info("Reversal Advice");
break;
case NETWORKREQ:
log.info("Network Management Request");
break;
}
} catch (Exception ex) {
ex.printStackTrace(System.out);
}
return true;
}
}

Input needed for twitter cloud connector in Mule

I have a flow with a custon filter that works(with an echo) but if I try tu use a twitter cloud connector i get this error
ERROR 2015-04-04 19:09:02,451 [[CopyTrabajosd2].trabajosdFlow.stage1.02] org.mule.retry.notifiers.ConnectNotifier: Failed to connect/reconnect: Work Descriptor. Root Exception was: Response code 403 mapped as failure. Message payload is of type: BufferInputStream. Type: class org.mule.module.http.internal.request.ResponseValidatorException
ERROR 2015-04-04 19:09:02,458 [[CopyTrabajosd2].trabajosdFlow.stage1.02] org.mule.exception.CatchMessagingExceptionStrategy:
********************************************************************************
Message : Response code 403 mapped as failure. Message payload is of type: BufferInputStream
Code : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. Response code 403 mapped as failure. Message payload is of type: BufferInputStream (org.mule.module.http.internal.request.ResponseValidatorException)
org.mule.module.http.internal.request.SuccessStatusCodeValidator:37 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/module/http/internal/request/ResponseValidatorException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
org.mule.module.http.internal.request.ResponseValidatorException: Response code 403 mapped as failure. Message payload is of type: BufferInputStream
at org.mule.module.http.internal.request.SuccessStatusCodeValidator.validate(SuccessStatusCodeValidator.java:37)
at org.mule.module.http.internal.request.DefaultHttpRequester.innerProcess(DefaultHttpRequester.java:202)
at org.mule.module.http.internal.request.DefaultHttpRequester.process(DefaultHttpRequester.java:166)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************
I think that the clout connector is not receiving the input type that it needs but I'm not sure ,any help?
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:twitter="http://www.mulesoft.org/schema/mule/twitter" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:json="http://www.mulesoft.org/schema/mule/json" xmlns:smtp="http://www.mulesoft.org/schema/mule/smtp"
xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.6.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/smtp http://www.mulesoft.org/schema/mule/smtp/current/mule-smtp.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd
http://www.mulesoft.org/schema/mule/twitter http://www.mulesoft.org/schema/mule/twitter/current/mule-twitter.xsd">
<smtp:gmail-connector name="gmail" doc:name="Gmail"/>
<http:request-config name="HTTP_Request_Configuration" host="api.openweathermap.org" port="80" basePath="data/2.5/forecast/daily?q=San Fernando,es&lang=es&units=metric&cnt=2&mode=json" doc:name="HTTP Request Configuration"/>
<spring:beans>
<spring:bean id="transformador" name="Bean" class="com.trabajosd.Transformador"/>
</spring:beans>
<twitter:config name="Twitter__Configuration" accessKey="3006010565-rUz6h4xnNoHO2juxGYQEK5jcM5DvSpxv7P3hv07" accessSecret="KxcqDQEo6JbHHR2S10lFN5luxXLEJauNhiBdZIeY7tUXO" consumerKey="LBxBQUYhbAFb5PeBtR7Jg4Evo" consumerSecret="AdD8lJYRS1OadJsn2BXhEbnhdcUNc1t3uM9pnOGH7eNfE2JxZu" doc:name="Twitter: Configuration"/>
<flow name="trabajosdFlow">
<poll doc:name="Poll">
<fixed-frequency-scheduler frequency="10000"/>
<http:request config-ref="HTTP_Request_Configuration" path="/" method="GET" doc:name="HTTP"/>
</poll>
<logger level="INFO" doc:name="Logger"/>
<byte-array-to-string-transformer doc:name="Byte Array to String"/>
<json:json-to-object-transformer doc:name="JSON to Object"/>
<custom-filter class="com.trabajosd.Filtro" doc:name="Custom"/>
<twitter:update-status config-ref="Twitter__Configuration" status="Predicción de lluvia para hoy(Prueba Mule)" doc:name="Twitter"/>
<catch-exception-strategy doc:name="Catch Exception Strategy"/>
</flow>
<catch-exception-strategy name="trabajosdCatch_Exception_Strategy">
<logger level="INFO" doc:name="Logger"/>
</catch-exception-strategy>
</mule>
And the custon filter class
package com.trabajosd;
import org.json.JSONArray;
import org.json.JSONObject;
import org.mule.api.MuleMessage;
import org.mule.api.routing.filter.Filter;
public class Filtro implements Filter{
#Override
public boolean accept(MuleMessage message) {
try {
String json=message.getPayloadAsString();
JSONObject obj = new JSONObject(json);
JSONArray lista = obj.getJSONArray("list");
JSONObject elemento0 =lista.getJSONObject(0);
JSONArray clima = elemento0.getJSONArray("weather");
JSONObject prediccion = clima.getJSONObject(0);
return prediccion.getString("main").equalsIgnoreCase("Clouds");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return false;
}
}
It seems that there is an issue with WWW-authenticate header header in Mule 3.6.x.
The error usually is "401 response received, but no WWW-Authenticate header was present". Not sure why it is http response 403 in your case.
I tried a basic twitter flow and it works on Mule 3.5 but not 3.6.
The reported issues are:
https://www.mulesoft.org/jira/browse/MULE-8282
https://www.mulesoft.org/jira/browse/MULE-8127
https://www.mulesoft.org/jira/browse/MULE-8249

Listing files from ftp using spring-integration

I want to list all of files on an FTP server using spring-integration and, for example, print them on screen. I've done something like this:
context:
<int:channel id="toSplitter">
<int:interceptors>
<int:wire-tap channel="logger"/>
</int:interceptors>
</int:channel>
<int:logging-channel-adapter id="logger" log-full-message="true"/>
<int:splitter id="splitter" input-channel="toSplitter" output-channel="getFtpChannel"/>
<int-ftp:outbound-gateway id="gatewayLS"
session-factory="ftpClientFactory"
request-channel="inbound"
command="ls"
expression="payload"
reply-channel="toSplitter"/>
<int:channel id="getFtpChannel">
<int:queue/>
</int:channel>
<bean id="ftpClientFactory"
class="org.springframework.integration.ftp.session.DefaultFtpSessionFactory">
<property name="host" value="${host}"/>
<property name="username" value="${user}"/>
<property name="password" value="${password}"/>
<property name="clientMode" value="0"/>
<property name="fileType" value="2"/>
<property name="bufferSize" value="10000000"/>
</bean>
Java code:
ConfigurableApplicationContext context =
new FileSystemXmlApplicationContext("/src/citrus/resources/citrus-context.xml");
final FtpFlowGateway ftpFlow = context.getBean(FtpFlowGateway.class);
ftpFlow.lsFiles("/");
PollableChannel channel = context.getBean("getFtpChannel", PollableChannel.class);
variable("tt", channel.receive().toString());
echo("${tt}");
output:
11:09:17,169 INFO port.LoggingReporter| Test action <echo>
11:09:17,169 INFO actions.EchoAction| [Payload=FileInfo [isDirectory=false, isLink=false, Size=3607, ModifiedTime=Tue Jul 15 14:18:00 CEST 2014, Filename=Smoke03_angart30_st40.exi, RemoteDirectory=/, Permiss
ions=-rw-r--r--]][Headers= {replyChannel=org.springframework.integration.core.MessagingTemplate$TemporaryReplyChannel#7829b776, sequenceNumber=1, errorChannel=org.springframework.integration.core.MessagingTempla
te$TemporaryReplyChannel#7829b776, file_remoteDirectory=/, sequenceSize=1, correlationId=49b57f2d-4dbf-4a89-b5b8-0dfb15bca2be, id=0a58ad65-74b4-4aae-87be- aa6034a41776, timestamp=1405501757060}]
11:09:17,169 INFO port.LoggingReporter| Test action <echo> done
11:09:17,169 INFO port.LoggingReporter| TEST STEP 1/1 done
The output is fine, but what should I do to print this information when I don't know how many files are stored on the FTP? (this code prints only one file). I've tried checking if channel.receive() is null but the test just freezes.
Since you send the result of LS to the <splitter>, your getFtpChannel will receive FileInfo<?> objects one by one.
To print them all you really should have an infinite loop:
while (true) {
variable("tt", channel.receive().toString());
echo("${tt}");
}
To stop the app you should provide some shoutDownHook or listen something from console input.
Another point, that it is bad to block your app with infinite receive().
There is na overloaded method, which applies a timeout param. The last one might be useful to determine the end of your loop:
while (true) {
Message<?> receive = channel.receive(10000);
if (receive == null) {
break;
}
variable("tt", receive.toString());
echo("${tt}");
}
#Configuration
public class FtpConfig {
#Bean
public DefaultFtpSessionFactory ftpSessionFactory() {
DefaultFtpSessionFactory ftpSessionFactory = new DefaultFtpSessionFactory();
ftpSessionFactory.setHost("localhost");
ftpSessionFactory.setPort(21);
ftpSessionFactory.setUsername("user");
ftpSessionFactory.setPassword("pass");
return ftpSessionFactory;
}
}
#Bean
public ApplicationRunner runner(DefaultFtpSessionFactory sf) {
return args -> {
FTPFile[] list = sf.getSession().list(".");
for (FTPFile file: list ) {
System.out.println("Result: " + file.getName());
}
};
}

how to develop chatting application in java using flex?

In my Flex Application MXML file i'm writing..
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
width="598" height="459" creationComplete="consumer.subscribe()" layout="vertical">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.messaging.messages.AsyncMessage;
import mx.messaging.messages.IMessage;
public function send():void {
var message:IMessage = new AsyncMessage();
message.destination = "SimpleChatDestination";
message.body = "\n" + usernameInput.text + ":\t" + messageInput.text;
trace(producer.connected);
producer.send(message);
messageInput.text = "";
}
public function messageHandler( message:IMessage ):void {
textArea.text += message.body;
}
]]>
</mx:Script>
<mx:Producer id="producer" destination="SimpleChatDestination"/>
<mx:Consumer id="consumer" destination="SimpleChatDestination" message="messageHandler(event.message)"/>
<mx:TextArea id="textArea" width="400" height="300" color="#F31C1C" editable="false"
enabled="false"/>
<mx:HBox horizontalGap="0">
<mx:TextInput id="usernameInput" width="80"/>
<mx:TextInput id="messageInput" width="180"/>
<mx:Button label="Send" click="send();"/>
</mx:HBox>
</mx:Application>
And in BlazeDs(java side) message-config.xml file i wrote code like this.
<?xml version="1.0" encoding="UTF-8"?>
<service id="message-service"
class="flex.messaging.services.MessageService">
<adapters>
<adapter-definition id="actionscript" class="flex.messaging.services.messaging.adapters.ActionScriptAdapter" default="true" />
<!-- <adapter-definition id="jms" class="flex.messaging.services.messaging.adapters.JMSAdapter"/> -->
</adapters>
<default-channels>
<channel ref="my-polling-amf"/>
</default-channels>
<adapters>
<adapter-definition id="actionscript" default="true" />
<!-- <adapter-definition id="jms"/> -->
</adapters>
<default-channels>
<channel ref="my-polling-amf"/>
</default-channels>
<destination id="SimpleChatDestination">
<properties>
<network>
<subscription-timeout-minutes>0</subscription-timeout-minutes>
</network>
<server>
<message-time-to-live>0</message-time-to-live>
<allow-subtopics>true</allow-subtopics>
<subtopic-separator>.</subtopic-separator>
</server>
</properties>
</destination>
</service>
So it is Working fine. But problem is when ever we open three are four chat boxes then all chat boxes are participated.
i want only allow two user can only chat if 3rd user came not visiable 2nd person chating information.
just it is like Facebook,Gmail chating.
plz help me..

Categories