I have a doubt about task

6 views
Skip to first unread message

Jaime Vizán González

unread,
Dec 7, 2009, 7:13:40 PM12/7/09
to jpos-...@googlegroups.com
Hi, I need get the ISOMsgs from two channel adaptors. In a first moment I thought develop a new class which implemented Runnable interface to use <task> tag but, finally, I decided to define two QBeans. One of this is primary QBean and the other one is secondary QBean. The code of these classes is the same. The problem is in the start method. I show the next snippet:

public synchronized void start() {
super.start();
ISOMsg isoMsg = null;
Space sp = SpaceFactory.getSpace();
//while (sp.rd(this.channelAdaptorName + ".ready") != null) {
while(true){
isoMsg = (ISOMsg) sp.in(this.channelAdaptor.getOutQueue());

If I use a call to the space sp int the QBeans, the primary QBean is ok, but the secondary QBean isn't able to execute this method. I don't get any error and warning. I don`t know which could be the reason of this behavior. I have solved this problem implementing the Runnable interface in the QBeans and I have put the code of start method in run method. Could anybody give me an explication of this?

Thanks in advance

Alejandro Revilla

unread,
Dec 7, 2009, 7:51:34 PM12/7/09
to jpos-...@googlegroups.com
You are blocking the 'start()' method, you should start your Runnable in a new thread.

2009/12/7 Jaime Vizán González <jaime...@gmail.com>

Jaime Vizán González

unread,
Dec 8, 2009, 3:21:48 AM12/8/09
to jpos-...@googlegroups.com
I can imagine what happens, the start method is blocked, but why? Could the using of any call to Space in start method to block all the QBeans in my application?

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

Mark Salter

unread,
Dec 8, 2009, 4:10:55 AM12/8/09
to jpos-...@googlegroups.com
Jaime Viz�n Gonz�lez wrote:
> I can imagine what happens, the start method is blocked, but why?

Jaime Viz�n Gonz�lez wrote previously:
>> while(true){
>> isoMsg = (ISOMsg) sp.in(this.channelAdaptor.getOutQueue());

How long will your code above run for? This currently prevents a call
to start() from completing...

--
Mark

Jaime Vizán González

unread,
Dec 8, 2009, 6:18:09 AM12/8/09
to jpos-...@googlegroups.com

El 08/12/2009, a las 10:10, Mark Salter escribió:

> Jaime Vizán González wrote:
>> I can imagine what happens, the start method is blocked, but why?
>
> Jaime Vizán González wrote previously:
>>> while(true){
>>> isoMsg = (ISOMsg) sp.in(this.channelAdaptor.getOutQueue());
>
> How long will your code above run for? This currently prevents a call
> to start() from completing...

always, it will be active while the channel adaptor exists and it is ready. With this code the state of primary QBean is started and the second QBean is stopped. It isn't able to call the start method.

>
> --
> Mark

Alejandro Revilla

unread,
Dec 8, 2009, 7:10:23 AM12/8/09
to jpos-...@googlegroups.com
Your start() method never returns, that's your problem. You need to implement Runnable, have a 'public void run()' method and call
new Thread(this).start() from your start method, and promptly return.

2009/12/8 Jaime Vizán González <jaime...@gmail.com>
Reply all
Reply to author
Forward
0 new messages