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 » How to set .NET C# IBM.XMS.MQC.MQCFUNC_MQPUT1

Post new topic  Reply to topic Goto page 1, 2  Next
 How to set .NET C# IBM.XMS.MQC.MQCFUNC_MQPUT1 « View previous topic :: View next topic » 
Author Message
Gergo2020
PostPosted: Thu Jun 25, 2020 4:08 am    Post subject: How to set .NET C# IBM.XMS.MQC.MQCFUNC_MQPUT1 Reply with quote

Novice

Joined: 25 Jun 2020
Posts: 15

Hi all!

Please help me.
I need to set IBM.XMS.MQC.MQCFUNC_MQPUT1 option.
destination.SetStringProperty("???", IBM.XMS.MQC.MQCFUNC_MQPUT1);

I want to use MQOD with two parametes
ObjectName = ReplyToQ
ObjectQMgrName = ReplyToQMgr

How can implement this?

Thank You!
Back to top
View user's profile Send private message
Vitor
PostPosted: Thu Jun 25, 2020 4:28 am    Post subject: Re: How to set .NET C# IBM.XMS.MQC.MQCFUNC_MQPUT1 Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

Gergo2020 wrote:
How can implement this?


With code, I'd recommend C# syntax as this will fit in well with the rest of your C# code.

Seriously.

If that's what you want to do, do that. If you've tried that and it's not worked, post what you've tried and why the results were not acceptable or we'll likely suggest the same thing.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Thu Jun 25, 2020 4:41 am    Post subject: Reply with quote

Grand High Poobah

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

As you're using XMS, did you set the replyto destination before sending the message?
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Gergo2020
PostPosted: Thu Jun 25, 2020 4:46 am    Post subject: Reply with quote

Novice

Joined: 25 Jun 2020
Posts: 15

I dont find examples.

Here is my code (clean version):

Code:

 public IMessage SendMessage(string message)
        {
            try
            {
                if (Connection != null && MqConnected)
                {
                    using (var Session = Connection.CreateSession(true, AcknowledgeMode.ClientAcknowledge))
                    {
                        if (Session != null && MqConnected)
                        {
                            var msg = Session.CreateTextMessage(message);
                            msg.JMSDeliveryMode = DeliveryMode.NonPersistent;
                            IDestination destination = null;
                            destination = Session.CreateQueue(string.Format("queue:///{1}", Parameters.Manager, Parameters.Queue));
                            destination.SetIntProperty(XMSC.WMQ_TARGET_CLIENT, XMSC.WMQ_TARGET_DEST_MQ);
                            destination.SetStringProperty(XMSC.JMS_IBM_FORMAT, IBM.XMS.MQC.MQFMT_STRING);
                            destination.SetStringProperty(XMSC.???, IBM.XMS.MQC.MQCFUNC_MQPUT1);
                           
                            using (var Producer = Session.CreateProducer(destination))
                            {
                                Producer.Send(msg);
                                Producer.Close();
                            }
                       
                            Session.Commit();
                 
                            return msg;
                        }
                        else
                        {
                            throw new Exception("xxx");
                        }
                    }
                }
                else
                {
                    throw new Exception("xxx");
                }
            }
            catch (XMSException e)
            {
                CheckConnection(e);
                return null;
            }
        }
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Thu Jun 25, 2020 4:58 am    Post subject: Reply with quote

Grand High Poobah

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

You're messing with a number of things here:
  • No need to manually specify a format. You created a JMS Text message. By default the format will be MQFMT_STRING.
  • You are creating only one destination, the target. You need to also create a replytodestination in the form of queue://replytoqmgr/replytoqueue[?attribute=value[&attribute=value]] created from the session.
  • before using producer.send(msg) you want to add msg.setReplyTo(replytodestination)
  • No idea where that PUT1 comes from. I'd expect it to happen automatically if you used a form of the send method that includes the destination. For that you may need to create the producer with a null destination...
    producer.send(msg, destination)
Enjoy
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Gergo2020
PostPosted: Thu Jun 25, 2020 5:28 am    Post subject: Reply with quote

