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 » MQ C# 2018 Error

Post new topic  Reply to topic
 MQ C# 2018 Error « View previous topic :: View next topic » 
Author Message
robertjenkin
PostPosted: Fri Nov 12, 2004 7:16 am    Post subject: MQ C# 2018 Error Reply with quote

Newbie

Joined: 12 Nov 2004
Posts: 2

Hello all..

I have a simple c# program to get messages from queue. I need to get messages from MQ within transaction so I am executing Begin and Commit methods to control the transaction. When ever I execute Begin I get an 2018 error. Without the Begin/Commit statements all works. Any ideas or hints would be greatly appreicated.

Following is the class code I am currently using.

public class MQInterface
{
private MQQueueManager mqQMgr;
private MQQueue mqQueue;
private MQGetMessageOptions mqGetMsgOpts;
private MQMessage mqMsg;
private bool bConnected = false;
private bool bTransaction = false;

public MQInterface() {}

public bool Connect(string mqQueueMgr, string mqQueueName, string mqChannel) {
// determine how to connect
string[] parts;
char[] separator = {'/'};
string channelname = "";
string transporttype = "";
string connectionname = "";

// connect to queue manager
try {
if (mqChannel.Length > 0) {
parts = mqChannel.Split(separator);
if (parts.Length>0) channelname = parts[0];
if (parts.Length>1) transporttype = parts[1];
if (parts.Length>2) connectionname = parts[2];
mqQMgr = new MQQueueManager(mqQueueMgr,channelname,connectionname);
} else {
if (mqQueueMgr.Length>0) {
mqQMgr = new MQQueueManager(mqQueueMgr);
} else {
mqQMgr = new MQQueueManager();
}
}
} catch (MQException ex) {
bConnected = false;
throw ex;
}

try {
mqQueue = mqQMgr.AccessQueue(mqQueueName,MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQOO_FAIL_IF_QUIESCING);
} catch (MQException ex) {
bConnected = false;
throw ex;
}

mqGetMsgOpts = new MQGetMessageOptions();
mqGetMsgOpts.Options = MQC.MQGMO_WAIT;
mqGetMsgOpts.WaitInterval = 15 * 1000;
mqGetMsgOpts.MatchOptions = MQC.MQMO_NONE;
bConnected = true;
return (bConnected);
}

public void Disconnect() {
mqQueue.Close();
mqQMgr.Disconnect();
bTransaction = false;
bConnected = false;
}

public bool Begin() {
try {
mqQMgr.Begin();
bTransaction = true;
return (true);
} catch (MQException ex) {
throw ex;
}
}

public bool Commit() {
try {
mqQMgr.Commit();
bTransaction = false;
return (true);
} catch (MQException ex) {
throw ex;
}
}

public bool RollBack() {
try {
mqQMgr.Backout();
bTransaction = false;
return (true);
} catch (MQException ex) {
throw ex;
}
}

public bool Process(ref string sMessage) {
if (!bConnected) {
sMessage = "";
return (false);
}
try {
mqMsg = new MQMessage();
mqMsg.Format=MQC.MQFMT_STRING;
try {
mqQueue.Get(mqMsg, mqGetMsgOpts);
sMessage = mqMsg.ReadString(mqMsg.MessageLength);
} catch(MQException e) {
if (e.Reason == MQC.MQRC_NO_MSG_AVAILABLE) {
sMessage = "";
return (false);
} else {
throw e;
}
}
} catch(MQException e) {
throw e;
}
return (true);
}
}
Back to top
View user's profile Send private message Send e-mail
robertjenkin
PostPosted: Fri Nov 12, 2004 8:13 am    Post subject: All ready resolved it.. Reply with quote

Newbie

Joined: 12 Nov 2004
Posts: 2

The issue was caused by lack of sync point
Back to top
View user's profile Send private message Send e-mail
kirani
PostPosted: Fri Nov 12, 2004 10:55 am    Post subject: Reply with quote

Jedi Knight

Joined: 05 Sep 2001
Posts: 3779
Location: Torrance, CA, USA

Also, you are using "Begin" keyword in your code. It's needed for doing 2-phase commit only. For local UOW you can use Syncpoint option.
_________________
Kiran


IBM Cert. Solution Designer & System Administrator - WBIMB V5
IBM Cert. Solutions Expert - WMQI
IBM Cert. Specialist - WMQI, MQSeries
IBM Cert. Developer - MQSeries

Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ API Support » MQ C# 2018 Error
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.