8 Replies Latest reply on Apr 9, 2011 12:05 PM by clebert.suconic

    MESSAGE DRIVEN BEAN STOPS WORKING

    rishi321

      when the server starts up I can see it checking for messages, but for some times it doesn't try to grab messages any more. I haven't monitored it that closely to know the exact timing, but I know it's not even trying to check because I have it in debug mode and I don't see the message commands being executed at all and also messages are queued not grab by message driven.

       

      here is my ejb-jar.xml

      <?xml version="1.0" encoding="UTF-8"?>

      <ejb-jar id="ejb-jar_ID" version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"

           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

           xsi:schemaLocation="http://java.sun.com/xml/ns/javaee

                                 http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd">

          <display-name>MessageEJB</display-name>

      <enterprise-beans>

            <message-driven>
                 <display-name>MessageBean</display-name>
                 <ejb-name>MessageBean</ejb-name>
                 <ejb-class>com.ecomm.ejb.mdb.MessageBean</ejb-class>
                 <messaging-type>javax.jms.MessageListener</messaging-type>
                 <transaction-type>Container</transaction-type>
                 <message-destination-type>javax.jms.Queue</message-destination-type>
                 <activation-config>
                      <activation-config-property>
                           <activation-config-property-name>destinationType</activation-config-property-name>
                           <activation-config-property-value>javax.jms.Queue</activation-config-property-value>
                      </activation-config-property>
                      <activation-config-property>
                           <activation-config-property-name>destination</activation-config-property-name>
                           <activation-config-property-value>/queue/ExpiryQueue</activation-config-property-value>
                      </activation-config-property>
                 </activation-config>
            </message-driven>
      </enterprise-beans>

       

       

      Here is my Jboss.xml

       

      <?xml version="1.0"?>

      <jboss>

          <enterprise-beans>

              <message-driven>

                  <ejb-name>MessageBean</ejb-name>

                  <destination-jndi-name>/queue/ExpiryQueue</destination-jndi-name>

                  <resource-ref>

                    <!--   <res-ref-name>jms/QCF</res-ref-name>

                      <jndi-name>ConnectionFactory</jndi-name>

                       -->

       

                       <res-ref-name>MessageBean</res-ref-name>

                      <jndi-name>/queue/ExpiryQueue</jndi-name>

       

       

                  </resource-ref>

              </message-driven>

          </enterprise-beans>

      </jboss>

       

       

      and ejb

      /** * Message-Driven Bean implementation class for: MeaageBean * */@MessageDriven(mappedName = "/queue/ExpiryQueue", activationConfig = {        @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),        @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue")})public class MessageBean implements MessageListener {

       

      i think there may problem related resoure adaptor jms-ra.rar or hornetq-ra.rar

        • 1. MESSAGE DRIVEN BEAN STOPS WORKING
          clebert.suconic

          I have no information to even guess what's going on here...

           

           

          Start at least with what version you're using

          • 2. MESSAGE DRIVEN BEAN STOPS WORKING
            rishi321

            I am using jboss 6 final server and egb3

            • 3. MESSAGE DRIVEN BEAN STOPS WORKING
              clebert.suconic

              We have just released HornetQ 2.2.2.Final

               

               

              You could maybe replace the jars on jboss-6 and give it a try.

               

               

              But even so.. it should work.  It should receive all the messages from your expire queue.

               

               

              Are you sure you are using the Expiry Queue correctly?

              • 4. MESSAGE DRIVEN BEAN STOPS WORKING
                rishi321

                Hi

                 

                I will try with HornetQ 2.2.2 final

                 

                but its working fine only sometime it stop working in between

                 

                i am using Expiry queue as simple queue is there special way to implenment Expiry queue ?

                • 5. MESSAGE DRIVEN BEAN STOPS WORKING
                  rishi321

                     Hi Clebert, Thanks for the quick reply:

                  I am using the Queue in the following manner

                   

                   

                  public void sendMessagetoJMS(String sender,String receiver,String Message,String smsc,String Credit,String userid,long ctime,String savenumber)

                      {

                          int count=0;

                          Hashtable<String, String> ht = new Hashtable<String, String>();

                          ht.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");

                          ht.put(Context.PROVIDER_URL, "69.89.2.245");

                          ht.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");

                          log.warn("SendJMS");

                          try{

                              lContext = new InitialContext(ht);

                              Hconnection = (ConnectionFactory) lContext.lookup("ConnectionFactory");

                              q = (Queue) lContext.lookup("/queue/ExpiryQueue");

                              Hconn = (Connection) Hconnection.createConnection();

                              session =  Hconn.createSession(false, Session.AUTO_ACKNOWLEDGE);

                              messageProducer = session.createProducer(q);

                              /*

                               * Insert into Database

                               */

                              UUID id=UUID.randomUUID();

                              HiberEx hobj=new HiberEx();

                              hobj.insertintoSimpleReport(id,sender,savenumber,Message,smsc,ctime);

                             

                              Hconn.start();

                              log.info("id"+id.toString());

                              log.info("sender"+sender);

                              log.info("message"+Message);

                              log.info("Receiver"+receiver);

                              log.info("operator"+smsc);

                              log.info("User"+userid);

                              log.info("Credit"+Credit);

                              log.info("Ctime"+ctime);

                              textmsg msg = new textmsg();

                              msg.setReciever(receiver);

                              msg.setSender(sender);

                              msg.setText(Message);

                              msg.setSmsc(smsc);

                              msg.setCredit(Credit);

                              msg.setUserid(userid);

                              msg.setCtime(ctime);

                              msg.setId(id.toString());

                              ObjectMessage message = session.createObjectMessage();

                              message.setObject(msg);

                              messageProducer.send(message);

                              log.info("Message sent ");

                              Hconn.close();

                          }

                          catch(Exception ex)

                          {

                              ex.printStackTrace();

                          }

                      }

                   

                  Am i doing it the right way ?

                  • 6. MESSAGE DRIVEN BEAN STOPS WORKING
                    clebert.suconic

                    Expiry queue is just a queue.. look at the manual on how messages are transfered to the Expiry queue.

                     

                     

                    You example is a bit incomplete. I'm not sure what you're doing at your classes.

                    • 7. MESSAGE DRIVEN BEAN STOPS WORKING
                      henk53

                      A little offtopic, but for clarity you might want to improve your variable names a little. Because of naming conventions, Hconn for instance reads like doing a static call.

                      • 8. MESSAGE DRIVEN BEAN STOPS WORKING
                        clebert.suconic

                        Thanks Henk... as a matter of fact yes I thought those were classes...

                         

                         

                        @Riski: WHAT? you're *sending* messages to the expiry queue? With what purpose?

                         

                        You're using the expiry queue as a simple queue. I'm not really sure what you're trying to achieve here.. but you've messing up with concepts I guess.

                         

                         

                        Try telling me from what queue are you consuming, and what queue you're sending...

                         

                        What is your version (did you move to hornetq 2.2.2?)

                         

                        If you're on jboss 6, you should try a snapshot of jboss with the newest version.