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 » XMS.NET type initializer error

Post new topic  Reply to topic
 XMS.NET type initializer error « View previous topic :: View next topic » 
Author Message
cpeele
PostPosted: Wed Apr 04, 2007 7:51 am    Post subject: XMS.NET type initializer error Reply with quote

Acolyte

Joined: 04 Apr 2007
Posts: 53

Hey guys,

I am writing a C# app with XMS.NET directly translated from that nice IronPython/XMS.NET example on the web.

I verified that I can publish and subscribe using MQ Explorer but for some reason when I try to do this with my C# app I get the following error:

"The type initializer for 'IBM.XMS.WMQ.WmqConnectionFactory' threw an exception."

Here is my code for the subscriber portion of my app and thanks for the help:

Code:

namespace IronPythonToCSharp_Publisher
{
    class Program
    {
        static void Main(string[] args)
        {
            string host = "localhost";
            string port = "1414";
            string mode = "1";
            string qm = "QM1";

            try
            {
                //create the connection factory
                XMSFactoryFactory ff = XMSFactoryFactory.GetInstance(XMSC.CT_WMQ);

                //use the connection factory factory to create a connection factory
                IConnectionFactory cf = ff.CreateConnectionFactory();

                //set the properties
                cf.SetStringProperty(XMSC.WMQ_HOST_NAME, host);
                cf.SetStringProperty(XMSC.WMQ_PORT, port);
                cf.SetStringProperty(XMSC.WMQ_CONNECTION_MODE, mode);
                cf.SetStringProperty(XMSC.WMQ_QUEUE_MANAGER, qm);

                //create a connection
                IConnection connection = cf.CreateConnection();
                Console.WriteLine("Connection created");

                //create a session
                ISession session = connection.CreateSession(false, AcknowledgeMode.AutoAcknowledge);
                Console.WriteLine("Session created");

                //create a destination
                IDestination destination = session.CreateTopic("topic://xms/test");
                Console.WriteLine("Destination created");

                //create a publisher
                IMessageProducer publisher = session.CreateProducer(destination);
                Console.WriteLine("Publisher created!");

                //start the connection
                connection.Start();

                //create a text message
                IMessage sendMsg = session.CreateTextMessage("Wow! this actually works! ;-)");

                //send the message using the sender
                publisher.Send(sendMsg);
                Console.WriteLine(sendMsg);
                Console.WriteLine("Message sent!");

                //tidy up all the resources
                publisher.Close();
                Console.WriteLine("Publisher closed");

                session.Close();
                Console.WriteLine("Session closed");

                connection.Close();
                Console.WriteLine("Connection closed");

                //we're finished
                Console.WriteLine("Sample execution SUCCESSFUL");
            }
            catch (XMSException e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine("Sample execution FAILED!");
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine("Sample execution FAILED!");
            }           
        }
    }
}

[/code]
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Wed Apr 04, 2007 1:26 pm    Post subject: Reply with quote

Grand High Poobah

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

I think you might want to look into following code:
Quote:
cf.SetStringProperty(XMSC.WMQ_PORT, port);

and
Quote:
ISession session = connection.CreateSession(false, AcknowledgeMode.AutoAcknowledge);

I would expect that to be setIntProperty(XMSC.WMQ.PORT, port)

and I would expect that to be createSession(false, Session.AUTOACKNOWLEDGE) or something of the kind...

But for more security recheck your .NET XMS manual. I'm just looking at if from the JMS point of view.
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
cpeele
PostPosted: Thu Apr 05, 2007 7:01 am    Post subject: Reply with quote

Acolyte

Joined: 04 Apr 2007
Posts: 53

It appears that others from a different forum got it to work for them no problem....so it seems it is something we have configured wrong with the server itself.

I went ahead and installed the required Refresh and Fix packs. Now I am receiving a different error on a different line of code. Thanks again for your help

It happens on this line:
Code:
IDestination destination = session.CreateTopic("topic://xms/test");

Here is the exception information I received:
Code:
{IBM.XMS.XMSException: CWSMQ0006E: An exception was received during the call to the method WmqSession.SetupPubSub: CompCode: 2, Reason: 2085. During execution of the specified method an exception was thrown by another component. See the linked exception for more information.
   at IBM.XMS.WMQ.WmqSession.ThrowExceptionReceived(Object[] messageParams, Exception caughtException, String probeId)
   at IBM.XMS.WMQ.WmqSession.SetUpPubSub(Boolean startCleanup)
   at IBM.XMS.WMQ.WmqSession.CreateTopic(String topicName)
   at IronPythonToCSharp_Subscriber.Program.Main(String[] args) in C:\XMS_NET\IronPythonToCSharp\IronPythonToCSharp_Subscriber\Program.cs:line 41

Linked Exception : CompCode: 2, Reason: 2085}
Back to top
View user's profile Send private message
Vitor
PostPosted: Thu Apr 05, 2007 7:06 am    Post subject: Reply with quote

