Re: [jpos-users] SAF + OneShotChannelAdaptor

278 views
Skip to first unread message

Alejandro Revilla

unread,
Aug 31, 2012, 10:08:50 AM8/31/12
to jpos-...@googlegroups.com
If the host is not connected, SAF will silently wait until it gets connected again. Perhaps that's just the problem.

--
@apr



Bjarne Henriksen

unread,
Aug 31, 2012, 10:14:56 AM8/31/12
to jpos-...@googlegroups.com


Den fredag den 31. august 2012 16.09.12 UTC+2 skrev Alejandro Revilla:
If the host is not connected, SAF will silently wait until it gets connected again. Perhaps that's just the problem.

But when it connects again, shouldn't this be shown in log, just as when connection works from start?  
--
@apr



Alejandro Revilla

unread,
Aug 31, 2012, 10:28:07 AM8/31/12
to jpos-...@googlegroups.com
Correct, yes, activity should resume.

--
@apr


AAO

unread,
Aug 31, 2012, 10:36:50 AM8/31/12
to jpos-...@googlegroups.com
Not sure I understand:  If the mux is in not-ready status, the SAF can't and won't engage.

Andy

On Fri, Aug 31, 2012 at 8:05 AM, Bjarne Henriksen <bjarne.h...@gmail.com> wrote:
Hi

I'm having problems in getting the saf up and running. When the line outwards is up everything's fine, but if I change the host (to simulate lien lost/broken) nothing seems to happen. Not even in the logs, so I'm having a hard time figuring out what's been done wrong. I assume I've forgotten/overlooked something, so suggestions are highly appreciated:)

Below is my code, pretty basic:

protected void storeAndForwardMessage(ISOMsg msg) throws NotFoundException, ISOException{
MUX saf = QMUX.getMUX("unox-saf");
saf.request(msg, config.getSafMuxTimeoutInMs());
}


And the xml:

<channel-adaptor name='unox_saf_channel'
class="org.jpos.q2.iso.OneShotChannelAdaptor" logger="Gateway">
<channel class="org.jpos.iso.channel.ASCIIChannel" logger="Gateway"
packager="org.jpos.iso.packager.GenericPackager">
<property name="packager-config" value="config/IFSF_ISO_Definition.xml" />
<property name="host" value="172.23.1.10" />
<property name="port" value="4043" />
<property name="alternate-host" value="172.23.3.10" />
<property name="alternate-port" value="4043" />
<property name="timeout" value="600000" />
<property name="keep-alive" value="false" />
</channel>
<in>unox-saf-send</in>
<out>unox-saf-receive</out>
<reconnect-delay>10000</reconnect-delay>
</channel-adaptor>

<mux class="org.jpos.q2.iso.QMUX" logger="Q2" name="unox-saf">
 <in>unox-saf-receive</in>
<out>unox-saf-send</out>
</mux>

<saf name='saf' logger='saf' realm='saf' class='org.jpos.saf.SAF'>
<property name='space' value='jdbm:saf' />
<property name='mux' value='unox-saf' />
<property name='flag-retransmissions' value='no'>
1220, 1420
</property>
<property name='initial-delay' value='10000' />
<property name='inter-message-delay' value='1000' />
<property name='wait-for-response' value='5000' />
<property name='max-retransmissions' value='1000' />
<property name='expire-after' value='86400'>
in seconds
</property>
<property name='valid-response-codes' value='*' />
<property name='retry-response-codes' value='907,909,911,912' />
</saf>

--
--
jPOS is licensed under AGPL - free for community usage for your open-source project. Licenses are also available for commercial usage.
Please support jPOS, contact: sa...@jpos.org
 
You received this message because you are subscribed to the "jPOS Users" group.
Please see http://jpos.org/wiki/JPOS_Mailing_List_Readme_first
To post to this group, send email to jpos-...@googlegroups.com
To unsubscribe, send email to jpos-users+...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/jpos-users
 
 
 

Bjarne Henriksen

unread,
Aug 31, 2012, 10:42:32 AM8/31/12
to jpos-...@googlegroups.com
Andy,

I understand SAF can't send when line is down, but my understanding is that SAF should keep trying until message has been sent successfully?
So if line is down, try connect repeatedly, and when line is up again send pending message(s).

