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 » WebSphere Message Broker (ACE) Support » atomic block and additional instances query

Post new topic  Reply to topic
 atomic block and additional instances query « View previous topic :: View next topic » 
Author Message
ec10024
PostPosted: Thu Jun 30, 2016 3:44 am    Post subject: atomic block and additional instances query Reply with quote

Novice

Joined: 30 Jun 2016
Posts: 15

I am trying with a simple flow to increment the count which is a shared variable and total instances being 2.As it is not differentiating the instances and considering only one thread because of which I am getting updated count value.

DECLARE count SHARED INTEGER 0;

CREATE COMPUTE MODULE Input_No_MQMD_Compute
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
Val:BEGIN ATOMIC
SET count= count+1;
SET OutputRoot.XMLNSC.count =count;
END Val;

RETURN TRUE;
END;

Can anyone help me in understanding the ATOMIC and instances behavior?
Back to top
View user's profile Send private message
mqjeff
PostPosted: Thu Jun 30, 2016 4:01 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

Atomic means that the operation only happens in one place at a time. If some other place tries to do the same operation at the same time, it waits until it's free.

But that doesn't mean that you enter the second atomic block (which has to wait) *after* the first atomic block completes.

So:
instance 1: Count = 0
instance 2: Count = 0
Instance 1: enter atomic with count = 0
Instance 2 : wait for atomic with count = 0
instance 1: exit atomic with count = 1
instance 2: enter atomic with count = 0
_________________
chmod -R ugo-wx /
Back to top
View user's profile Send private message
ec10024
PostPosted: Thu Jun 30, 2016 4:11 am    Post subject: Reply with quote

Novice

Joined: 30 Jun 2016
Posts: 15

but in my case I am getting

count = 1
count = 2
count = 3
count = 4
count = 5

which was not the expectation from me in case of multiple instances.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Thu Jun 30, 2016 4:14 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

What was your expectation?

It's a shared variable. There's only one copy of it in all instances of the flow in the same EG.

The 1,2,3,4,5 behavior is what I thought you wanted...

But there is still the scenario I mention where it's not set that way.

Although it is early and the coffee hasn't kicked in, so the scenario I outlined might not be possible.
_________________
chmod -R ugo-wx /
Back to top
View user's profile Send private message
ec10024
PostPosted: Thu Jun 30, 2016 4:17 am    Post subject: Reply with quote

Novice

Joined: 30 Jun 2016
Posts: 15

suppose If I run 4 messages at a time .how can I get count values to be 1,2,1,2 on declaring count as SHARED variable
Back to top
View user's profile Send private message
mqjeff
PostPosted: Thu Jun 30, 2016 4:26 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

ec10024 wrote:
suppose If I run 4 messages at a time .how can I get count values to be 1,2,1,2 on declaring count as SHARED variable


Do something other than add one to it each time.
_________________
chmod -R ugo-wx /
Back to top
View user's profile Send private message
agrawalamit166
PostPosted: Thu Jun 30, 2016 2:37 pm    Post subject: Reply with quote

Voyager

Joined: 17 Aug 2009
Posts: 78
Location: NY, US

ec10024 wrote:
suppose If I run 4 messages at a time .how can I get count values to be 1,2,1,2 on declaring count as SHARED variable


Add condition in ATOMIC block

if 2 then make that 1.
Back to top
View user's profile Send private message Yahoo Messenger
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » atomic block and additional instances query
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.