Grand High Poobah

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

2085 is a queue not found error (which the Programmer's Reference would have told you).

I would theorise that the subscription queue is either absent, misspelt or in a different case to the one specified in your code.

I'd tend to the last as the most likely...
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
cpeele
PostPosted: Thu Apr 05, 2007 7:10 am    Post subject: Reply with quote

Acolyte

Joined: 04 Apr 2007
Posts: 53

My code only references the Queue manager not an actual queue. But it works for others. The queue name is Q1 and queue manager is QM1.

Is this topic string wrong? topic://xms/test

Should this reference the queue?

Thanks again for your help!

Take care!
Back to top
View user's profile Send private message
Vitor
PostPosted: Thu Apr 05, 2007 7:17 am    Post subject: Reply with quote

Grand High Poobah

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

If you're getting a 2085 your application is referencing a queue (or trying to!)

You'd need to define a subcription point by some means, which would refer to a queue, even if you're not directly referencing the queue.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Thu Apr 05, 2007 7:19 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

I would guess that the queue manager name being supplied on the connection is different than the one being supplied on the topic definition.

And I would think that, actually, both of these should be blank.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
cpeele
PostPosted: Thu Apr 05, 2007 7:27 am    Post subject: Reply with quote

Acolyte

Joined: 04 Apr 2007
Posts: 53

Just to be clear, I have set this up a local machine and am trying to publish and subscribe on the same machine.

I have created a Queue manager named QM1 and a queue named Q1.
I have checked the spelling as well.

No channels have been created.
Default listener is there and hasn't been modified.

Error is: Reason 2085.

Am I missing something I should have configured?

Thanks again, Chris
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Thu Apr 05, 2007 7:32 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

So you created a qmgr, and added a qlocal and are trying to get pub/sub to work?

Yeah, you didn't configure the broker.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
cpeele
PostPosted: Thu Apr 05, 2007 7:34 am    Post subject: Reply with quote

Acolyte

Joined: 04 Apr 2007
Posts: 53

Ok, when I test publishing and subscribing through MQ Explorer I don't recall setting up a broker, I just register a publisher and Subscriber and then create a test topic and it works.

How do I set up a broker?

Thanks!
Back to top
View user's profile Send private message
cpeele
PostPosted: Thu Apr 05, 2007 7:47 am    Post subject: Reply with quote

Acolyte

Joined: 04 Apr 2007
Posts: 53

When I run the command: strmqbrk -m QM1 it says that the broker has been started.

I never "created" a broker in MQ Explorer, but this command is working says the broker is running.

Any Ideas?

Do I need to create a channel even if on a local installation?
Back to top
View user's profile Send private message
EddieA
PostPosted: Thu Apr 05, 2007 11:26 am    Post subject: Reply with quote

Jedi

Joined: 28 Jun 2001
Posts: 2453
Location: Los Angeles

That is the supplied Pub/Sub broker. It's part of the standard MQ V6 install. There's nothing to "create".

Cheers.
_________________
Eddie Atherton
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Thu Apr 05, 2007 11:35 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

http://publib.boulder.ibm.com/infocenter/wmqv6/v6r0/index.jsp?topic=/com.ibm.mq.amqnar.doc/amq622u.htm
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Thu Apr 05, 2007 1:10 pm    Post subject: Reply with quote

Grand High Poobah

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

cpeele wrote:
Just to be clear, I have set this up a local machine and am trying to publish and subscribe on the same machine.

I have created a Queue manager named QM1 and a queue named Q1.
I have checked the spelling as well.

No channels have been created.
Default listener is there and hasn't been modified.

Error is: Reason 2085.

Am I missing something I should have configured?

Thanks again, Chris
Usually in JMS when I get a 2085 it tells me as well which queue it was trying to access so that I can fix the problem.

When I started poking with JMS and the broker
(WMB) it told me a host of queues (SYSTEM.JMS.....) were missing. I managed to get it to work by creating a few aliases and a minimum number of queues...

As well in the Topic definition you want to pass the queue name for the target (if relevant)...

Enjoy
_________________
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 API Support » XMS.NET type initializer error
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.