Novice

Joined: 25 Jun 2020
Posts: 15

Thanks, I'm starting to understand.
How do I specify properties? Is it necessary at all? What settings are required for a cluster?

Code:

 queue://replytoqmgr/replytoqueue[?targetClient=1] //this valid?
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Thu Jun 25, 2020 10:39 am    Post subject: Reply with quote

Grand High Poobah

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

Gergo2020 wrote:
Thanks, I'm starting to understand.
How do I specify properties? Is it necessary at all? What settings are required for a cluster?

Code:

 queue://replytoqmgr/replytoqueue[?targetClient=1] //this valid?

Yes this would be perfectly valid. Just make sure that the queue is local to the queue manager you're connected to. You can achieve that by omitting the qmgr name:
Code:
queue:///replytoqueue?targetClient=1

And if you're using a replytoqueue alias you really need 3 destinations:
One for the producer
One as the replyto alias to put on the request message
one as the ultimate destination of the reply message to put on the consumer.

Hope it helps
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Gergo2020
PostPosted: Fri Jun 26, 2020 1:00 am    Post subject: Reply with quote

Novice

Joined: 25 Jun 2020
Posts: 15

I try to modify my code:

Code:

 public IMessage SendMessage(string message)
        {
            try
            {
                if (Connection != null && MqConnected)
                {

                    using (var Session = Connection.CreateSession(true, AcknowledgeMode.ClientAcknowledge))
                    {
                        if (Session != null && MqConnected)
                        {
                            var msg = Session.CreateTextMessage(message);

                            msg.JMSDeliveryMode = DeliveryMode.NonPersistent;

                            IDestination destination = null;

                           
                            //replayDest
                            msg.JMSReplyTo = Session.CreateQueue(string.Format("queue://{0}/{1}", ReplyManager, ReplyQueue));

                            //own
                            destination = Session.CreateQueue(string.Format("queue://{0}/{1}?targetClient=1", LocalManager, LocalQueue));

                            IDestination producerdest = null;
                            using (var Producer = Session.CreateProducer(producerdest))
                            {
                                Producer.Send(destination,msg);
                                Producer.Close();
                            }

                            Session.Commit();

                            return msg;
                        }
                        else
                        {
                            throw new Exception("");
                        }
                    }
                }
                else
                {
                    throw new Exception("");
                }
            }
            catch (XMSException e)
            {
                CheckConnection(e);
                return null;
            }
        }


Why need 3 destination? What mean ultimate destination?
I am very grateful for the help. Thanks!
Back to top
View user's profile Send private message
Gergo2020
PostPosted: Fri Jun 26, 2020 3:58 am    Post subject: Reply with quote

Novice

Joined: 25 Jun 2020
Posts: 15

This error came:

Code:

Message: Failed to open MQ queue ESB.SOAPWMQ.REPLYQ.
XMS attempted to perform an MQOPEN, but IBM MQ reported an error.
Use the linked exception to determine the cause of this error. Check that the specified queue and queue manager are defined correctly.
ErrorCode: XMSWMQ2008
Source: IBM.XMS.Client.WMQ
TargetSite: Void CheckNmqiCallSuccess(System.String, IBM.XMS.Client.WMQ.Common.WmqDestination, System.String, Int32, Int32)
Data:
LinkedException.Message: 2085
LinkedException.Source:
LinkedException.TargetSite:
LinkedException.Data:
 
