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 » MQ 7.5 XMS .NET Sync communition, how can implement?

Post new topic  Reply to topic
 MQ 7.5 XMS .NET Sync communition, how can implement? « View previous topic :: View next topic » 
Author Message
kugynok
PostPosted: Tue Jul 22, 2014 1:44 am    Post subject: MQ 7.5 XMS .NET Sync communition, how can implement? Reply with quote

Newbie

Joined: 21 Jul 2014
Posts: 7

Hi all!

I am fairly new to mq.

I use to XMS , .NET 4.5 I made an async mode and work well... I wanna make sync communication, but I don't know how can. Please help me!

Thank You!

K
Back to top
View user's profile Send private message
IanAlderson
PostPosted: Tue Jul 22, 2014 4:47 am    Post subject: Reply with quote

Novice

Joined: 23 Apr 2014
Posts: 17

Hi,
For synchronous mode you do not use a message listener but instead use one of the Receive methods (wait, infinite wait or no wait) of the MessageConsumer object. You should be able to find suitable documentation in the online Knowledge Center or take a look at the SampleConsumerCS sample program which has an example of both the asynchronous and synchronous consumers.
Back to top
View user's profile Send private message
kugynok
PostPosted: Tue Jul 22, 2014 9:31 pm    Post subject: Reply with quote

Newbie

Joined: 21 Jul 2014
Posts: 7

Hi IanAlderson!

Why should not I use? (a message listener)

Here is my code, how I can modify?

Code:
public ITextMessage GetMessage(string qmName, string queuOut)
        {
            try
            {
               
                if (Session == null)
                {
                    Session = Connection.CreateSession(true, AcknowledgeMode.ClientAcknowledge);
                }
                Destination = Session.CreateQueue(string.Format("queue://{0}/{1}", qmName, queuOut));
                Destination.SetIntProperty(XMSC.WMQ_TARGET_CLIENT, XMSC.WMQ_TARGET_DEST_MQ);
                Destination.SetStringProperty(XMSC.JMS_IBM_FORMAT, MQC.MQFMT_STRING);
                var consumer = Session.CreateConsumer(Destination);

                var message = consumer.ReceiveNoWait();
                consumer.Close();
                consumer.Dispose();
                return message as ITextMessage;
            }
            catch (XMSException e)
            {
                Console.WriteLine(e.ToString());
                return null;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                return null;
            }

        }


I think this line can modify:

Code:
var message = consumer.ReceiveNoWait(); //orig
var message = consumer.Receive(3000); //changed


but, how I find the reply message?

Thank you for help me!

K.
Back to top
View user's profile Send private message
IanAlderson
PostPosted: Wed Jul 23, 2014 2:05 am    Post subject: Reply with quote

Novice

Joined: 23 Apr 2014
Posts: 17

The message listener registers a method that is invoked (asynchronously) when a message arrives on the queue. The Receive method blocks until it returns. ReceiveNoWait returns immediately whether a message is available or not, Receive(3000) returns after 3 seconds or when a message is available and read from the queue, whichever is the sooner.

What error are you seeing in your program?

Try using the ImessageConsumer and IMessage objects rather than var.
Back to top
View user's profile Send private message
kugynok
PostPosted: Wed Jul 23, 2014 2:51 am    Post subject: Reply with quote

Newbie

Joined: 21 Jul 2014
Posts: 7

Thanks for the information!

var not problem, I could modifying the code and work well, but I dont get a reply message. How can use the message selector?

My code:

Code:
 var correlId = "JMSCorrelationID='SOKPOK'";

send message object:
Code:
msg.JMSMessageID = correlId;


reply message object:
Code:
var consumer = Session.CreateConsumer(Destination, correlId);
                var message = consumer.Receive(waitTime);


What did I do wrong?

Thank You for help me!

K
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Wed Jul 23, 2014 5:03 am    Post subject: Reply with quote

Grand High Poobah

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

wrong sequence of things...


  1. send message
  2. get messagid (it was set during the send)
    String msgid = msg.getJMSMessageId();
  3. build selector
    String sel="JMSCorrelID='" + msgid + "'";
  4. create receiver with selector
  5. receive message or time out (remember sent message has to be committed before starting this step.
  6. close / discard receiver
  7. done


Have fun
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
kugynok
PostPosted: Wed Jul 23, 2014 11:50 pm    Post subject: Reply with quote

Newbie

Joined: 21 Jul 2014
Posts: 7

Thank You!

Now works well!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ API Support » MQ 7.5 XMS .NET Sync communition, how can implement?
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.