How to integrate transaction manager with ISO Request Listener?

1,111 views
Skip to first unread message

anil jaladi

unread,
Nov 12, 2012, 6:08:04 AM11/12/12
to jpos-...@googlegroups.com
Hi,

I want to Hands off the ISO request to the TransactionManager where this transactionmanager can do all the process.

I had gone through JPOS guide and i did not got How to integrate the Transaction Manager with ISORequestListener ?

can you please help me in this.

Thanks
Anil Kumar J




Victor Salaman

unread,
Nov 12, 2012, 7:41:42 AM11/12/12
to jpos-...@googlegroups.com

Anil,

We've covered this before in the sample I created for you. Did you not study it?

/v

--
--
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
 
 
 

chhil

unread,
Nov 14, 2012, 1:17:03 AM11/14/12
to jpos-...@googlegroups.com
Hi,
I see you have not been able to move forward.

Some basics:

When you configure a server you place a ISORequestListener element in it.
The element has the following properties that can be configured

<property name="space" value="tspace:default" />
<property name="queue" value="use_a_string_that_the_TM_waits_on" />

Now your request listener needs to process the data and put the
request in a special object called Context. Context is a name value
pair structure (see code for details). Its used for passing
information throughout the system.
Then it needs to put this context in the space configured above. You
can get the space by SpaceFactory.getSpace (cfg.get ("space"));
While putting the value in the space use the key as the queue property
configured in the listener.

Now moving onto the transaction manager. We somehow need to link the
space as a property in the TM configuration, so that it knows which
space and what key to use to get the context and pass it on to its
participants.

The TransactionManager has properties that need to be configured
<property name="space" value="tspace:default" /><!--same as what was
configured in iso request listener-->
<property name="queue" value="use_a_string_that_the_TM_waits_on" />
<!--same as what was configured in iso request listener-->

So what the Transaction Manager does is (see code for better
understanding), its waiting in a loop to grab an entry place in the
space with the queue name. Although this queue name is a string, the
way spaces work is that if multiple values are placed in the same key
those values are queued and the TM picks them in the FIFO order and
hands them off to each participant in the order it is is configured in
the transaction manager xml file (group selectors are not talked about
here, lets get the basics working).

I had referenced some pdfs earlier, if you read those then you will
have a good understanding on how spaces work by now.

If you can draw your components out and see how they link to each
other will be beneficial for you, rather doing it brute force.

-chhil

anil jaladi

unread,
Nov 14, 2012, 1:51:25 AM11/14/12
to jpos-...@googlegroups.com
Hi Chhil,

As you suggested

I added some properties to My ISORequestlitener when configuring my server.

In the same server config file I added the Transaction Manager Properties .

And After in my request listener process() method i put the message and source in the context as below.

Context ctx = new Context ();
        ctx.put (REQUEST, m);
        ctx.put (ISOSOURCE, source);

Then next step is add the context to space

sp.out (MyTxnQueue, ctx);

Mytxnqueue can not be resolved in above statement.

MYTxnQueue is queue property VALUE IN the requestlistener configuration.

My problem here is

While i am trying to get the space  by Space sp = SpaceFactory.getSpace (cfg.get ("space"));

cfg i am unable to resolve and i am not getting the configured space.

Please help me

Thanks
Anil Kumar J

Chhil

unread,
Nov 14, 2012, 2:19:08 AM11/14/12
to jpos-...@googlegroups.com
Comments inline.

-chhil

On 14-Nov-2012, at 12:21 PM, anil jaladi <jala...@gmail.com> wrote:

Hi Chhil,

As you suggested

I added some properties to My ISORequestlitener when configuring my server.
Could you be more specific and paste "some" properties?
Also provide the deploy file name.
The nameregistrar object has a static dump that gives you a list of objects that can be accessed. Most helper methods directly or indirectly get objects from this. Dumping it will give you an idea of what is already available.

In the same server config file I added the Transaction Manager Properties .
Add a new deploy file for your transaction manager. A sample can be found at http://jpos.org/blog/page/2/
Get this in place and then move forward. If you haven't purchased the programmers guide, you should.
Another blog that you should start following is www.andyorrock.com

anil jaladi

unread,
Nov 14, 2012, 2:34:10 AM11/14/12
to jpos-...@googlegroups.com
Hi

My deploy file name is : server_conf.xml

The configuration what i did in this is..

<?xml version="1.0" ?>
<server name="manam-server" class="org.jpos.q2.iso.QServer" logger="Q2">
<attr name="port" type="java.lang.Integer">8000</attr>
<attr name="minSessions" type="java.lang.Integer">20</attr>
<attr name="maxSessions" type="java.lang.Integer">250</attr>

<channel name="manam.channel" class="com.manam.minar.iso.MinarChannel"
         packager="com.manam.minar.iso.MinarPackager"
         logger="minar" realm="minar-channel"
         header="ISO00011">
</channel>

<request-listener class="com.manam.minar.iso.MinarListener" logger="Q2">

