TransactionManager and its Participants

1,005 views
Skip to first unread message

ImixTools

unread,
Dec 3, 2013, 12:15:57 PM12/3/13
to jpos-...@googlegroups.com
Hi, I'm new to the implementation of JPOS and I have some doubts about the use of the participants such as:

- How to implement a participants?
- When a participant is working?
- What is the function of groups of participants in the TransactionManager?

It would be helpful to i provide an example in which participants implement with some purpose.

Thank you very much beforehand.

Alejandro Revilla

unread,
Dec 3, 2013, 12:28:27 PM12/3/13
to jPOS Users

In order to implement a TransactionParticipant you need to add implements TransactionParticipant to your class, and implement the prepare, commit and abort method. It’s very simple. If you extend the txn module from jPOS-EE, you could extend TxnSupport instead and get advantage of some handy helper methods implemented by it.

This link can give you some ideas on how we use the TransactionManager in one of our applications. There are many other examples in the net, including some very good ones provided by Andy Orrock (http://www.andyorrock.com/) in his excellent blog.

PS.- \o/ don’t tell Andy, but I’m praising his blog so we can get him back blogging… :)



--
@apr


--
--
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
 
Join us in IRC at http://webchat.freenode.net/?channels=jpos
 
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
---
You received this message because you are subscribed to the Google Groups "jPOS Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jpos-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jpos-users/bc64d9ac-f86c-4e69-9b78-c9afe62ea48e%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Alejandro Revilla

unread,
Dec 3, 2013, 12:41:36 PM12/3/13
to jpos-...@googlegroups.com

ImixTools

unread,
Dec 3, 2013, 3:13:13 PM12/3/13
to jpos-...@googlegroups.com

Thank you very much for answering Alejandro, I have seen some articles that blog but I have some doubts, since I've managed to configure the TransactionManager this:

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

<property name="space"   value="tspace:default" /> //this means?
<property name="queue"   value="MyTxnQueue" /> //this means?
<property name="persistent-space" value="jdbm:MyTxnSpace" /> //this means?
<property name="sessions" value="32" /> //this means?
<property name="debug" value="true" /> //this means?
<property name="retry-interval" value="100" /> //this means?

<participant class="solidda.switchs.datafono.participant.TestParticipant" logger="Q2" />

</txnmgr>

And thus the listener

<server name="xml-server" class="org.jpos.q2.iso.QServer">

<attr name="port" type="java.lang.Integer">29520</attr>
<attr name="minSessions" type="java.lang.Integer">5</attr>
<attr name="maxSessions" type="java.lang.Integer">5</attr>

<channel name="client.channel" class="org.jpos.iso.channel.ASCIIChannel"
packager="org.jpos.iso.packager.GenericPackager" logger="Q2">this means?(logger="Q2")
<property name="packager-config" value="iso-8583-movilred.xml" />
<property name="debug" value="true" />

</channel>
<request-listener class="datafono.listener.MainListener">
<property name="debug" value="true" />
</request-listener>
<keep-alive>yes</keep-alive>
</server>

But I not have certainty that participant running

package solidda.switchs.datafono.participant;

import java.io.Serializable;

import org.jpos.iso.ISOMsg;
import org.jpos.iso.ISOSource;
import org.jpos.transaction.Context;
import org.jpos.transaction.TransactionParticipant;
import org.jpos.util.Logger;
import org.jpos.util.SimpleLogListener;
public class TestParticipant implements TransactionParticipant { 

    public void abort(long id, Serializable context) { 
            System.out.println("ParticipantTest Process aborted"); 
    } 

    public void commit(long id, Serializable context) { 
        Context ctx=(Context)context; 
        ISOMsg msg=(ISOMsg)ctx.get("ORIGINAL"); 
        ISOSource source=(ISOSource)ctx.get("ISOSOURCE"); 
        try { 
        source.send(msg); 
        } catch(Exception e) { 
        e.printStackTrace(); 
        } 
        System.out.println("Committing the participantTest process"); 
    } 

    public int prepare(long id, Serializable context) { 
        Context ctx=(Context)context; 
        ISOMsg msg=(ISOMsg)ctx.get("SEND"); 
        Logger logger=new Logger(); 
        logger.addListener (new SimpleLogListener (System.out)); 
        ISOSource source=(ISOSource)ctx.get("ISOSOURCE"); 
        try { 
        msg.set(39,"00"); 
        source.send(msg); 
        } catch(Exception e) { 
        e.printStackTrace(); 
        } 
        return PREPARED; 
    } 


Thank :D

chhil

unread,
Dec 3, 2013, 3:29:35 PM12/3/13
to jpos-users
One way to go about this is to look at the TransactionManager source code and see how these properties get utilized.

Learn about some concepts of space etc.


<property name="space"   value="tspace:default" /> //this means?
Its a special data structure read more about how it functions from the pdfs above.

<property name="queue"   value="MyTxnQueue" /> //this means?
A space can have multiple queues, which are fifo based, so to get values from the queue you need a name, this is the one that provides the name that another entity say an isorequestlistener has put the entry on it.

<property name="persistent-space" value="jdbm:MyTxnSpace" /> //this
means?
Space can be in memory or persistent (file based db) based on your need, if you want data to be available across restarts then use a persistent one.
<property name="sessions" value="32" /> //this means?
How many values from the queue will be picked up and processed simultaneously through the participants(in parallel).
<property name="debug" value="true" /> //this means?
<property name="retry-interval" value="100" /> //this means?
This one I dont know :)

-chhil





chhil

unread,
Dec 3, 2013, 4:33:14 PM12/3/13
to jpos-users

ImixTools

unread,
Dec 10, 2013, 9:37:51 AM12/10/13
to jpos-...@googlegroups.com
chhil,

I appreciate your help, I managed to implement and understand the TM and its participants.

Thank you very much! : D
Reply all
Reply to author
Forward
0 new messages