Bjarne

Mark Salter

unread,
Aug 31, 2012, 11:21:19 AM8/31/12
to jpos-...@googlegroups.com
On 31/08/2012 14:05, Bjarne Henriksen wrote:
> <saf name='saf' logger='saf' realm='saf' class='org.jpos.saf.SAF'>

Silly question from me :-)

do you have this logger configured?


--
Mark

Mark Salter

unread,
Aug 31, 2012, 11:21:43 AM8/31/12
to jpos-...@googlegroups.com
On 31/08/2012 16:21, Mark Salter wrote:
> do you have this logger configured?
and deployed?

--
Mark

Victor Salaman

unread,
Aug 31, 2012, 11:27:33 AM8/31/12
to jpos-...@googlegroups.com
Hi:

I don't think that SAF would work with the OneChannelAdaptor without changes to the OneChannelAdaptor code. The QMUX code depends on a channel "ready" selector to detect it's operational. The nature of OneShotChannel is to only open a connection if there are things to send, so normally it's at an unconnected state and doesn't register "ready selectors". 

Take a look at the source code for ChannelAdaptor.

/V 

Bjarne Henriksen

unread,
Aug 31, 2012, 11:32:49 AM8/31/12
to jpos-...@googlegroups.com
No silly questions exist, only silly answers:)

At first I'd forgotten about it, but now I have. After having set it up, I ran some tests again.
It runs as expected, when line is up, but nothing happens when line is down, which to an extend is fine:). 
After opening the line again subsequent messages are sent, but never the "missing" ones

/Bjarne

Alejandro Revilla

unread,
Aug 31, 2012, 2:05:23 PM8/31/12
to jpos-...@googlegroups.com
Can you try to set 'max-retransmissions' to 0 (so it continue resending forever?)

Mark Salter

unread,
Sep 2, 2012, 2:13:04 AM9/2/12
to jpos-...@googlegroups.com
On 31/08/2012 16:27, Victor Salaman wrote:

> I don't think that SAF would work with the OneChannelAdaptor without
> changes to the OneChannelAdaptor code. The QMUX code depends on a
> channel "ready" selector to detect it's operational. The nature of
> OneShotChannel is to only open a connection if there are things to
> send, so normally it's at an unconnected state and doesn't register
> "ready selectors".
>
> Take a look at the source code for ChannelAdaptor.
Taking the approach that this ChannelAdaptor is 'ready' for use at all
times after we have successfully connected with the target, I have
hacked this patch to satisfy a MUX's need for a ready indicator,
untested, but I wonder if you want to test it and report back Bjarne?

I also wanted to make the adaptor 'unready' on modification, but didn't
spend long enough looking to find the correct place to remove the
'ready' on modification.

I can look further, but thought I would see if you were able to assist
first :-).

patch follows temporarily hosted @

https://docs.google.com/open?id=0B--mAC_B6kcINUxGNXFQZTYtOGM

--
Mark

Victor Salaman

unread,
Sep 2, 2012, 2:30:18 AM9/2/12
to jpos-...@googlegroups.com
Bjarne:

Can you tell us what version of jPOS and jPOS-EE are you using?

My initial diagnosis for the ready indicators seems to be wrong. I just looked at QMUX.java and if there are no ready indicators present, it assumes the mux is always connected:

public boolean isConnected() {
if (ready != null && ready.length > 0) {
for (int i=0; i<ready.length; i++)
if (sp.rdp (ready[i]) != null)
return true;
return false;
}
else
return true;
}

So the SAF should just start sending, so it should be something else.

/V

Victor Salaman

unread,
Sep 2, 2012, 2:36:31 AM9/2/12
to jpos-...@googlegroups.com
Hi Bjarne:

I just looked again at your original message and saw that you are using the SAF in the following way:

protected void storeAndForwardMessage(ISOMsg msg) throws NotFoundException, ISOException{
MUX saf = QMUX.getMUX("unox-saf");
saf.request(msg, config.getSafMuxTimeoutInMs());
}

It should be:

SAF saf = SAF.getSAF("saf"); 
saf.send(msg);

and don't call your MUX "unof-saf" as the mux is not a SAF component :)

/V

