|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
  |
|
How to call MQSeries from .Net |
View previous topic :: View next topic |
Author |
Message
|
sasikumar_83 |
Posted: Mon Jun 09, 2008 8:15 am Post subject: How to call MQSeries using .Net Application |
|
|
Newbie
Joined: 09 Jun 2008 Posts: 1
|
Hi,
I installed IBM MQSeries v6.0 in my Laptop and I developed .Net Application using c# to Put/Get Message from MQSeries. I mentioned all the values like
QueueManager, QueueName, ChannelName, Port Number and hostname. If I tried this scenario in my machine its works fine.
If I put the application in separate machine (which is in the same network). And tried the same scenario, Its giving one of the error like as follow
1) Error Code : 2035 “Authorization required for the QueuManager” i.e) its requiring Userid and password.
2) Error Code : 2059 “No connection established with QueueManager”.
The same scenario can be achieved by using Java. In Both local and Network Machine its works fine. I need solution in .Net.
I have given complete code below which i'm trying:
const string connectionType = MQC.TRANSPORT_MQSERIES_MANAGED;
public static Hashtable init(String connectionType)
{
Hashtable connectionProperties = new Hashtable();
connectionProperties.Add(MQC.TRANSPORT_PROPERTY, connectionType);
switch (connectionType)
{
case MQC.TRANSPORT_MQSERIES_BINDINGS:
break;
case MQC.TRANSPORT_MQSERIES_CLIENT:
case MQC.TRANSPORT_MQSERIES_XACLIENT:
case MQC.TRANSPORT_MQSERIES_MANAGED:
connectionProperties.Add(MQC.HOST_NAME_PROPERTY, hostName); ;
connectionProperties.Add(MQC.CHANNEL_PROPERTY, channel);
break;
}
return connectionProperties;
}
public void PutMessageInQueue()
{
try
{
Hashtable connectionProperties = init(connectionType);
MQQueueManager putQManager = new MQQueueManager(qManager, connectionProperties);
int openOptions = MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQOO_OUTPUT;
MQQueue putQueue = putQManager.AccessQueue("default", openOptions);
MQMessage putMessage = new MQMessage();
putMessage.WriteString(putMessage1.Text.Trim());
putMessage.Format = MQC.MQFMT_STRING;
putMessage1.Clear();
MQPutMessageOptions putMessageOption = new MQPutMessageOptions();
putQueue.Put(putMessage, putMessageOption);
putQManager.Disconnect();
}
catch (MQException mqException)
{
MessageBox.Show(mqException.ToString());
}
catch (Exception generalException)
{
MessageBox.Show(generalException.ToString());
}
}
public void GETMessageInQueue()
{
try
{
Hashtable connectionProperties = init(connectionType);
MQQueueManager outQManager = new MQQueueManager(qManager, connectionProperties);
int openOptions = MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQOO_OUTPUT ;
MQQueue outQueue = outQManager.AccessQueue("default", openOptions);
MQMessage retrievedMessage = new MQMessage();
retrievedMessage.Format = MQC.MQFMT_STRING;
MQGetMessageOptions getMessageOption = new MQGetMessageOptions();
outQueue.Get(retrievedMessage, getMessageOption);
//String msgText = retrievedMessage.ReadUTF();
textBox1.Text += retrievedMessage.ReadString(retrievedMessage.MessageLength).ToString() + " Received" + Environment.NewLine;
outQueue.Close();
outQManager.Disconnect();
}
catch (MQException mqException)
{
MessageBox.Show(mqException.ToString());
}
catch (Exception generalException)
{
MessageBox.Show(generalException.ToString());
}
}
Please help me, I don't know much about MQSeries, I did all the above code frm searching in google.
Thanks
S. Ramkumar  |
|
Back to top |
|
 |
fjb_saper |
Posted: Mon Jun 09, 2008 1:33 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
The essential difference between .NET and java is the way the username/password thing is being handled on a client connection.
You have seen the answers you got.
So make sure the user is added to the relevant security groups (They did setup security at a group level for MQ and not at an individual level right?)
Have the MQ admin run "refresh security" and try again...
Work with the MQAdmin on your site  _________________ MQ & Broker admin |
|
Back to top |
|
 |
|
|
  |
|
Page 1 of 1 |
|
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
|
|
|
|