1 2 Previous Next 15 Replies Latest reply on Apr 15, 2007 6:40 PM by John Fawcett

    Using CsIL

    Kurt De Wit Newbie

      Moved from original topic found at:

      http://www.jboss.com/index.html?module=bb&op=viewtopic&t=61886&postdays=0&postorder=asc&start=10


      Hi,

      Great that you responded in such a fast way. It would be nice if everybody answered that fast on different forums :-). I tried the code you provided as an example but I must do something wrong since I'm getting strange error messages from .NET. I provided the stacktrace together with my example below. Any suggestion what I am doing wrong? I followed the installation instruction provided with the installation and tried using a clean JBoss install. I am using Visual Studio .NET 2003 (.NET 1.1 thus) and JBoss 4.0.2 bound to JDK 1.5.0_04. In your documents you reffer to the commons-codec-1.2.jar and castor-0.9.9-wml.jar. Do I have to install these libraries too perhaps? If so, where do I have to place them? Below jboss/server/lib?

      Stacktrace:
      Value cannot be null.
      Parameter name: type
       at System.Activator.CreateInstance(Type type, Boolean nonPublic)
       at System.Activator.CreateInstance(Type type)
       at tamalesoftware.messaging.ConnectionFactory.CreateServerIL()
       at tamalesoftware.messaging.Connection..ctor(AuthenticationRequest pAuth, ConnectionFactory pFact
      ory)
       at tamalesoftware.messaging.ConnectionFactory.CreateConnection(Authentication
      Request pAuth)
       at tamalesoftware.messaging.ConnectionFactory.CreateConnection()
       at JMSTest.JMSTest..ctor() in d:\visual studio projects\jmstest\jmstest\jmstest.cs:line 19
      



      C# code:
      using System;
      using tamalesoftware.messaging;
      using tamalesoftware.jms;
      using tamalesoftware.concurrent;
      
      namespace JMSTest
      {
       class JMSTest
       {
       public JMSTest()
       {
       try
       {
       ConnectionFactory factory = new ConnectionFactory();
       factory.Config.ServerAddress = "192.168.3.120";
       factory.Config.Port = 8094;
       factory.Config.PingPeriod = 10;
       AuthenticationRequest auth = new AuthenticationRequest("admin", "admin");
       Connection conn = factory.CreateConnection();
       conn.Start();
      
       Session session = new Session(conn, AcknowledgementTypes.AUTO_ACKNOWLEDGE);
       Topic topic = conn.CreateTopic("topic/SMCTopic");
       ITopicSubscriber subscribe = session.CreateSubscriber((ITopic)topic);
       subscribe.Listen += new OnMessageEventHandler(doEvent);
       ITopicPublisher publish = session.CreatePublisher((ITopic)topic);
       TextMessage message = new TextMessage();
       message.Text = "Dit is een test.";
       publish.Send(message);
      
       }
       catch(Exception ex)
       {
       Console.WriteLine(ex.Message);
       Console.WriteLine(ex.StackTrace);
       }
      
       Console.ReadLine();
       }
      
       public void doEvent(object sender, OnMessageEventArgs args)
       {
       Console.WriteLine("--> " + args.Message);
       }
      
      
       [STAThread]
       static void Main(string[] args)
       {
       new JMSTest();
       }
       }
      }



      I asume that the user and password required for authentication is a password assigned to the JMS systems.

      Again, any advise would be appreciated and thanks again for your fast response.

      Greetings,
      Kurt

        • 1. Re: Using CsIL
          Kurt De Wit Newbie

          Oke, there seems to be an error in the code provided above.

          AuthenticationRequest auth = new AuthenticationRequest("admin", "admin");
          Connection conn = factory.CreateConnection();
          


          should be

          AuthenticationRequest auth = new AuthenticationRequest("admin", "admin");
          Connection conn = factory.CreateConnection(auth);
          


          I also tried to change the username and password in guest - guest without any result :-(

          Greetings,
          Kurt

          • 2. Re: Using CsIL
            Istvan Gyodi Newbie

            You will definitely need commons-codec-1.2.jar and castor-0.9.9-wml.jar
            in JBoss, just install them under server/default/lib .

            About the user names:
            Please check server/default/conf/jbossmq-state.xml in JBoss.
            For example, you can use j2ee/j2ee for user/passwd.

            Also, in the CSIL package there's a nunit_tests folder. In that, there are
            some tests that use the NUnit framework. You may want to check the
            source code of those tests to see how to use it.

            I

            • 3. Re: Using CsIL
              Kurt De Wit Newbie

              Hi,

              Thanks for your advise. This one actually solved my problem. The default config parameters seem to be incorrect. After replacing them by the ones specified in the NUnit csil-conf.xml file I was able to connect to my JBoss server. Currently I am using the following configuration :

              ConnectionFactory factory = new ConnectionFactory();
              factory.Config.ServerAddress = "192.168.3.120";
              factory.Config.Port = 8094;
              factory.Config.Username = "dynsub";
              factory.Config.Password = "dynsub";
              factory.Config.PingPeriod = 60000;
              factory.Config.TcpNoDelay = false;
              factory.Config.ServerILName = "tamalesoftware.messaging.csil.xil2.XIL2ServerIL";
              
              factory.Config.ClientILServiceName = "tamalesoftware.messaging.csil.xil2.XIL2ClientILService";
              
              factory.Config.Xil2blockwriterblocksize = 128;
              factory.Config.Xil2blockwriterdelimiterchar = 0;
              factory.Config.Xil2blockwriterpaddingchar = 32;
              factory.Config.Usessl = false;



              Thanks and greetings,
              Kurt

              • 4. Re: Using CsIL
                Michal Zajaczkowski Newbie

                Hello,
                I've got a problem with using Csil xil2 with .Net Framework 2.0.
                Program hangs up when method ConnectionFactory.CreateConnection(auth) is invoked. I recompiled xil2 sources but it didn't help.

                Thank you for help,
                Michal

                • 5. Re: Using CsIL
                  Li Qiang Newbie

                  Hi,I am using xil2,and the basic function is all ok,
                  but in my project, I need some function that xil2 currently not implemented ,eg:
                  // TODO: Add Session.CreateDurableSubscriber implementation

                  currently need durableSubscriber and Transaction
                  surport.
                  Is there a plan for implement them? Now I am evaluating some JMS product for use in .Net.

                  And JBossMQ+xil2 is currently best , but for product use I need the durableSubscriber and Transaction function.

                  Thanks.

                  • 6. Re: Using CsIL
                    John Fawcett Newbie

                    csil doesn't yet support .net2, and hasn't been tested by us with it at all. We'll be porting csil to .net2 in the next 3-4 months.

                    • 7. Re: Using CsIL
                      John Fawcett Newbie

                      I currently don't have plans to implement transactions. All I can suggest is contacting Hungary Networks (http://www.net.hu/english/). They also have commit rights for csil, and they might be available to implement this for you.

                      • 8. Re: Using CsIL
                        Michal Zajaczkowski Newbie

                        I saw that method getObject is signed as 'not implemented'. Are there any plans to implement sending objects?
                        Regards,
                        Michal

                        • 9. Re: Using CsIL
                          John Fawcett Newbie

                          getObject is difficult, because you would need some explicit knowledge about the object being transferred in order to translate it from java to c#.

                          I recommend either using xml + serialization to a string with a text message, or implementing externalizable in java and a corresponding constructor in c#.

                          In both cases, it has to be the responsibility of the client application to reconstruct the object from the message, because simple java serialization isn't available.

                          • 10. Re: Using CsIL
                            John Fawcett Newbie

                            sorry, meant to say use externalizable to write your object into a byte message that you know how to decode on the client.

                            • 11. Re: Using CsIL
                              John Fawcett Newbie

                              Hi,

                              We just posted another beta of CsIL, which now runs on .Net2.

                              Enjoy,
                              fawce

                              • 12. Re: Using CsIL
                                Markus Kolp Newbie

                                Hi, I'm using Jboss 4 and XIL2 and can't get your examples working.

                                I get a problem when trying to create a Connection-Object.

                                ...
                                Connection conn = factory.CreateConnection(auth);
                                // alternative: Connection conn = factory.CreateConnection();
                                // alternative: Connection conn = new Connection(auth, factory);
                                ...
                                


                                The stacktrace says following:
                                Object reference not set to an instance of an object.
                                
                                at tamalesoftware.messaging.Connection.Authenticate(AuthenticationRequest pAuthRequest)
                                 at tamalesoftware.messaging.Connection..ctor(AuthenticationRequest pAuth, ConnectionFactory pFactory)
                                 at tamalesoftware.messaging.ConnectionFactory.CreateConnection(AuthenticationRequest pAuth)
                                 at TryAndError.Form1.btnCSILsendMessage_Click(Object sender, EventArgs e) in c:\...\TryAndError\Form1.cs:line 211
                                


                                I tried to use the keyword "new", but that doesn't work either.

                                Here is my complete listing:

                                private void btnCSILsendMessage_Click(object sender, EventArgs e)
                                 {
                                 try
                                 {
                                
                                 ConnectionFactory factory = new ConnectionFactory();
                                 factory.Config.ServerAddress = "10.252.103.201";
                                 factory.Config.Port = 8094;
                                 factory.Config.PingPeriod = 10;
                                
                                 //======================================================================
                                
                                 factory.Config.Username = "admin";
                                 factory.Config.Password = "admin";
                                 factory.Config.TcpNoDelay = false;
                                 factory.Config.ServerILName = "tamalesoftware.messaging.csil.xil2.XIL2ServerIL";
                                 factory.Config.ClientILServiceName = "tamalesoftware.messaging.csil.xil2.XIL2ClientILService";
                                 factory.Config.Xil2blockwriterblocksize = 128;
                                 factory.Config.Xil2blockwriterdelimiterchar = 0;
                                 factory.Config.Xil2blockwriterpaddingchar = 32;
                                 factory.Config.Usessl = false;
                                
                                 //======================================================================
                                
                                 AuthenticationRequest auth = new AuthenticationRequest("admin", "admin");
                                 //Connection conn = new Connection(auth, factory);
                                 Connection conn = factory.CreateConnection(auth);
                                 conn.Start();
                                
                                 Session session = new Session(conn, AcknowledgementTypes.AUTO_ACKNOWLEDGE);
                                 Topic topic = conn.CreateTopic("topic/SMCTopic");
                                 ITopicSubscriber subscribe = session.CreateSubscriber((ITopic)topic);
                                 subscribe.Listen += new OnMessageEventHandler(doEvent);
                                
                                 ITopicPublisher publish = session.CreatePublisher((ITopic)topic);
                                 TextMessage message = new TextMessage();
                                 message.Text = "This is a test.";
                                 publish.Send(message);
                                 MessageBox.Show("message sent");
                                
                                 }
                                 catch (Exception ex)
                                 {
                                 MessageBox.Show(ex.Message);
                                 MessageBox.Show(ex.StackTrace);
                                 txtCSILMessage.Text = ex.Message + " " + ex.StackTrace;
                                 }
                                
                                
                                 }
                                
                                 public void doEvent(object sender, OnMessageEventArgs args)
                                 {
                                 MessageBox.Show("--> " + args.Message);
                                 }
                                


                                Any advice?

                                Thanks, Markus



                                • 13. Re: Using CsIL
                                  John Fawcett Newbie

                                  Hi,

                                  Check the jbossmq-state.xml config file that will be in your jboss/server/<config-name>/conf/ directory. For example, you would use dynsub from the default config:

                                  <?xml version="1.0" encoding="UTF-8"?>
                                  <StateManager>
                                   <Users>
                                   <User>
                                   <Name>john</Name>
                                   <Password>needle</Password>
                                   <Id>DurableSubscriberExample</Id>
                                   </User>
                                   <User>
                                   <Name>guest</Name>
                                   <Password>guest</Password>
                                   </User>
                                   <User>
                                   <Name>nobody</Name>
                                   <Password>nobody</Password>
                                   </User>
                                   <User>
                                   <Name>dynsub</Name>
                                   <Password>dynsub</Password>
                                   </User>
                                   </Users>
                                   <Roles>
                                   <Role name="guest">
                                   <UserName>guest</UserName>
                                   <UserName>john</UserName>
                                   </Role>
                                   <Role name="subscriber">
                                   <UserName>john</UserName>
                                   </Role>
                                   <Role name="publisher">
                                   <UserName>john</UserName>
                                   <UserName>dynsub</UserName>
                                   </Role>
                                   <Role name="durpublisher">
                                   <UserName>john</UserName>
                                   <UserName>dynsub</UserName>
                                   </Role>
                                   <Role name="noacc">
                                   <UserName>nobody</UserName>
                                   </Role>
                                   </Roles>
                                   <DurableSubscriptions>
                                   </DurableSubscriptions>
                                  </StateManager>
                                  


                                  Also, the ping period is in milleseconds. You'll want to use 60000 (a minute), otherwise your connection will drop very often for ping timeouts.


                                  You can keep all the connection factory information in a config file:

                                  <csilconfig xmlns="http://www.tamalesoftware.com/schema/csilconf">
                                   <serveraddress><some-ip-address></serveraddress>
                                   <port>8093</port>
                                   <tcpnodelay>False</tcpnodelay>
                                   <pingperiod>60000</pingperiod>
                                   <serverilname>tamalesoftware.messaging.csil.xil2.XIL2ServerIL</serverilname>
                                   <clientilservicename>tamalesoftware.messaging.csil.xil2.XIL2ClientILService</clientilservicename>
                                   <username>dynsub</username>
                                   <password>dynsub</password>
                                   <xil2blockwriterdelimiterchar>0</xil2blockwriterdelimiterchar>
                                   <xil2blockwriterpaddingchar>32</xil2blockwriterpaddingchar>
                                   <xil2blockwriterblocksize>512</xil2blockwriterblocksize>
                                   <usessl>False</usessl>
                                  </csilconfig>
                                  


                                  Then you can create a connection with:
                                  ConnectionFactory cf = new ConnectionFactory();
                                  cf.SetConfigDirectory("full-path-to-csil-conf.xml");
                                  
                                  Connection c = cf.CreateConnection();
                                  c.Error += new OnConnectionErrorHandler(HandleSubscriptionError);
                                  c.Start();
                                  


                                  Hope this straightens things out, and thanks for using the xil.

                                  thanks,
                                  fawce

                                  • 14. Re: Using CsIL
                                    Markus Kolp Newbie

                                    Hello fawce,
                                    thanks for your quick reply.

                                    I have had already tried out the jbossmq-state.xml file and deployed it to jboss/server/default/conf, as well as the file-state-service.xml to the jboss/server/default/deploy/jms folder. while deploying, JBoss brings up a failure, because the StateManager-MBean has already been registered. See the errors below:

                                     [exec] 19:04:34,272 ERROR [MainDeployer] Could not create deployment: file:/D:/Programme/jboss-4.0.5.GA/server/default/deploy/jms/file-state-service.xml
                                     [exec] org.jboss.deployment.DeploymentException: Trying to install an already registered mbean: jboss.mq:service=StateManager
                                    

                                    I found out, that the StateManager is already started by the hsqldb-jdbc-state-service.xml file in the jboss/server/default/deploy/jms folder. It actually starts the StateManager MBean and stores all the information about JMS users and roles into the integrated HSQL Database (Hypersonic). Following listing shows you the content of hsqldb-jdbc-state.xml.
                                    <?xml version="1.0" encoding="UTF-8"?>
                                    
                                    <!-- hsqldb-jdbc-state-service.xml 23386 2004-09-03 21:38:12Z ejort -->
                                    
                                    
                                    <server>
                                    
                                     <!-- ==================================================================== -->
                                     <!-- JBossMQ State Management using HSQLDB -->
                                     <!-- See docs/examples/jms for other configurations -->
                                     <!-- ==================================================================== -->
                                    
                                     <!-- A Statemanager that stores state in the database -->
                                     <mbean code="org.jboss.mq.sm.jdbc.JDBCStateManager"
                                     name="jboss.mq:service=StateManager">
                                     <depends optional-attribute-name="ConnectionManager">jboss.jca:service=DataSourceBinding,name=DefaultDS</depends>
                                     <attribute name="SqlProperties">
                                     CREATE_TABLES_ON_STARTUP = TRUE
                                     CREATE_USER_TABLE = CREATE TABLE JMS_USERS (USERID VARCHAR(32) NOT NULL, PASSWD VARCHAR(32) NOT NULL, \
                                     CLIENTID VARCHAR(128), PRIMARY KEY(USERID))
                                     CREATE_ROLE_TABLE = CREATE TABLE JMS_ROLES (ROLEID VARCHAR(32) NOT NULL, USERID VARCHAR(32) NOT NULL, \
                                     PRIMARY KEY(USERID, ROLEID))
                                     CREATE_SUBSCRIPTION_TABLE = CREATE TABLE JMS_SUBSCRIPTIONS (CLIENTID VARCHAR(128) NOT NULL, \
                                     SUBNAME VARCHAR(128) NOT NULL, TOPIC VARCHAR(255) NOT NULL, \
                                     SELECTOR VARCHAR(255), PRIMARY KEY(CLIENTID, SUBNAME))
                                     GET_SUBSCRIPTION = SELECT TOPIC, SELECTOR FROM JMS_SUBSCRIPTIONS WHERE CLIENTID=? AND SUBNAME=?
                                     LOCK_SUBSCRIPTION = SELECT TOPIC, SELECTOR FROM JMS_SUBSCRIPTIONS WHERE CLIENTID=? AND SUBNAME=?
                                     GET_SUBSCRIPTIONS_FOR_TOPIC = SELECT CLIENTID, SUBNAME, SELECTOR FROM JMS_SUBSCRIPTIONS WHERE TOPIC=?
                                     INSERT_SUBSCRIPTION = INSERT INTO JMS_SUBSCRIPTIONS (CLIENTID, SUBNAME, TOPIC, SELECTOR) VALUES(?,?,?,?)
                                     UPDATE_SUBSCRIPTION = UPDATE JMS_SUBSCRIPTIONS SET TOPIC=?, SELECTOR=? WHERE CLIENTID=? AND SUBNAME=?
                                     REMOVE_SUBSCRIPTION = DELETE FROM JMS_SUBSCRIPTIONS WHERE CLIENTID=? AND SUBNAME=?
                                     GET_USER_BY_CLIENTID = SELECT USERID, PASSWD, CLIENTID FROM JMS_USERS WHERE CLIENTID=?
                                     GET_USER = SELECT PASSWD, CLIENTID FROM JMS_USERS WHERE USERID=?
                                     POPULATE.TABLES.01 = INSERT INTO JMS_USERS (USERID, PASSWD) VALUES ('guest', 'guest')
                                     POPULATE.TABLES.02 = INSERT INTO JMS_USERS (USERID, PASSWD) VALUES ('j2ee', 'j2ee')
                                     POPULATE.TABLES.03 = INSERT INTO JMS_USERS (USERID, PASSWD, CLIENTID) VALUES ('john', 'needle', 'DurableSubscriberExample')
                                     POPULATE.TABLES.04 = INSERT INTO JMS_USERS (USERID, PASSWD) VALUES ('nobody', 'nobody')
                                     POPULATE.TABLES.05 = INSERT INTO JMS_USERS (USERID, PASSWD) VALUES ('dynsub', 'dynsub')
                                     POPULATE.TABLES.06 = INSERT INTO JMS_ROLES (ROLEID, USERID) VALUES ('guest','guest')
                                     POPULATE.TABLES.07 = INSERT INTO JMS_ROLES (ROLEID, USERID) VALUES ('j2ee','guest')
                                     POPULATE.TABLES.08 = INSERT INTO JMS_ROLES (ROLEID, USERID) VALUES ('john','guest')
                                     POPULATE.TABLES.09 = INSERT INTO JMS_ROLES (ROLEID, USERID) VALUES ('subscriber','john')
                                     POPULATE.TABLES.10 = INSERT INTO JMS_ROLES (ROLEID, USERID) VALUES ('publisher','john')
                                     POPULATE.TABLES.11 = INSERT INTO JMS_ROLES (ROLEID, USERID) VALUES ('publisher','dynsub')
                                     POPULATE.TABLES.12 = INSERT INTO JMS_ROLES (ROLEID, USERID) VALUES ('durpublisher','john')
                                     POPULATE.TABLES.13 = INSERT INTO JMS_ROLES (ROLEID, USERID) VALUES ('durpublisher','dynsub')
                                     POPULATE.TABLES.14 = INSERT INTO JMS_ROLES (ROLEID, USERID) VALUES ('noacc','nobody')
                                     </attribute>
                                     </mbean>
                                    
                                    </server>
                                    
                                    

                                    As you can see, it has the same content (same users and roles e.g. dynsub) like the jbossmq-state.xml has - it just stores them into the database as you can see in the following image. The image shows the HSQL Database Manager and the content of one of these tables.

                                    [img]http://markus-kolp.jimdo.com/cc_images/cache_3071238.jpg[/img]

                                    I'm using JBoss 4.0.5. This version automatically supplies this file and chooses this way via the database - and not the jbossmq-state.xml file.

                                    I've tried to remove the hsqldb-jdbc-state-service.xml file and afterwards deploying the jbossmq-state.xml file.
                                    Then I tested the application again, but I still get the same error messages.

                                    I also tried out the way with the config file (csil-conf.xml) you mentioned, but it doesn't work either.

                                    Do you have a complete VS.NET project/solution that I could try out? My email is markus.kolp@freenet.de.

                                    What else could I be doing wrong?


                                    1 2 Previous Next