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 » Is the Environment structure thread safe?

Post new topic  Reply to topic
 Is the Environment structure thread safe? « View previous topic :: View next topic » 
Author Message
klingelb
PostPosted: Thu Oct 10, 2002 2:47 pm    Post subject: Is the Environment structure thread safe? Reply with quote

Apprentice

Joined: 25 Sep 2002
Posts: 28

I have deployed a message flow and specified 100 additional intances.
I need a global variable that is thread safe that I can store a simple counter in. So that each message that comes through the flow
increments this counter by one. I tried storing this counter in a DB2
DB, but the read operation is not blocking so multiple thread read the counter at the same time...not good. I also don't want to make the whole flow transactional, because that would defeat the purpose of bumping up the additional instance count on the message flow. I tried the following:

IF Environment.newtrxnId IS NULL then
SET Environment.newtrxnId = 1;
else
SET Environment.newtrxnId = CAST(Environment.newtrxnId AS INTEGER) + 1;
end IF;

But I found that Environment must not be thread safe because all my newtrxnId were equal to 1. Any Ideas?
Back to top
View user's profile Send private message
TonyD
PostPosted: Thu Oct 10, 2002 10:29 pm    Post subject: Reply with quote

Knight

Joined: 15 May 2001
Posts: 540
Location: New Zealand

The 'Working with Messages' manual states that '... an empty Environment tree is created when a message is received by the input node and parsed....'.
Back to top
View user's profile Send private message Send e-mail
devans
PostPosted: Fri Oct 11, 2002 1:27 am    Post subject: Reply with quote

Apprentice

Joined: 18 Mar 2002
Posts: 43

A new Environment is created for every message read from an MQInput node. It is not a cross thread storage area. It is thread safe, because only one thread can see it! To store information between threads and between messages you ought to use a database. If you make the flow transactional, then your database read will be blocking. This is probably ok performance wise if you can leave the operation as late as possible in your flow.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Is the Environment structure thread safe?
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.