Glassfish中未调用消息驱动Bean onMessage()

Glassfish中未调用消息驱动Bean onMessage(),glassfish,jms,Glassfish,Jms,我不熟悉JMS编码。我试图从独立java客户机创建消息,该客户机创建消息并将消息发送到队列,消息驱动bean用于进一步处理消息 我参考了以下准则: 我正在使用Glassfish应用服务器(3.1)。并设置所有内容以从独立java客户端创建JMS消息 这是我的密码: 客户端 import java.util.Properties; import javax.jms.Connection; import javax.jms.DeliveryMode; import javax.jms.Messa

我不熟悉JMS编码。我试图从独立java客户机创建消息,该客户机创建消息并将消息发送到队列,消息驱动bean用于进一步处理消息

我参考了以下准则:

我正在使用Glassfish应用服务器(3.1)。并设置所有内容以从独立java客户端创建
JMS
消息

这是我的密码: 客户端

import java.util.Properties;

import javax.jms.Connection;
import javax.jms.DeliveryMode;
import javax.jms.MessageProducer;
import javax.jms.Queue;
import javax.jms.QueueConnectionFactory;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.naming.Context;
import javax.naming.InitialContext;

public class TruckMonitor {

public static void main(String args[]) {

    try {

    // Provide the details of remote JMS Client
      Properties props = new Properties();
      props.put(Context.PROVIDER_URL, "mq://localhost:7676");

    // Create the initial context for remote JMS server
      InitialContext cntxt = new InitialContext(props);
      System.out.println("Context Created");

      // JNDI Lookup for QueueConnectionFactory in remote JMS Provider
      QueueConnectionFactory qFactory = (QueueConnectionFactory)cntxt.lookup("OmazanQueueConnectionFactory");

      // Create a Connection from QueueConnectionFactory
      Connection connection = qFactory.createConnection();
      System.out.println("Connection established with JMS Provide ");
      connection.start();
      // Initialise the communication session 
      Session session = connection.createSession(true, Session.AUTO_ACKNOWLEDGE);
      // Create the message
      TextMessage message = session.createTextMessage();
      message.setJMSDeliveryMode(DeliveryMode.PERSISTENT);


      message.setText(getMessage());

      // JNDI Lookup for the Queue in remote JMS Provider
      Queue queue = (Queue)cntxt.lookup("OmazanQueue");

      // Create the MessageProducer for this communication 
      // Session on the Queue we have
      MessageProducer mp = session.createProducer(queue);

      // Send the message to Queue
      mp.send(message);
      System.out.println("Message Sent: " + getMessage());

      // Make sure all the resources are released 
      mp.close();
      session.close();
      cntxt.close();
  } catch (Exception ex) {
      ex.printStackTrace();
  }

}

private static String getMessage() {
    String msg = null;

    StringBuffer sbExceptionEvent = new StringBuffer("<exceptionEvent>");
    sbExceptionEvent.append("</exceptionEvent>");

    msg = sbExceptionEvent.toString();
    return msg;
}
}

问题是:
onMessage()
未被调用。我错过什么了吗?请帮帮我。

我想如果您从您的MessageDrivenBean中删除@ActivationConfigProperty(propertyName=“destination”,propertyValue=“OmazanQueue”),因为您已经使用了mappedName=“OmazanQueue”

import java.util.Properties;
import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven;
import javax.jms.Connection;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageConsumer;
import javax.jms.MessageListener;
import javax.jms.Queue;
import javax.jms.QueueConnectionFactory;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;


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

/**
 * Default constructor. 
 * @throws NamingException 
 * @throws JMSException 
 */
public OmazanMDBean() {
    super();
}

/**
 * @see MessageListener#onMessage(Message)
 */
public void onMessage(Message message) {
    System.out.println("Inside omMessage");
    try {
       message.acknowledge();
      } catch (Exception e) {
       e.printStackTrace();
    }

    TextMessage txtMessage = (TextMessage) message;

    try {
        System.out.println(txtMessage.getText());
    } catch (Exception e) {
       e.printStackTrace();
    }
}

}