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 Java / JMS » XMS How to create QueueBrowser using C#

Post new topic  Reply to topic
 XMS How to create QueueBrowser using C# « View previous topic :: View next topic » 
Author Message
kun.leeing
PostPosted: Fri Dec 26, 2008 7:56 am    Post subject: XMS How to create QueueBrowser using C# Reply with quote

Disciple

Joined: 27 Sep 2008
Posts: 171

hi, experts. there's a problem about queue browser using C# with XMS.
whatever replace '??' with 'IMessage' or other type, it throws an error 'unable to cast object of type... to type ...'.
Code here

Code:
               
                IDestination iDest;
                iDest = session.CreateQueue("TEMP.LQUEUE");
                IQueueBrowser queue_browser = session.CreateBrowser(iDest);
                connection.Start();

                IEnumerator<??> iterator_msg = (IEnumerator<??>)queue_browser.GetEnumerator();

                while(){
                    ...
                }

No samples can be found in src folder of ia9h,could anybody give an demostration about browsing mesage from a queue ?
Back to top
View user's profile Send private message Send e-mail
fjb_saper
PostPosted: Fri Dec 26, 2008 11:34 am    Post subject: Re: XMS How to create QueueBrowser using C# Reply with quote

Grand High Poobah

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

kun.leeing wrote:
hi, experts. there's a problem about queue browser using C# with XMS.
whatever replace '??' with 'IMessage' or other type, it throws an error 'unable to cast object of type... to type ...'.
Code here

Code:
               
                IDestination iDest;
                iDest = session.CreateQueue("TEMP.LQUEUE");
                IQueueBrowser queue_browser = session.CreateBrowser(iDest);
                connection.Start();

                IEnumerator<??> iterator_msg = (IEnumerator<??>)queue_browser.GetEnumerator();

                while(){
                    ...
                }

No samples can be found in src folder of ia9h,could anybody give an demostration about browsing mesage from a queue ?

Depending on the java version (an I am aware that we are talking c# XMS here) the enumerator is not necessarily typed.
Anyways what you are accessing in your code is an enumerator. so the code would look something like this:
Code:
IEnumerator myenum = (IEnumerator) queue_browser.getEnumerator();
IMessage mymess = null;
While(myenum.hasNext()){
  mymess = (IMessage) myenum.nextElement();
} //endwhile


This is a poor exemple as I am way more fluent in java than in c# but you should get the drift.

Enjoy
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
kun.leeing
PostPosted: Fri Dec 26, 2008 5:42 pm    Post subject: Reply with quote

Disciple

Joined: 27 Sep 2008
Posts: 171

Thanks for your help,saper.

But it seems that it does not work in c#.

There's only a generic type of IEnumerator and can not be converted to IMessage.
Back to top
View user's profile Send private message Send e-mail
mqjeff
PostPosted: Sat Dec 27, 2008 7:41 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

What version of .NET are you trying to use? Are you trying to use a supported version for XMS? Are you sure you are required to specify a generic for the IEnumerator?

It's not as clear from your post if you're having issues using the iterator, or just declaring the generic.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Sat Dec 27, 2008 11:22 am    Post subject: Reply with quote

Grand High Poobah

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

kun.leeing wrote:
Thanks for your help,saper.

But it seems that it does not work in c#.

There's only a generic type of IEnumerator and can not be converted to IMessage.

Excuse me for still not getting it.
An Enumerator interface IEnumerator is as far as I remember a POINTER to the data and as such has no other type.
You want to cast the result of IEnumerator.getNext() to IMessage and not the IEnumerator! .

Trying to cast the IEnumerator to IMessage should get you a ClassCastException at runtime.
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » XMS How to create QueueBrowser using C#
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.