<property name="space"   value="tspace:default" />
 <property name="queue"   value="MyTxnQueue" />
</request-listener>

<txnmgr name="MyTxn" logger="Q2" class="org.jpos.q2.transaction.TransactionManager">

<property name="space" value="tspace:default" />
<property name="queue" value="MyTxnQueue" />
<property name="persistent-space" value="jdbm:MyTxnSpace" />
<property name="sessions" value="32" />
<participant class="com.manam.minar.iso.ProcessRequest" logger="Q2" >
</participant>
</txnmgr> -->
</server>

And i want to implement the processing logic in participiant class here ProcessRequest . is it right way to do like this?

From my RequestListener class after adding the context to space how can i do this one.?

Thanks

Anil Kumar J

chhil

unread,
Nov 14, 2012, 2:47:53 AM11/14/12
to jpos-...@googlegroups.com
Split the files.
10_server_conf.xml


<server name="manam-server" class="org.jpos.q2.iso.QServer" logger="Q2">
<attr name="port" type="java.lang.Integer">8000</attr>
<attr name="minSessions" type="java.lang.Integer">20</attr>
<attr name="maxSessions" type="java.lang.Integer">250</attr>

<channel name="manam.channel" class="com.manam.minar.iso.MinarChannel"
packager="com.manam.minar.iso.MinarPackager"
logger="minar" realm="minar-channel"
header="ISO00011">
</channel>

<request-listener class="com.manam.minar.iso.MinarListener" logger="Q2">

<property name="space" value="tspace:default" />
<property name="queue" value="MyTxnQueue" />
</request-listener>

</server>

20_txnmgr_conf.xml

<?xml version="1.0" ?>
<txnmgr name="MyTxn" logger="Q2"
class="org.jpos.q2.transaction.TransactionManager">

<property name="space" value="tspace:default" />
<property name="queue" value="MyTxnQueue" />
<property name="persistent-space" value="jdbm:MyTxnSpace" />
<property name="sessions" value="32" />
<participant class="com.manam.minar.iso.ProcessRequest" logger="Q2" >
</participant>
</txnmgr>

Your participant ProcessRequest needs to implement the
TransactionParticipant interface and implement your logic in the
prepare.
The transaction manager reads through its xml file and then calls the
participants prepare method.(please step through source code to
understand intricacies).

-chhil

anil jaladi

unread,
Nov 14, 2012, 3:49:50 AM11/14/12
to jpos-...@googlegroups.com
Hi

I divided the configuration file as you suggested by you.

Then i implemented the registered ISORequestListener in 10_server_cnf.xml as below in this case MinarListener.

public class MinarListener implements ISORequestListener , Configurable{

   
    private String queueName;
    protected Space<String, Context>  sp;

    public static final String REQUEST = "REQUEST";
    public static final String ISOSOURCE = "ISOSOURCE";
        
        public MinarListener()
        {
            super();
        }
       
        @Override
        public void setConfiguration(Configuration cfg)
                throws ConfigurationException {
           
           
            queueName = cfg.get("queue");
            System.out.println("------------------"+queueName);

           
             sp =  SpaceFactory.getSpace (cfg.get ("space"));   
           
            System.out.println("space--------------"+sp.toString());
           
        }
       
        public boolean process (ISOSource source, ISOMsg m) {
            System.out.println("Processed method--------");

        Context ctx = new Context ();
        System.out.println("keeping the message in request");
        ctx.put (REQUEST, m);
       
        System.out.println("keeping the source in the ISOSource");
        ctx.put (ISOSOURCE, source);
        System.out.println("adding the context to space");
        sp.out (queueName, ctx);
        return true;
        }

       
    }

After doing this i am getting into the process method and all print statements are working fine.

previously i had implemented the my logic(if a balance request comes i use to call a handler based on request and send the response back) in the process method and it worked fine.

With the help of transaction manager how can i achieve the above logic.

Thanks
Anil Kumar J

chhil

unread,
Nov 14, 2012, 4:38:11 AM11/14/12
to jpos-...@googlegroups.com
Remember that pdf that I keep referencing time and again called
jpos-ee.pdf also found here http://jpos.org/doc/jPOS-EE.pdf (please
click and download).
chapter 7 page 21/22 a sensible copy and paste of the DemoParticipant
should help you complete your assignment.
You need a a lot of hand holding even after all the resources that
have been made available to proceed.


Give a man a fish and you feed him for a day. Teach a man to fish and
you feed him for a lifetime.

Its time for me to stop giving you the fish :)

Best of luck!

-chhil

anil jaladi

unread,
Nov 14, 2012, 7:01:19 AM11/14/12
to jpos-...@googlegroups.com
Hi Chhil,

I Downloaded the PDF and i gone through and finally i got the response for my request.

Thanks for your help .

chillum

unread,
Nov 14, 2012, 7:01:44 AM11/14/12
to jpos-...@googlegroups.com, anil jaladi
No, Thank You!!! :)

-chhil
Reply all
Reply to author
Forward
0 new messages