Call class that extends MuxQBean from a regular class

39 views
Skip to first unread message

Victor Shoaga

unread,
Jan 10, 2022, 10:56:38 AM1/10/22
to jPOS Users
Please, how do I call a class that extends MuxQBean from a regular class.

My goal is to be able to use my Rest setup to communicate with that class.

Looking forward to your reply

Thank you

murtuza chhil

unread,
Jan 10, 2022, 8:27:35 PM1/10/22
to jPOS Users
JPOS qbeans are registered in a static instance of NameRegistrar.

QMUX.getMUX("<your mux name>")

The mux name is the name you provided in the mux deploy file. 


You can see how the QMUX.get uses the NameRegistrar in the background here https://github.com/jpos/jPOS/blob/master/jpos/src/main/java/org/jpos/q2/iso/QMUX.java#L121-L125

(MUX) NameRegistrar.get ("mux."+name)

jpos add the "mux." prefix to the mux name while registering.


If its a custom Qbean then your bean should register the instance in the static Nameregistrar object (name, this) at initService. Then you can access the NameRegistrar from anywhere and use it. Remember to unregister it at destroyService time so that no one can use it.

You would do something similar to

NameRegistrar.register ("mux."+getName (), this);

https://github.com/jpos/jPOS/blob/master/jpos/src/main/java/org/jpos/q2/iso/QMUX.java#L94


You can read the section on NameRegistrar in the programmer's guide http://jpos.org/doc/proguide-draft.pdf


Victor Shoaga

unread,
Jan 11, 2022, 2:35:01 PM1/11/22
to jPOS Users
Thank you very much

Please, I want to ask again;

Is it okay to have a regular class that extends QBeanSupport to be setup this way....
My concern is the global scopes in a concurrent environment.

Please, what do u think?

public class Pool extends QBeanSupport implements PoolMBean, Runnable {

        private DownloadRequestService downloadRequestService;
        private RZList allTerms;
        private final HashMap<PoolCategory, RZList> activeLiquidityProviderTerminalIds = new HashMap<>();
        private int numberOfWorkerThreads;
        private List<String> serialNumbers = new ArrayList<>();
        private List<Thread> workerThreads = new ArrayList<>();

        private final Random RANDOM = new SecureRandom();

        @Override
       public void initService() throws Exception {

        }

}


 

chhil

unread,
Jan 11, 2022, 7:29:09 PM1/11/22
to jpos-...@googlegroups.com

QBeanSupport simply provides the framework for jpos Q2 to call various methods on it (init/start/stop etc) , its just another standard java class.
For concurrent usage you need to follow standard java concurrency practices, and nothing changes here.

JPOS components like muxes and spaces are thread safe, your custom beans acess need to be developed to be threadsafe.
Writing threadsafe java code is beyond the scope of jpos support.

-chhil



--
--
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 a topic in the Google Groups "jPOS Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jpos-users/Es0GbveGFTw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jpos-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jpos-users/975d3e52-86fd-4071-b821-ddd849176345n%40googlegroups.com.

Victor Shoaga

unread,
Jan 11, 2022, 8:32:45 PM1/11/22
to jPOS Users
Thanks Chhil

Really appreciate.
Reply all
Reply to author
Forward
0 new messages