ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ API Support » Send a Signal from IBM MQ thread

Post new topic  Reply to topic Goto page 1, 2  Next
 Send a Signal from IBM MQ thread « View previous topic :: View next topic » 
Author Message
yasaboy
PostPosted: Sun Aug 03, 2014 9:53 pm    Post subject: Send a Signal from IBM MQ thread Reply with quote

Voyager

Joined: 23 Jun 2014
Posts: 90

Hi,

It seem to be creating a new internal thread from within the IBMMQ connection in my MQCB multi threaded application. So when ever a callback is fired the message is sent from that internal thread created by IBM-MQ itself. But I want this to be the thread that I have created that receives the messages.

How to send a Signal from IBM MQ thread to another thread ?
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Mon Aug 04, 2014 4:14 am    Post subject: Re: Send a Signal from IBM MQ thread Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20696
Location: LI,NY

yasaboy wrote:
Hi,

It seem to be creating a new internal thread from within the IBMMQ connection in my MQCB multi threaded application. So when ever a callback is fired the message is sent from that internal thread created by IBM-MQ itself. But I want this to be the thread that I have created that receives the messages.

How to send a Signal from IBM MQ thread to another thread ?


As I understand it the MQCB is by nature asynchronous and there is little to no probability that the control thread or any thread created by the control thread would be processing the message.

MQ will create its own threads as needed and one of those will be processing the message.

Now it would be helpful if you could fill us in as to why you would need to have a specific thread (that you control) process the message.

Have fun
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
mqjeff
PostPosted: Mon Aug 04, 2014 4:52 am    Post subject: Re: Send a Signal from IBM MQ thread Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

fjb_saper wrote:
yasaboy wrote:
Hi,

It seem to be creating a new internal thread from within the IBMMQ connection in my MQCB multi threaded application. So when ever a callback is fired the message is sent from that internal thread created by IBM-MQ itself. But I want this to be the thread that I have created that receives the messages.

How to send a Signal from IBM MQ thread to another thread ?


As I understand it the MQCB is by nature asynchronous and there is little to no probability that the control thread or any thread created by the control thread would be processing the message.

MQ will create its own threads as needed and one of those will be processing the message.

Now it would be helpful if you could fill us in as to why you would need to have a specific thread (that you control) process the message.

Have fun


There've been a few posts by Paul Clarke on this subject recently.

Good reading for anyone.

MQCB gives you options for whether you let MQ create the thread or whether it uses a thread you create.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Mon Aug 04, 2014 6:44 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20696
Location: LI,NY

Quote:
Do not make any assumptions about the life and availability of the thread other than what is stated. For example, do not rely on a thread staying alive beyond the last call to DEREGISTER. Similarly, when you have chosen not to use THREAD_AFFINITY, do not assume that the thread exists whenever the connection is started.

If your application has particular requirements for thread characteristics, it can always create a thread accordingly, then use MQCTL(WAIT). This has the effect of 'donating' the thread to WebSphere MQ for asynchronous message delivery.

From http://www-01.ibm.com/support/knowledgecenter/SSFKSJ_8.0.0/com.ibm.mq.ref.dev.doc/q101720_.htm?lang=en
Apart from "donating" the thread to MQ, I see no information for any allowed purpose outside of MQ... Do you routinely use thread local variables?
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
yasaboy
PostPosted: Mon Aug 04, 2014 9:08 am    Post subject: Re: Send a Signal from IBM MQ thread Reply with quote

Voyager

Joined: 23 Jun 2014
Posts: 90

fjb_saper wrote:


Now it would be helpful if you could fill us in as to why you would need to have a specific thread (that you control) process the message.

Have fun


I am using a internal thread structure with a message passing mechanism between the threads defined by internally. So in-order to facilitate this action I must pass the message back to the thread that we have created.
Back to top
View user's profile Send private message
yasaboy
PostPosted: Mon Aug 04, 2014 9:10 am    Post subject: Re: Send a Signal from IBM MQ thread Reply with quote

Voyager

Joined: 23 Jun 2014
Posts: 90

