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 IndexIBM MQ API SupportHow to set .NET C# IBM.XMS.MQC.MQCFUNC_MQPUT1

Post new topicReply to topic Goto page Previous  1, 2
How to set .NET C# IBM.XMS.MQC.MQCFUNC_MQPUT1 View previous topic :: View next topic
Author Message
fjb_saper
PostPosted: Wed Jul 15, 2020 8:57 am Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20394
Location: LI,NY

Gergo2020 wrote:
Thanks for all the help,
I tried Alias, but unfortunately the same error came.

Is it possible to modify the MQOD in the XMS API?
Thank you very much!


How ? Show us the code that defines the queue off the session and show us the code that does the put...
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Gergo2020
PostPosted: Thu Jul 16, 2020 1:47 am Post subject: Reply with quote

Novice

Joined: 25 Jun 2020
Posts: 13

I'd like this:

Code:

var destination2 = Session.CreateQueue(string.Format("queue://{0}/{1}?PUT1=1&ObjectName ={0}&ObjectQMgrName={1}", remoteQM, remoteQ));
  var msg = Session.CreateTextMessage(message);
  var producer = Session.CreateProducer(null);
  producer.Send(destination2,msg);


Unfortunately, I couldn't find any .NET XMS API documentation for this.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Thu Jul 16, 2020 5:12 am Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20394
Location: LI,NY

Gergo2020 wrote:
I'd like this:

Code:

var destination2 = Session.CreateQueue(string.Format("queue://{0}/{1}?PUT1=1&ObjectName ={0}&ObjectQMgrName={1}", remoteQM, remoteQ));
  var msg = Session.CreateTextMessage(message);
  var producer = Session.CreateProducer(null);
  producer.Send(destination2,msg);


Unfortunately, I couldn't find any .NET XMS API documentation for this.

too much together in 1 line
set the string format on its own line populating a string variable.
print out the content of the string variable for debug control, and use it in Session.CreateQueue...


_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Gergo2020
PostPosted: Thu Jul 16, 2020 6:58 am Post subject: Reply with quote

Novice

Joined: 25 Jun 2020
Posts: 13

Why so much? Is the syntax not good? I don't understand why you wrote these.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Fri Jul 17, 2020 6:05 am Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20394
Location: LI,NY

Gergo2020 wrote:
Why so much? Is the syntax not good? I don't understand why you wrote these.

Because the value might not be what you think it is, and the way you wrote it, you have no way to control it in a debug step... Trust ... but verify...
Did you start the session after creating it?
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Gergo2020
PostPosted: Tue Aug 04, 2020 5:56 am Post subject: Reply with quote

Novice

Joined: 25 Jun 2020
Posts: 13

I hope this will make it more transparent
test app MQ codes:
Code:


using IBM.XMS;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.Remoting.Messaging;
using System.Windows.Forms;
using System.Collections;
namespace MQTest
{
    public class MQ_Manager : IDisposable
    {
        public XMSFactoryFactory XMSfactoryFactory;
        public IConnectionFactory Connectionfactory;
        private IConnection Connection;
        public ISession Session;
        public bool MqConnected;
        private IMessageProducer Producer;
        private static IDestination Destination;

        public void Disconnect()
        {
            if (Connection != null)
            {

                Connection.Stop();
            }
        }
        public string Connect(string username, string password, string ip, int port, int reconnectTime, string qmName, string chName, string queueIn)
        {

            try
            {
                //Create connection
                XMSfactoryFactory = XMSFactoryFactory.GetInstance(XMSC.CT_WMQ);
                Connectionfactory = XMSfactoryFactory.CreateConnectionFactory();

                // Connectionfactory.SetStringProperty(XMSC.WMQ_QUEUE_MANAGER, qmName);
                Connectionfactory.SetStringProperty(XMSC.WMQ_HOST_NAME, ip);
                Connectionfactory.SetIntProperty(XMSC.WMQ_PORT, port);
                Connectionfactory.SetStringProperty(XMSC.WMQ_CHANNEL, chName);
                Connectionfactory.SetIntProperty(XMSC.WMQ_BROKER_VERSION, XMSC.WMQ_BROKER_V2);
                Connectionfactory.SetIntProperty(XMSC.WMQ_CONNECTION_MODE, XMSC.WMQ_CM_CLIENT_UNMANAGED);

                // In case of network issues - reconnect to same queue manager
                Connectionfactory.SetIntProperty(XMSC.WMQ_CLIENT_RECONNECT_OPTIONS, XMSC.WMQ_CLIENT_RECONNECT_Q_MGR);
                Connectionfactory.SetStringProperty(XMSC.WMQ_CONNECTION_NAME_LIST, String.Format("{0}({1})", ip, port));
                Connectionfactory.SetIntProperty(XMSC.WMQ_CLIENT_RECONNECT_TIMEOUT, reconnectTime); ;

                if (!string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password))
                {
                    Connection = Connectionfactory.CreateConnection(username, password);
                }
                else
                {
                    Connection = Connectionfactory.CreateConnection();
                }
                Connection.ExceptionListener = new ExceptionListener(XMSExceptionHandler);

                Connection.Start();
                MqConnected = true;


                return "Connection ok!";
            }
            catch (XMSException e)
            {
                CheckConnection(e);

                return e.ToString();
            }
            catch (Exception e)
            {
                return e.ToString();
            }
        }

        public string SendMessage(string message, string localQ, string remoteQM, string remoteQ)
        {
            try
            {
                Session = Connection.CreateSession(true, AcknowledgeMode.ClientAcknowledge);

                var subString = string.Format("queue://{0}/{1}?PUT1=1&ObjectName={1}&ObjectQMgrName={0}", remoteQM, remoteQ);
                var destination2 = Session.CreateQueue(subString);
                var msg = Session.CreateTextMessage(message);

                var producer = Session.CreateProducer(null);
                producer.Send(destination2, msg);

                return msg.ToString();
            }
            catch (XMSException e)
            {
                CheckConnection(e);
                return e.ToString();
            }
            catch (Exception e)
            {
                return e.ToString();
            }
        }
    }

    public class Teszt
    {
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                var fn = txbFileName.Text;
                File.WriteAllText(lastFileName, fn);

                using (MQ_Manager mq = new MQ_Manager())
                {
                    var msg = File.ReadAllText(fn, Encoding.UTF8);

                    try
                    {
                        mq.Connect("", "", txbAddress.Text, Convert.ToInt32(txbPort.Text), 1000, txbQueueManager.Text, txbChannel.Text, txbQueueName.Text);
                        var result = mq.SendMessageWithId(msg, txbQueueName.Text, remoteQMtb.Text, remoteQtb.Text);

                        mq.Session.Commit();
                        mq.Session.Close();
                    }
                    catch (XMSException ex)
                    {
                        richTextBox1.AppendText(MQ_Manager.GetExceptionDetails(ex) + "\r\n\r\n");
                    }
                }
            }
            catch (Exception ex)
            {

                richTextBox1.AppendText(ex.ToString() + "\r\n\r\n");
            }
        }
    }
}
Back to top
View user's profile Send private message
Display posts from previous:
Post new topicReply to topic Goto page Previous  1, 2 Page 2 of 2

MQSeries.net Forum IndexIBM MQ API SupportHow to set .NET C# IBM.XMS.MQC.MQCFUNC_MQPUT1
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.