IBM MQSeries Accessing Issue from .NET

I am not very familiar with the IBM MQSeries, but I write C # scripts that write and read files from my queue server. The problem is that my works are being read, but my recording is not working. Please note that I use the same queue, so do not worry about going in that direction.

My code first accesses MQserver with the following code:

MQQueueManager qManager;
MQQueue queue;
MQMessage queueMessage;
MQGetMessageOptions queueGetMessageOptions;
MQPutMessageOptions queuePutMessageOptions;

string QueueName;

public MQAccess(string queueName, string queueManager, string connection, string channel)
{
    QueueName = queueName;

    qManager = new MQQueueManager(queueManager, channel, connection);

    queue = qManager.AccessQueue(QueueName, MQC.MQOO_INPUT_AS_Q_DEF + MQC.MQOO_FAIL_IF_QUIESCING);
}

I can read files from my queue using this code:

public bool NextMessage(ref string message, ref DateTime putDateTime)
{
    queueMessage = new MQMessage();
    queueMessage.Format = MQC.MQFMT_STRING;
    queueGetMessageOptions = new MQGetMessageOptions();

    queueGetMessageOptions.Options = MQC.MQOO_INPUT_AS_Q_DEF + MQC.MQOO_FAIL_IF_QUIESCING;

    try
    {
        queue.Get(queueMessage, queueGetMessageOptions);
    }
    catch (MQException mqex)
    {
        if (mqex.ReasonCode == MQC.MQRC_NO_MSG_AVAILABLE)
        {
            message = "";
            return false;
        }
        else
            throw mqex;
    }
    message = queueMessage.ReadString(queueMessage.MessageLength);
    putDateTime = queueMessage.PutDateTime;

    if (message.StartsWith("´╗┐"))
    {
        message = message.Substring(3, message.Length - 3);
    }

    return true;
}

If I try to write with the following code, it will give me errors:

public void WriteMessage(string message)
{
    queueMessage = new MQMessage();
    queueMessage.WriteString(message);
    queueMessage.Format = MQC.MQFMT_STRING;
    queuePutMessageOptions = new MQPutMessageOptions();

    queue.Put(queueMessage, queuePutMessageOptions);
}

My error causes an error:

Application error

This, of course, does not show. So I checked the event log on the server and this showed me an error:

An error occurred while retrieving data from stx041774 (192.168.225.51) TCP / IP. This may be due to communication failure.

TCP/IP (recv) 10054 (X'2746 '). .

10054 :

.

- , , ? , MQC, ? , , , .

, , :

public void Close()
{
    queueMessage = null;
    queue.Close();
    qManager.Close();
}

~MQAccess()
{
    queueMessage = null;
    queue.Close();
    qManager.Close();
}
+3
3

, . , , open, . .

+1

, , put

queuePutMessageOptions = MQC.MQOO_OUTPUT + MQC.MQOO_FAIL_IF_QUIESCING

- , .

+1

Perhaps looking at this article on CodeProject , in connection with the MSMQ protocol, the article implements a chat system.

Hope this helps, Regards, Tom.

-2
source

Source: https://habr.com/ru/post/1730997/


All Articles