[2020.06.05 13:00:39.905][]
Failed to open MQ queue MQ1.REPLYQ.
XMS attempted to perform an MQOPEN, but IBM MQ reported an error.
Use the linked exception to determine the cause of this error. Check that the specified queue and queue manager are defined correctly.
Failed to open MQ queue ESB.SOAPWMQ.REPLYQ.
XMS attempted to perform an MQOPEN, but IBM MQ reported an error.
Use the linked exception to determine the cause of this error. Check that the specified queue and queue manager are defined correctly.
 
   at IBM.XMS.Client.WMQ.ProducerShadow.CheckNmqiCallSuccess(String messageid, WmqDestination destination, String probeid, Int32 cc, Int32 rc)
   at IBM.XMS.Client.WMQ.SpiIdentifiedProducerShadow.Initialise()
   at IBM.XMS.Client.WMQ.WmqMessageProducer..ctor(WmqSession session, WmqDestination destination, XmsPropertyContext propertyContext)
   at IBM.XMS.Client.WMQ.WmqSession.CreateProducer(ProviderDestination destination, XmsPropertyContext propertyContext)
   at IBM.XMS.Client.Impl.XmsSessionImpl.CreateProducer(IDestination dest)

Back to top
View user's profile Send private message
fjb_saper
PostPosted: Fri Jun 26, 2020 4:32 am    Post subject: Reply with quote

Grand High Poobah

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

looks like your replyto queue has not been defined on the queue manager....

So let's say you need to use a replytoqueuealias because of routing

Code:

   mysession = connection.createSession(autoack, transacted);

   destination1 = mysession.createQueue("queue:///targetq?targetClient=1");
   destination2 = mysession.createQueue("queue:///replytoqalias");
   destination3 = mysession.createQueue("queue:///replytoq");

   msg = mysession.createTextMessage();
   msg.setText("whatever");
   msg.setreplyto(destination2);
   producer = mysession.createProducer(null);
   producer.send(msg, destination1); //send anywhere
   session.commit();
   consumer = mysession.createconsumer(destination3);

   //if not started
   mysession.start();
   replymsg = consumer.receive(timeout)

   //process message
   session.commit();



Hope this little example helps. All 3 queues need to be defined locally to the queue manager you are connected to.

For more information about the replyto queue alias look it up in the infocenter.


_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Gergo2020
PostPosted: Tue Jun 30, 2020 3:48 am    Post subject: Reply with quote

Novice

Joined: 25 Jun 2020
Posts: 15

Unfortunately, I do not have access. I got a remote queue and queue manager that is part of the cluster, but unfortunately I can't put a message. Why is it necessary to have a local queue?

IBM.XMS.IllegalStateException: Failed to send a message to destination PE_TEST.
XMS attempted to perform an MQPUT or MQPUT1; however IBM MQ reported an error.
Use the linked exception to determine the cause of this error.
at IBM.XMS.Client.WMQ.ProducerShadow.CheckNmqiCallSuccess(String messageid, WmqDestination destination, String probeid, Int32 cc, Int32 rc)
at IBM.XMS.Client.WMQ.SpiUnidentifiedProducerShadow.SendInternal(MQMessageDescriptor md, Byte[] buffers, Int32 msgLength)
at IBM.XMS.Client.WMQ.ProducerShadow.Send(WmqDestination destAtSendCall, WmqMessage message)
at IBM.XMS.Client.WMQ.WmqMessageProducer.Send(ProviderDestination destAtSendCall, ProviderMessage message)
at IBM.XMS.Client.Impl.XmsMessageProducerImpl.SendMessage(IMessage message, XmsDestinationImpl dest)
at IBM.XMS.Client.Impl.XmsMessageProducerImpl.Send_(Boolean inIdentifiedContext, XmsDestinationImpl dest, IMessage message, DeliveryMode deliveryMode, Int32 priority, Int64 timeToLive, Boolean explicitDlvModePriorityAndTimeToLive)
at IBM.XMS.Client.Impl.XmsMessageProducerImpl.Send(IDestination dest, IMessage message)
at MQTest.MQ_Manager.SendMessageWithId(String message, String localQ, String remoteQM, String remoteQ)

Linked Exception : CompCode: 2, Reason: 2085

Thank you for helping me!


Code:

