Hi, I created an mdb, that follows:

  | package uk.co.jemos.ejb3.mdbs;
  | 
  | import javax.annotation.Resource;
  | import javax.ejb.ActivationConfigProperty;
  | import javax.ejb.MessageDriven;
  | import javax.ejb.MessageDrivenContext;
  | import javax.jms.JMSException;
  | import javax.jms.Message;
  | import javax.jms.MessageListener;
  | import javax.jms.TextMessage;
  | 
  | import org.apache.log4j.Logger;
  | /**
  |  *  <class main function here>
  |  *  <p>
  |  *  Jemos Copyright 2003 - All rights reserved.
  |  *  This software is distributed under the 
  |  *  <a href="http://www.opensource.org/licenses/cddl1.php";>CDDL</a> licence
  |  *  </p>
  |  *  @author Marco Tedone <[EMAIL PROTECTED]>
  |  */
  | @MessageDriven(
  |             activationConfig= {
  |                     
@ActivationConfigProperty(propertyName="destinationType", 
  |                                                                   
propertyValue="javax.jms.Queue")                  
  |             })
  |             
  | public class HelloServiceMdb implements MessageListener {
  | 
  |     private static final Logger LOG = 
Logger.getLogger(HelloServiceMdb.class);
  |     
  |     @Resource MessageDrivenContext context;
  |     
  |     public HelloServiceMdb() {
  |             super();
  |             // TODO Auto-generated constructor stub
  |     }
  | 
  |     public void onMessage(Message arg0) {
  |             LOG.info("Hello from MDB.");
  |             if (!(arg0 instanceof TextMessage)) {
  |                     LOG.error("The Message is not of type TextMessage. 
Nothing will be done.");
  |                     return;
  |             }
  |             
  |             TextMessage msg = (TextMessage)arg0;
  |             try {
  |                     String textMsg = msg.getText();
  |                     if (null != textMsg) {
  |                             LOG.info("This is the message from the client: 
" + textMsg);
  |                     } else {
  |                             LOG.error("The string contained in the 
TextMessage is null!");
  |                     }
  |             } catch (JMSException e) {
  |                     LOG.error("An error occurred while retrieving the text 
message");
  |                     context.setRollbackOnly();
  |             }
  |     }
  | 
  | }
  | 

I then have a session bean which invokes the session bean, which also follows:


  | package uk.co.jemos.ejb3.sessions;
  | 
  | import javax.annotation.Resource;
  | import javax.ejb.Remote;
  | import javax.ejb.Stateless;
  | import javax.jms.JMSException;
  | import javax.jms.Message;
  | import javax.jms.Queue;
  | import javax.jms.QueueConnection;
  | import javax.jms.QueueConnectionFactory;
  | import javax.jms.QueueSender;
  | import javax.jms.QueueSession;
  | import javax.jms.Session;
  | 
  | import org.apache.log4j.Logger;
  | import org.jboss.annotation.ejb.RemoteBinding;
  | 
  | import uk.co.jemos.ejb3.exceptions.BusinessObjectException;
  | import uk.co.jemos.ejb3.intf.HelloService;
  | /**
  |  *  <class main function here>
  |  *  <p>
  |  *  Jemos Copyright 2003 - All rights reserved.
  |  *  This software is distributed under the 
  |  *  <a href="http://www.opensource.org/licenses/cddl1.php";>CDDL</a> licence
  |  *  </p>
  |  *  @author Marco Tedone <[EMAIL PROTECTED]>
  |  */
  | @Stateless
  | @Remote({HelloService.class})
  | @RemoteBinding(clientBindUrl="socket://192.168.2.3:4173/", 
jndiBinding="uk_co_jemos_ejb3.sessions_HelloService")
  | public class HelloServiceImpl implements HelloService {
  | 
  |     /**
  |      * 
  |      */
  |     private static final long serialVersionUID = -1689022300300785872L;
  |     
  |     /** The JMS Queue resource auto-managed by the container */
  |     @Resource(mappedName="queue/JEMOS")
  |     Queue destinationQueue;
  |     
  |     /** The JMS Queue Connection Factory auto-managed by the container */
  |     @Resource(mappedName="ConnectionFactory")
  |     QueueConnectionFactory factory;
  | 
  |     private static final Logger LOG = 
Logger.getLogger(HelloServiceImpl.class);
  |     
  |     public HelloServiceImpl() {
  |             super();
  |             // TODO Auto-generated constructor stub
  |     }
  | 
  |     public void sayHello(String name) {
  |             LOG.info("Hello: " + name);
  |     }
  | 
  |     public void sayAsynchronousHello(String name) throws 
BusinessObjectException {          
  |             LOG.info("Received request to send asynchronous say Hello...");
  |             QueueConnection conn = null;
  |             QueueSession session = null;
  |             QueueSender sender = null;
  |             try {
  |                      conn = factory.createQueueConnection();
  |                      session = conn.createQueueSession(false, 
Session.AUTO_ACKNOWLEDGE);
  |                      sender = session.createSender(destinationQueue);
  |                      
  |                      Message message = session.createTextMessage("Hello 
Marco Tedone - Asynchronous");                       
  |                      sender.send(message);
  |                      LOG.info("Message sent to the queue");
  |             } catch (JMSException e) {
  |                     LOG.error(e.getLocalizedMessage());
  |                     throw new 
BusinessObjectException(e.getLocalizedMessage());
  |             } finally {                                             
  |                     if (null != sender) {
  |                             try {
  |                                     sender.close();
  |                             } catch (JMSException e) {
  |                                     LOG.error(e.getLocalizedMessage());
  |                             }
  |                     }
  |                     if (null != session) {
  |                             try {
  |                                     session.close();
  |                             } catch (JMSException e) {
  |                                     LOG.error(e.getLocalizedMessage());
  |                             }
  |                     }
  |                     if (null != conn) {
  |                             try {
  |                                     conn.close();
  |                             } catch (JMSException e) {
  |                                     LOG.error(e.getLocalizedMessage());
  |                             }
  |                     }
  |             }
  |     }
  | 
  | }
  | 

I then invoke the sayAsynchronousHello from an external client. The message 
gets created and sent to the JBoss queue, but it never arrives to the MDB!

This is the list of messages sent to the JEMOS queue, retrieved from the 
JMX-Console:

anonymous wrote : 
  | [SpyTextMessage {
  | Header { 
  |    jmsDestination  : QUEUE.JEMOS
  |    jmsDeliveryMode : 2
  |    jmsExpiration   : 0
  |    jmsPriority     : 4
  |    jmsMessageID    : ID:9-11518646660711
  |    jmsTimeStamp    : 1151864666071
  |    jmsCorrelationID: null
  |    jmsReplyTo      : null
  |    jmsType         : null
  |    jmsRedelivered  : false
  |    jmsProperties   : {}
  |    jmsPropReadWrite: false
  |    msgReadOnly     : true
  |    producerClientId: ID:9
  | }
  | Body {
  |    text            :Hello Marco Tedone - Asynchronous
  | }
  | }
  | 

Any idea as how this happens?

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3954903#3954903

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3954903

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to