<saf name='saf' logger='saf' realm='saf' class='org.jpos.saf.SAF'>
<property name='space' value='jdbm:saf' />
<property name='mux' value='unox-saf' />
<property name='flag-retransmissions' value='no'>
1220, 1420
</property>
<property name='initial-delay' value='10000' />
<property name='inter-message-delay' value='1000' />
<property name='wait-for-response' value='5000' />
<property name='max-retransmissions' value='1000' />
<property name='expire-after' value='86400'>
in seconds
</property>
<property name='valid-response-codes' value='*' />
<property name='retry-response-codes' value='907,909,911,912' />
</saf>

Mark Salter

unread,
Sep 2, 2012, 5:26:16 AM9/2/12
to jpos-...@googlegroups.com
On 02/09/2012 07:13, Mark Salter wrote:
> I can look further, but thought I would see if you were able to assist
> first :-).

Please ignore this suggestion Bjarne, Victor's observation on QMUX and
the 'ready' indicator means that it will *not* help you.

:-)

--
Mark

Mark Salter

unread,
Sep 2, 2012, 5:22:32 PM9/2/12
to jpos-...@googlegroups.com
On 31/08/2012 14:05, Bjarne Henriksen wrote:
> but if I change the host (to simulate
> lien lost/broken) nothing seems to happen.
How are you simulating this scenario?

I wonder if you are throwing the request away and not responding?

>
> <channel-adaptor name='unox_saf_channel'
.
[snip]
.
> <property name="timeout" value="600000" />
Just because this feel like a big value?


--
Mark

Mark Salter

unread,
Sep 2, 2012, 6:06:19 PM9/2/12
to jpos-...@googlegroups.com
On 02/09/2012 07:36, Victor Salaman wrote:
> It should be:
>
> SAF saf = SAF.getSAF("saf");
Is there an echo in here?? :-)

Very good spot V.

--
Mark

Bjarne Henriksen

unread,
Sep 2, 2012, 6:37:20 PM9/2/12
to jpos-...@googlegroups.com
First of all, I really appreciate all the effort you put in this for me, thank you so much.

I took the liberty to have the week-end off, that's why I haven't been responding.

Mark,
I may have been a little to eager on the time-out value, it should only have been 60 seconds:)
I've tested it 2 ways: One way by changing the host-address on the fly pointing to nowhere, and another by having a dummy-host always responding with success and then shutting the dummy-host-service down.
As I understand it that fix of yours will not work?

Victor,
I'm running on jpos 1.6.2, and jpos-ee on 2.0.1
I know the naming of the mux is a bit off, but I did it to seperate the default gateway and saf as they are pointing to the same host.
The code change of yours makes sense. I have to be honest and say I ripped the code from here http://markmail.org/message/wbytvplxlw3zpyyi#query:+page:1+mid:wbytvplxlw3zpyyi+state:results

Alejandro,
I'll set the max-retransmit to 0 nomatter whatever the solution is.

I'll try your suggestions monday and get back to you.

If anything new comes to mind, please let me know:)

/Bjarne

Bjarne Henriksen

unread,
Sep 2, 2012, 6:41:17 PM9/2/12
to jpos-...@googlegroups.com
Thank you.
One more to spot the same. sounds like we may have a winner.
Sorry I didn't see that my self.
I'll change and test first thing tomorrow:)

/Bjarne

Mark Salter

unread,
Sep 3, 2012, 2:34:59 AM9/3/12
to jpos-...@googlegroups.com
On 02/09/2012 23:37, Bjarne Henriksen wrote:
> Mark,
> I may have been a little to eager on the time-out value, it should only
> have been 60 seconds:)
Ok, good.

> I've tested it 2 ways: One way by changing the host-address on the fly
> pointing to nowhere, and another by having a dummy-host always
> responding with success and then shutting the dummy-host-service down.
I like the latter better. changing the port values in the config will
incur a stop and a restart (automatic) of the components, so this could
get in the way a little IMO.

> As I understand it that fix of yours will not work?
Indeed, please ignore it.

--
Mark

Bjarne Henriksen

unread,
Sep 3, 2012, 5:06:42 AM9/3/12
to jpos-...@googlegroups.com
How easy was that? 
The code change worked like a charm: Thank you so much, and at the same time apologies from me for not finding that error myself.
If ever in Copenhagen I'll by you guys a beer.