[quote="mqjeff"][quote="fjb_saper"]
yasaboy wrote:
Hi,

MQCB gives you options for whether you let MQ create the thread or whether it uses a thread you create.


Its great news hearing that its possible. what are the references on this? how can I do this? I really need to route the message that comes from callback thread to internal thread.. If the above scenario possible please help me figure out the way.. Thanks
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Mon Aug 04, 2014 12:14 pm    Post subject: Re: Send a Signal from IBM MQ thread Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20696
Location: LI,NY

yasaboy wrote:
fjb_saper wrote:


Now it would be helpful if you could fill us in as to why you would need to have a specific thread (that you control) process the message.

Have fun


I am using a internal thread structure with a message passing mechanism between the threads defined by internally. So in-order to facilitate this action I must pass the message back to the thread that we have created.


Well that's telling the how... What we really want to know is the why. There are a lot of ways to fulfill a requirement. What we'd like to know is the what the requirement behind this proposed solution is...
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
yasaboy
PostPosted: Mon Aug 04, 2014 6:18 pm    Post subject: Re: Send a Signal from IBM MQ thread Reply with quote

Voyager

Joined: 23 Jun 2014
Posts: 90

fjb_saper wrote:
yasaboy wrote:
fjb_saper wrote:


Now it would be helpful if you could fill us in as to why you would need to have a specific thread (that you control) process the message.

Have fun


I am using a internal thread structure with a message passing mechanism between the threads defined by internally. So in-order to facilitate this action I must pass the message back to the thread that we have created.


Well that's telling the how... What we really want to know is the why. There are a lot of ways to fulfill a requirement. What we'd like to know is the what the requirement behind this proposed solution is...




Hi,
To explain you why, would be really difficult task, since I have to explain you from the beginning the system.
Just for the moment think that I have a thread A and B and each which are subscribed to set of INQUEUE's and their dedicated OUTQUEUE's. Now callbacks come to thread A. So we have already a implemented structure for sending the received message to thread B.

Why send it to Thread B? well it's because of multiple reasons. First it's to handle the MQPUT as a separate task since the performance aspect of the thread that receives the callback. So what are my options to make this work ? thanks
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Mon Aug 04, 2014 6:58 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20696
Location: LI,NY

A nice different way of increasing some of the throughput? Either way at some point you're going to hit a max in resources and a bottle neck somewhere... thread pool, other resources etc....

The traditional answer to this type of problem has been to grow the available thread pool (at least in JMS). You will have to test this, but I thought that part of the call back was to internally handle that hand off from the "browser" thread to the consuming threads... Don't know what any other hand off would give you, as you cannot acknowledge successful processing before the processing is actually done...

Have fun
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
yasaboy
PostPosted: Mon Aug 04, 2014 7:54 pm    Post subject: Reply with quote

Voyager

Joined: 23 Jun 2014
Posts: 90

@Grand Poobah

The method you have mentioned above works. When I use MQOP_START_WAIT on MQCTL it users our main thread rather than creating a one of its own.

Code:
MQCTL(Hcon, MQOP_START_WAIT, &ctlo, &CompCode, &Reason);


But the problem is that the Thread waits on the QUEUE itself and doesn't have the ability to make Callbacks to different Queues from within one thread. If there are X,Y,Z Queues to be listening to the callbacks from thread A, it hangs up on Queue X, without progressing further ? Can we handle this problem ?
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Mon Aug 04, 2014 11:07 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20696
Location: LI,NY

yasaboy wrote:
@Grand Poobah

The method you have mentioned above works. When I use MQOP_START_WAIT on MQCTL it users our main thread rather than creating a one of its own.

Code:
MQCTL(Hcon, MQOP_START_WAIT, &ctlo, &CompCode, &Reason);


But the problem is that the Thread waits on the QUEUE itself and doesn't have the ability to make Callbacks to different Queues from within one thread. If there are X,Y,Z Queues to be listening to the callbacks from thread A, it hangs up on Queue X, without progressing further ? Can we handle this problem ?