public string Connect(string username, string password, string ip, int port, int reconnectTime, string qmName, string chName, string queueIn, string clusterName)
        {

            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);
                if (!string.IsNullOrEmpty(clusterName))
                {
                    Connectionfactory.SetStringProperty(XMSC.WPM_CONNECTION_PROXIMITY_CLUSTER, clusterName);
                }
                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 destination1 = Session.CreateQueue(string.Format("queue:///{0}", localQ));
               var destination2 = Session.CreateQueue(string.Format("queue://{0}/{1}", remoteQM, remoteQ));
               var destination3 = Session.CreateQueue("queue:///replytoq");

               var msg = Session.CreateTextMessage(message);
             // msg.JMSReplyTo =destination2;
              var producer = Session.CreateProducer(null);
              producer.Send(destination2,msg); //send anywhere
              Session.Commit();
                return msg.ToString();
            }
            catch (XMSException e)
            {
                CheckConnection(e);
                return e.ToString();
            }
            catch (Exception e)
            {
                return e.ToString();
            }
        }

Back to top
View user's profile Send private message
Vitor
PostPosted: Tue Jun 30, 2020 5:07 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

Gergo2020 wrote:
Unfortunately, I do not have access. I got a remote queue and queue manager that is part of the cluster, but unfortunately I can't put a message. Why is it necessary to have a local queue?


Ok let's just take a step back for a moment and define some important terms.

In the world of MQ, "local" means the queue manager an application is connected to, "remote" means every other queue manager. It doesn't matter if the queue manager you're connected to is on Mars, it's still your "local" manager.

From this we extend to a QLOCAL definition being the definition of a queue hosted on a given queue manager, a QREMOTE is the definition of a queue hosted somewhere else.

Still with me?

An MQ cluster helps with this as MQ does the work of connecting queue managers and sharing queue definitions, but your application still has a local queue manager it's connected to, even if the queue manager participates in a cluster. This is important, and I'm getting to your problem.

When you put a message, you specify a queue name. That queue name has to exist on your local queue manager. It doesn't matter if it's a QLOCAL, a QREMOTE or a QALIAS but it has to a name the queue manager can find; if it can't it throws a 2085 error.

Now all the aliasing which my associate has quite correctly talked about is potentially necessary to get the message from the local queue manager to wherever it needs to go, for exactly the reasons he gives. But to get a 2085, the queue manager can't find somewhere to put your message.

So, to track back after that little lecture:

Gergo2020 wrote:
I got a remote queue and queue manager that is part of the cluster, but unfortunately I can't put a message. Why is it necessary to have a local queue?


It's necessary to have not a local queue, but a local definition of the remote queue, something to tell your local queue manager what you mean. You're trying to put to a queue called PE_TEST and it doesn't exist on the queue manager you're connected to. That queue manager of yours may participate in a cluster but that don't mean a thing; there's no guarantee that wherever PE_TEST is actually defined it's been shared out as a cluster resource.

Hope that clarifies things a bit.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Tue Jun 30, 2020 11:58 am    Post subject: Reply with quote

Grand High Poobah

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

So what you got is a 2085 queue does not exist.
You have to know that when you supply a queue in the form: queue:///qname the system looks for a local queue.
Create a cluster alias and supply the queue name in form queue://clusteralias/qname. That should fix it.

The cluster alias is a queue remote with rqname = ' '
and rqmname = ' ' and xmitq= ' '.

Enjoy
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Gergo2020
PostPosted: Wed Jul 15, 2020 2:55 am    Post subject: Reply with quote

Novice

Joined: 25 Jun 2020
Posts: 15

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!
Back to top
View user's profile Send private message
Vitor
PostPosted: Wed Jul 15, 2020 4:36 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

Gergo2020 wrote:
Is it possible to modify the MQOD in the XMS API?


Yes - what do you intend to modify it to? Because any value you insert is exactly the same as if you'd changed the MQOD by specifying an alias.

If you changed the destination by specifying an alias and got the same 2085 error, changing the MQOD to that destination via the API will give you a 2085 error.

If you can change the MQOD in the API to a value that does not result in a 2085 error, you can insert the same value into the MQOD using an alias.

It's a much better practice to resolve names through MQ objects as when someone changes or adds a queue, you don't have to alter your code.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Goto page 1, 2  Next Page 1 of 2

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