Pasted code below:
private static string _readmq = string.Empty;
public MQQueueManager _mQMgr;
public static MQMessage _retrievedMessage;
public MQQueue _mOutputQueue;
private MQMessage _mqsMsg;
private MQGetMessageOptions _mGetOptions;
private void button2_Click(object sender, EventArgs e)
{
try
{
Hashtable connection = InitilizeMQConnection1();
_mQMgr = new MQQueueManager(_mqManager, connection);
const int outOpenOptions = MQC.MQOO_INPUT_AS_Q_DEF |
MQC.MQOO_FAIL_IF_QUIESCING;
_mOutputQueue = _mQMgr.AccessQueue(_readmq, outOpenOptions);
string strResponseMessage = string.Empty;
for (int i = 0; i < 10; i++)
{
strResponseMessage = GetMessage();
}
}
catch (MQException ex)
{
string errorMsg = "Message : " + ex.Message + "error code :" + ex.ReasonCode;
richTextBox1.Text = errorMsg;
fileWriteline(errorMsg);
filelog.Flush();
}
}
private Hashtable InitilizeMQConnection1()
{
try
{
Hashtable connection = new Hashtable
{
{ MQC.HOST_NAME_PROPERTY, _mqHost },
{ MQC.CHANNEL_PROPERTY, _mqChannel },
{ MQC.PORT_PROPERTY, Convert.ToInt64(_mqPort) },
{ MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES_MANAGED }
// { MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES_CLIENT }
};
//connection.Add(MQC.USER_ID_PROPERTY, MQUserID);
return connection;
}
catch (Exception ex)
{
string errorMsg = "Message : " + ex.Message;
richTextBox1.Text = errorMsg;
fileWriteline(errorMsg);
filelog.Flush();
return null;
}
}
public string GetMessage()
{
string msgText = string.Empty;
try
{
_mGetOptions = new MQGetMessageOptions
{
WaitInterval = m_TmeOut,
};
_mGetOptions.Options |= MQC.MQGMO_FAIL_IF_QUIESCING | MQC.MQGMO_WAIT;
_mOutputQueue.Get(_retrievedMessage, _mGetOptions);
msgText = _retrievedMessage.ReadString(_retrievedMessage.MessageLength);
return msgText;
}
catch (MQException ex)
{
string errorMsg = string.Format("MQ Adapter:Get Message. Exception: Message [{0}], Source [{1}, Reason [{2}], Stack trace [{3}]", ex.Message, ex.Source, ex.Reason,ex.StackTrace.ToString());
fileWriteline(errorMsg);
return msgText;
}
catch (Exception ex)
{
string errorMsg = "An error occured " + ex.Message;
}
return msgText;
}
------------------------------
Achyuth Reddy
------------------------------
Original Message:
Sent: Mon April 19, 2021 02:23 AM
From: Shashikanth Rao Thambrahalli
Subject: From Azure Web Job .Net Appplication Connecting to IBM MQ
Can you show us the complete code? I think that would help in diagnosing the problem.
------------------------------
Shashikanth Rao Thambrahalli
IBM
Original Message:
Sent: Mon April 19, 2021 02:11 AM
From: Achyuth Reddy
Subject: From Azure Web Job .Net Appplication Connecting to IBM MQ
Dear Shashi,
I removed the code _retrievedMessage.CorrelationId still no luck, Any other idea?
------------------------------
Achyuth Reddy
Original Message:
Sent: Mon April 19, 2021 01:00 AM
From: Shashikanth Rao Thambrahalli
Subject: From Azure Web Job .Net Appplication Connecting to IBM MQ
You have specified MQC.MQMO_MATCH_CORREL_ID as the match option. But are you setting the required correlationId in _retrievedMessage.CorrelationId before calling Get method? That could be possible reason for 2026 reason code.
------------------------------
Shashikanth Rao Thambrahalli
IBM
Original Message:
Sent: Mon April 19, 2021 12:49 AM
From: Achyuth Reddy
Subject: From Azure Web Job .Net Appplication Connecting to IBM MQ
Dear Shashi,
I consumed the above sent nuget package but am getting an error "MQRC_MD_ERROR, 2026" while reading message from the queue.
the below code to read message from the queue, am facing error at _mOutputQueue.Get method:
_mGetOptions = new MQGetMessageOptions
{
WaitInterval = m_TmeOut,
MatchOptions = MQC.MQMO_MATCH_CORREL_ID
};
_mGetOptions.Options |= MQC.MQGMO_FAIL_IF_QUIESCING | MQC.MQGMO_WAIT;
_mOutputQueue.Get(_retrievedMessage, _mGetOptions);
msgText = _retrievedMessage.ReadString(_retrievedMessage.MessageLength);
Thanks for the Help.
------------------------------
Achyuth Reddy
Original Message:
Sent: Thu April 15, 2021 11:30 AM
From: Shashikanth Rao Thambrahalli
Subject: From Azure Web Job .Net Appplication Connecting to IBM MQ
The package you pointed out is not from IBM. I suggest you to use the official MQ .NET package from IBM which is named IBMMQDotnetClient as described here. The package from IBM gets updated regularly with latest one being v 9.2.2 - https://www.nuget.org/packages/IBMMQDotnetClient.
------------------------------
Shashikanth Rao Thambrahalli
IBM
Original Message:
Sent: Thu April 15, 2021 07:33 AM
From: Achyuth Reddy
Subject: From Azure Web Job .Net Appplication Connecting to IBM MQ
Dear Shashi,
In .Net Nuget Package this libraries are available so am planning to use this libraries instead of amqmdnetstd.dll.
------------------------------
Achyuth Reddy
Original Message:
Sent: Thu April 15, 2021 05:07 AM
From: Shashikanth Rao Thambrahalli
Subject: From Azure Web Job .Net Appplication Connecting to IBM MQ
I am bit confused. Initially you mentioned .NET, now you mention JDK. If your application is .NET, then you will need to use MQ .NET libraries.
------------------------------
Shashikanth Rao Thambrahalli
IBM
Original Message:
Sent: Thu April 15, 2021 05:00 AM
From: Achyuth Reddy
Subject: From Azure Web Job .Net Appplication Connecting to IBM MQ
Thanks for the reply.
Am using the stand alone IKVM.OpenJDK dll (Standalone dll's) is this fine to connect it?
or any specific Nuget Package?
------------------------------
Achyuth Reddy
Original Message:
Sent: Thu April 15, 2021 02:31 AM
From: Shashikanth Rao Thambrahalli
Subject: From Azure Web Job .Net Appplication Connecting to IBM MQ
You don't need the entire MQ client installation, you can just use the MQ .NET Client from NuGet.
------------------------------
Shashikanth Rao Thambrahalli
IBM
Original Message:
Sent: Wed April 14, 2021 03:10 AM
From: Achyuth Reddy
Subject: From Azure Web Job .Net Appplication Connecting to IBM MQ
Dear Team,
I created a .Net Application, this application I hosted in Azure Web Job, from the Web job I connecting to
IBM MQ(to read read the message from the queue).
Without MQ Client Installation can we establish the connection from the remote to the IBM MQ Server?
Is MQ Client mandatory or prerequisites for .Net Application to connect MQ Server?
------------------------------
Achyuth Reddy
------------------------------