But...
I stopped my server with pending saf-requests, and when starting the server again I get following error:

    <exception name="org.jpos.saf.SAF$Entry">
    java.lang.ClassNotFoundException: org.jpos.saf.SAF$Entry
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at java.io.ObjectInputStream.resolveClass(Unknown Source)
at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
at java.io.ObjectInputStream.readClassDesc(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at jdbm.helper.Serialization.deserialize(Serialization.java:93)
at jdbm.helper.DefaultSerializer.deserialize(DefaultSerializer.java:101)
at jdbm.helper.DefaultSerializationHandler.deserialize(DefaultSerializationHandler.java:75)
at jdbm.recman.BaseRecordManager.fetch(BaseRecordManager.java:613)
at jdbm.recman.CacheRecordManager.fetch(CacheRecordManager.java:336)
at jdbm.recman.CacheRecordManager.fetch(CacheRecordManager.java:316)
at org.jpos.space.JDBMSpace.rdp(JDBMSpace.java:278)
at org.jpos.saf.SAF.latchMsg(SAF.java:162)
at org.jpos.saf.SAF.run(SAF.java:76)
at java.lang.Thread.run(Unknown Source)
    </exception>

I haven't made any changes to my xml-files.
Any ideas?

/Bjarne

Mark Salter

unread,
Sep 3, 2012, 7:27:35 AM9/3/12
to jPOS Users


On Sep 3, 10:06 am, Bjarne Henriksen <bjarne.henrik...@gmail.com>
wrote:
> I stopped my server with pending saf-requests, and when starting the server
> again I get following error:
>
>     <exception name="org.jpos.saf.SAF$Entry">
>     java.lang.ClassNotFoundException: org.jpos.saf.SAF$Entry
> at java.net.URLClassLoader$1.run(Unknown Source)
> at java.security.AccessController.doPrivileged(Native Method)
> at java.net.URLClassLoader.findClass(Unknown Source)
> at java.lang.ClassLoader.loadClass(Unknown Source)
> at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
> at java.lang.ClassLoader.loadClass(Unknown Source)
> at java.lang.Class.forName0(Native Method)
> at java.lang.Class.forName(Unknown Source)
> at java.io.ObjectInputStream.resolveClass(Unknown Source)
> at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
> at java.io.ObjectInputStream.readClassDesc(Unknown Source)
> at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
> at java.io.ObjectInputStream.readObject0(Unknown Source)
> at java.io.ObjectInputStream.readObject(Unknown Source)
> at jdbm.helper.Serialization.deserialize(Serialization.java:93)
> at jdbm.helper.DefaultSerializer.deserialize(DefaultSerializer.java:101)
> at
> jdbm.helper.DefaultSerializationHandler.deserialize(DefaultSerializationHan­dler.java:75)
> at jdbm.recman.BaseRecordManager.fetch(BaseRecordManager.java:613)
> at jdbm.recman.CacheRecordManager.fetch(CacheRecordManager.java:336)
> at jdbm.recman.CacheRecordManager.fetch(CacheRecordManager.java:316)
> at org.jpos.space.JDBMSpace.rdp(JDBMSpace.java:278)
> at org.jpos.saf.SAF.latchMsg(SAF.java:162)
> at org.jpos.saf.SAF.run(SAF.java:76)
> at java.lang.Thread.run(Unknown Source)
>     </exception>
>
> I haven't made any changes to my xml-files.
But have you incurred a rebuild or have you by chance adjusted/removed
the line :-
public static final long serialVersionUID = 1L; from the inner class
definition of Entry?

To my belief the class serialisation should not be affected by a
rebuild, but worth checking.

--
Mark

Victor Salaman

unread,
Sep 3, 2012, 7:30:57 AM9/3/12
to jpos-...@googlegroups.com
Hi:

I believe you have classpath issues, such as two copies of jPOS in your classpath. Also, upgrade to the latest released jPOS (1.8.6)

/V


Bjarne Henriksen

unread,
Sep 3, 2012, 8:19:54 AM9/3/12
to jpos-...@googlegroups.com
I thought somebody would advice to upgrade:)
So I'm trying all I can using maven, mvn install, right?