The model is such that you need a different thread for each queue. If you have message affinity, I suggest that you simply MQGET the relevant message off of queue Y and Z using the thread from queue X.

If the order is not relevant but you need to aggregate, you'd be better off using IIB than just MQ... Alternatively you could build a pattern like IIB does, but that would get awfully complicated now when it is prebuilt for you in IIB and WMB...

Have fun
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
yasaboy
PostPosted: Mon Aug 04, 2014 11:15 pm    Post subject: Reply with quote

Voyager

Joined: 23 Jun 2014
Posts: 90

Hi,

Our model has multiple threads and each thread subscribing to multiple queues.

Code:
Thread_1 => Q1, Q2, Q3
Thread_2 => Q4, Q5, Q6
Thread_3 => Q7, Q8, Q9, Q10


Each thread must be our internal threads not the threads created by MQCTL. Is there anyway of doing this other than MQOP_START_WAIT

It seems like its impossible to do this with WAIT since it waits on thread_1 CALLBACKS. Is there any alternative solution to prevent MQCB creating a new thread ? Please help.
Back to top
View user's profile Send private message
PaulClarke
PostPosted: Tue Aug 05, 2014 12:47 am    Post subject: Reply with quote

Grand Master

Joined: 17 Nov 2005
Posts: 1002
Location: New Zealand

Yasaboy,

Can you explain in a little more detail about why MQOP_START_WAIT is not suitable ?

With MQOP_START_WAIT you can register multiple queues to 'listen' on. You issue MQCTL(MQOP_START_WAIT) and from that point any messages arriving on ANY of the queues will drive the registered callback. Clearly you can not have multiple callbacks invoked at the same time since you only have one thread but it is not the case that it get's blocked reading one queue.

Essentially....what did you mean by....

Quote:
If there are X,Y,Z Queues to be listening to the callbacks from thread A, it hangs up on Queue X, without progressing further ?


Cheers,
Paul.
_________________
Paul Clarke
MQGem Software
www.mqgem.com
Back to top
View user's profile Send private message Visit poster's website
yasaboy
PostPosted: Tue Aug 05, 2014 12:58 am    Post subject: Reply with quote

Voyager

Joined: 23 Jun 2014
Posts: 90

PaulClarke wrote:


Quote:
If there are X,Y,Z Queues to be listening to the callbacks from thread A, it hangs up on Queue X, without progressing further ?

'

Hi paul, I could resolve the above issue. Since there are now multi threads in the system like

Thread_1 => Q1, Q2, Q3
Thread_2 => Q4, Q5, Q6
Thread_3 => Q7, Q8, Q9, Q10
'
Now when thread 1 starts it does following,

Code:


func()
{
       MQCONN(QMName, &Hcon, &CompCode, &CReason);

       for(number of queues Q1, Q2 , Q3)
       {
               MQOPEN(Hcon, &od, O_options, &Hobj, &OpenCode, &Reason);
               MQCB(Hcon, MQOP_REGISTER, &cbd, Hobj, &md, &gmo, &CompCode, &Reason);
   
        }

        MQCTL(Hcon, [color=red]MQOP_START_WAIT[/color], &ctlo, &CompCode, &Reason);

}


Now what should happens next is Thread 2 should start and do the above for its queues Q4,Q5 and Q6.

But here as I have used MQOP_START_WAIT it hangs up on thread 1. Thread 2 doesn't start.


What should I do ?
Back to top
View user's profile Send private message
PaulClarke
PostPosted: Tue Aug 05, 2014 1:01 am    Post subject: Reply with quote

Grand Master

Joined: 17 Nov 2005
Posts: 1002
Location: New Zealand

You haven't included the code you use for starting the threads so it's a little difficult to answer for you. Perhaps you could show us where you are starting the threads.
_________________
Paul Clarke
MQGem Software
www.mqgem.com
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic  Reply to topic Goto page 1, 2  Next Page 1 of 2

MQSeries.net Forum Index » IBM MQ API Support » Send a Signal from IBM MQ thread
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.