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 » MQSeries and .NET

Post new topic  Reply to topic Goto page Previous  1, 2
 MQSeries and .NET « View previous topic :: View next topic » 
Author Message
jefflowrey
PostPosted: Thu Mar 24, 2005 6:10 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

something's wrong with your code.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
greg
PostPosted: Thu Mar 24, 2005 6:42 am    Post subject: Reply with quote

Novice

Joined: 24 Mar 2005
Posts: 20

My code looks like follow:

using System;
using IBM.WMQ;

namespace MQSeries
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class MQSeriesClass
{
/// <summary>
/// The main entry point for the application.
/// </summary>
MQQueueManager queueManager;
MQQueue queue;
MQMessage queueMessage;
MQPutMessageOptions queuePutMessageOptions;
MQGetMessageOptions queueGetMessageOptions;

static string QueueName;
static string QueueManagerName;
static string ChannelInfo;

string channelName;
string transportType;
string connectionName;

string message;

static void Main(string[] args)
{
//
// TODO: Add code to start application here
//
MQSeriesClass mqSeries = new MQSeriesClass();
mqSeries.putTheMessageIntoQueue();
mqSeries.GetMessageFromTheQueue();

Console.ReadLine();

}

public void putTheMessageIntoQueue()
{
QueueName = "QUEUE.TEST";
QueueManagerName = "TVTEST";
channelName = "SVRCONN.TEST";
transportType = "TCP";
connectionName = "10.0.0.99(1115)";
try
{
queueManager = new MQQueueManager( QueueManagerName, channelName, connectionName );
queue = queueManager.AccessQueue( QueueName, MQC.MQOO_OUTPUT + MQC.MQOO_FAIL_IF_QUIESCING );
Console.WriteLine("Enter the message to put in MQSeries server:");
message = System.Console.ReadLine();
int msgLen = message.Length;

while(msgLen == 0)
{
if(msgLen == 0)
Console.WriteLine("Please reenter the message:");
message = System.Console.ReadLine();
msgLen = message.Length;
}


queueMessage = new MQMessage();
queueMessage.WriteString( message );
queueMessage.Format = MQC.MQFMT_STRING;
queuePutMessageOptions = new MQPutMessageOptions();

//putting the message into the queue
queue.Put( queueMessage, queuePutMessageOptions );

Console.WriteLine("Success fully entered the message into the queue");
}
catch(MQException mqexp)
{
Console.WriteLine( "MQSeries Exception: " + mqexp.Message );
}
}

public void GetMessageFromTheQueue()
{

queue = queueManager.AccessQueue( QueueName, MQC.MQOO_INPUT_AS_Q_DEF + MQC.MQOO_FAIL_IF_QUIESCING );
queueMessage = new MQMessage();
queueMessage.Format = MQC.MQFMT_STRING;
queueGetMessageOptions = new MQGetMessageOptions();

try
{
queue.Get( queueMessage, queueGetMessageOptions );

// Received Message.
System.Console.WriteLine( "Received Message: {0}", queueMessage.ReadString(queueMessage.MessageLength));

}
catch (MQException MQExp)
{
// report the error
System.Console.WriteLine( "MQQueue::Get ended with " + MQExp.Message );
}
}

}
}

All name of QM, Q, channel ark correct.
Back to top
View user's profile Send private message
Michael Dag
PostPosted: Thu Mar 24, 2005 9:04 am    Post subject: Reply with quote

Jedi Knight

Joined: 13 Jun 2002
Posts: 2607
Location: The Netherlands (Amsterdam)

to test your configuration use the supplied sample programs like amqsputc.exe this way you know you did the config right.
Then start using your own code to see what is wrong with it.

but first do the obvious and use one of the working samples!
_________________
Michael



MQSystems Facebook page
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
JT
PostPosted: Thu Mar 24, 2005 10:14 am    Post subject: Reply with quote

Padawan

Joined: 27 Mar 2003
Posts: 1564
Location: Hartford, CT.

greg wrote:
On machine_1(66.0.0.66(1215)) I created:
QM - QM_machine
Q - DEFAULT_LOCAL_QUEUE
CH - SERVER.CHANNEL

greg wrote:
Ok, one more time...
On machine_1 I have MQSeries Server and Client.
I created
-queue manager: TVTEST
-queue : TEST.QUEUE (loacl queue)
-server connection channel: SVRCONN

greg wrote:
I made mestake, the channel name was: SVRCOON, not SVRCONN.

greg wrote:
I defined :
MQSERVER SVRCONN/TCP/10.0.0.10(1111)

greg wrote:
public void putTheMessageIntoQueue()
{
QueueName = "QUEUE.TEST";
QueueManagerName = "TVTEST";
channelName = "SVRCONN.TEST";
transportType = "TCP";
connectionName = "10.0.0.99(1115)";


I'm so confused.......... What channel is actually defined to the queue manager, and is that the channel you've coded for?
Back to top
View user's profile Send private message
kevinf2349
PostPosted: Thu Mar 24, 2005 11:28 am    Post subject: Reply with quote

Grand Master

Joined: 28 Feb 2003
Posts: 1311
Location: USA

Confusing? I'll say....which port is it that your queue manager is listening on. So far I count 3 different values that are coded for it 1111, 1115 1215.

Maybe if you posted the output from a display it may help....I suspect that your code is throwing a null reference because the connection handle isn't being returned.

I usually wrap my MQCalls in their own exception handling clause. You have all yours in one big 'try'. Just an idea to help debug.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Goto page Previous  1, 2 Page 2 of 2

MQSeries.net Forum Index » IBM MQ API Support » MQSeries and .NET
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.