5 Replies Latest reply on Sep 19, 2007 4:20 AM by changemylife

    I need help about Messaging!

    changemylife

      Hi all !
      I use jboss-4.0.5.GA and EJB3.0
      I write a Message-Driven Bean. It's very simple and look like :

      public class LogBean implements MessageListener {
       public void onMessage(Message msg) {
       if (msg instanceof TextMessage) {
       TextMessage tm = (TextMessage) msg;
       try {
       String text = tm.getText();
       System.out.println("Received new message : " + text);
       } catch (JMSException e) {
       e.printStackTrace();
       }
       }
       }
      }

      My ejb-jar.xml:
      <enterprise-beans>
       <message-driven>
       <ejb-name>LogBean</ejb-name>
       <ejb-class>mdb.com.LogBean</ejb-class>
       <messaging-type>javax.jms.MessageListener</messaging-type>
       <transaction-type>Bean</transaction-type>
       <message-destination-type>javax.jms.Topic</message-destination-type>
      
       <activation-config>
       <activation-config-property>
       <activation-config-property-name>destinationType</activation-config-property-name>
       <activation-config-property-value>javax.jms.Topic</activation-config-property-value>
       </activation-config-property>
       </activation-config>
       </message-driven>
      </enterprise-beans>

      But when I run JBoss Server, I received some errors:
      org.jboss.deployment.DeploymentException: Required configproperty RequiredConfigPropertyMetaData@192
      38ad[name=destination descriptions=[DescriptionMetaData@147ff11[language=en]]] for messagingType 'ja
      vax.jms.MessageListener' not found in activation config [ActivationConfigProperty(destinationType=ja
      vax.jms.Topic)] ra=jboss.jca:service=RARDeployment,name='jms-ra.rar'
      ....

      I put my ejb-jar inside META-INF folder.
      I think that I must configure JBoss Server but I don't know where I do this.
      Please guide to me or show me some documents. Thanks.

      Catania.

        • 1. Re: I need help about Messaging!
          bershath27

          first, i believe you have to post this to the EJB3 queue , not here. hope someone's going to move this thread to the correct location.

          where is the *destination* ?? to which destination are you publishing your messages ??
          btw, why do you still use deployment descriptors and do this in such a tortures way ? haven't you heard of annotations ??

          you can do the same as follows :

          import javax.jms.JMSException;
          import javax.jms.Message;
          import javax.jms.MessageListener;
          import javax.jms.TextMessage;
          import javax.ejb.ActivationConfigProperty;
          import javax.ejb.MessageDriven;
          import javax.ejb.TransactionManagement;
          import javax.ejb.TransactionManagementType;



          @MessageDriven (activationConfig = {
          @ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Topic"),
          @ActivationConfigProperty(propertyName="destination", propertyValue="topic/SriLanka"),
          })

          @TransactionManagement (TransactionManagementType.BEAN)
          public class LogMDB implements MessageListener {

          public void onMessage(Message message) {

          if (message instanceof TextMessage) {
          TextMessage textMessage = (TextMessage) message;
          try {
          System.out.println(textMessage.getText());
          } catch (JMSException e) {
          e.printStackTrace();
          }
          }
          }

          }

          *note*
          in this example, i'm publishing messages to the topic called, "SriLanka". as i've said earlier, you got that error for you haven't provided a destination(topic) name.

          Tyronne Wickramarathne

          • 2. Re: I need help about Messaging!
            changemylife

            Hi !
            Sorry, my English is not good. The first, thanks to reply. My work is very urgent and I'm beginner with MDB and JMS so I post any where to expect reply from some one. The second, I'm sorry because I locate incorrectly.
            Thank you very much!

            • 3. Re: I need help about Messaging!
              bershath27

              >>My work is very urgent and I'm beginner with MDB and JMS so I post any where to expect reply from some one.

              you will be the one, who's going to get the benefit, when you first post your query to the correct queue :) you have to get to the *relevant* queue to get a *relevant* from the *relevant* experts.

              let me know, if you have solve your problem.

              thanks
              Tyronne Wickramarathne

              • 4. Re: I need help about Messaging!
                changemylife

                Hi !
                I edited my MDB, and it's Ok. My jbossmq-myqueues-service.xml is look like:

                <mbean code="org.jboss.mq.server.jmx.Queue"
                 name="jboss.mq.destination:service=Queue,name=myQueue">
                 <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
                </mbean>

                And I put it inside /deploy --> all things are Ok. but when I write a client that send some TextMessage :
                InitialContext jndiContext = getInitialContext( );
                try {
                 ConnectionFactory factory = (ConnectionFactory)jndiContext.lookup("ConnectionFactory");
                 Queue queueTmp= (Queue)jndiContext.lookup("queue/producerQueue");
                 Connection connect = factory.createConnection( );
                 Session session = connect.createSession(false,Session.AUTO_ACKNOWLEDGE);
                 MessageProducer sender = session.createProducer(queueTmp);
                 for(int i=0; i<10; i++){
                 TextMessage t = session.createTextMessage();
                 t.setText(new Timestamp(System.currentTimeMillis())+" JmsClientProducer Message "+i);
                 sender.send(t);
                 Thread.sleep(1000);
                 }
                 connect.close();
                } catch (NamingException e) {
                 ......
                }

                And my jndi.properties is look like:
                java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
                java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
                java.naming.provider.url=localhost:1099

                When I run client, I received some errors:
                javax.naming.CommunicationException [Root exception is java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
                 java.lang.ClassNotFoundException: org.jboss.mq.referenceable.ObjectRefAddr (no security manager: RMI class loader disabled)]
                 at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:722)
                 at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
                 at javax.naming.InitialContext.lookup(Unknown Source)
                 at thai.jms.client.JmsClient.main(JmsClient.java:33)
                Caused by: java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
                 java.lang.ClassNotFoundException: org.jboss.mq.referenceable.ObjectRefAddr (no security manager: RMI class loader disabled)
                 at sun.rmi.server.UnicastRef.invoke(Unknown Source)
                 at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
                 at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:625)
                 ... 3 more
                ---> and error at line:
                ConnectionFactory factory = (ConnectionFactory)jndiContext.lookup("ConnectionFactory");

                But inside my MDB, I were declared:
                @Resource(mappedName="ConnectionFactory")
                 private ConnectionFactory connectionFactory;


                I understand your suggestions.And althought, I posted my article not correct but I recognized your helps and can you continue guide some my remain problems ?

                Thanks.

                Catania.

                • 5. Re: I need help about Messaging!
                  changemylife

                  Hi all!
                  I solved my problem. I imported

                  jbossall-client
                  into my project, all things ok.