E:\jpos\jpos-jPOS-v1_8_6-0\jpos-jPOS-5652680\jpos>mvn install -e
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building jPOS Core 1.8.6
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ jpos ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 15 resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ jpos ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- exec-maven-plugin:1.1:exec (exec-git-log) @ jpos ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.132s
[INFO] Finished at: Mon Sep 03 14:20:23 CEST 2012
[INFO] Final Memory: 5M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.1:exec (exe
c-git-log) on project jpos: Result of cmd.exe /X /C "git log --pretty=format:rev
ision=%h -n1" execution is: '1'. -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal o
rg.codehaus.mojo:exec-maven-plugin:1.1:exec (exec-git-log) on project jpos: Resu
lt of cmd.exe /X /C "git log --pretty=format:revision=%h -n1" execution is: '1'.

        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:217)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:145)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProje
ct(LifecycleModuleBuilder.java:84)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProje
ct(LifecycleModuleBuilder.java:59)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBu
ild(LifecycleStarter.java:183)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(Lifecycl
eStarter.java:161)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:601)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Laun
cher.java:290)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.jav
a:230)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(La
uncher.java:409)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:
352)
Caused by: org.apache.maven.plugin.MojoExecutionException: Result of cmd.exe /X
/C "git log --pretty=format:revision=%h -n1" execution is: '1'.
        at org.codehaus.mojo.exec.ExecMojo.execute(ExecMojo.java:260)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(Default
BuildPluginManager.java:101)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:209)
        ... 19 more
[ERROR]
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:

--
Mvh
Bjarne Henriksen

Victor Salaman

unread,
Sep 3, 2012, 8:46:50 AM9/3/12
to jpos-...@googlegroups.com

It seems GIT is not in your path

Alejandro Revilla

unread,
Sep 3, 2012, 8:47:44 AM9/3/12
to jpos-...@googlegroups.com
BTW, if you use jPOS-EE, you could trust the jPOS version pulled via Maven.

--
@apr

Bjarne Henriksen

unread,
Sep 3, 2012, 12:58:49 PM9/3/12
to jpos-...@googlegroups.com
Now I have built and use latest version.

But now when running  the new version I get following error:

log4j:ERROR Could not find value for key log4j.appender.FILE
log4j:ERROR Could not instantiate appender named "FILE".

I use log4j in my own code, and it's been working fine until now. Any ideas?
To the best of my knowledge I haven't changed anything apart from upgrading jpos.

Bjarne Henriksen

unread,
Sep 3, 2012, 2:41:14 PM9/3/12
to jpos-...@googlegroups.com
SAF is now up and running:)

I ended up altering the manifest for jpos.jar so it was able to se the saf.jar. when starting.

But I still have the log4j error though. 
The property file for log4j seems to be loaded, I tried removing it, and gave a completely different error.


/Bjarne

Victor Salaman

unread,
Sep 3, 2012, 2:47:32 PM9/3/12
to jpos-...@googlegroups.com

Hi

Have you read the jposee guide? It seems to me that you are not following "best practices" shown in the guide. Particularly, you should not have to fiddle with jpos.jar or saf.jar.

Bjarne Henriksen

unread,
Sep 3, 2012, 3:59:58 PM9/3/12
to jpos-...@googlegroups.com
Victor,

I know it's not the proper thing to do, but I'm pressed for time, and maybe a bit thick, because I cannot figure out how to build saf into jpos. 
I will look into it though, there's no reason to do things the hard way, if there is an easier. I just need to figure it out:)

/Bjarne

Alejandro Revilla

unread,
Sep 3, 2012, 4:05:42 PM9/3/12
to jpos-...@googlegroups.com
Bjarne,

If you create a jPOS-EE archetype for your project, and add 'jposee-saf' as a dependency in your project, you should have all you need.

Take a look at http://jpos.org/doc/jPOS-EE.pdf where that is described (See Chapter 5, five minutes tutorial).

If you want to step back and use 'ant', this document is still valid (http://jpos.org/doc/jPOS-Project-Guide.pdf see the HOWTO section) although we are fading away 'ant' in favor of 'Maven' (I still have most of my projects in 'ant', slowly moving them to the new architecture).

Reply all
Reply to author
Forward
0 new messages