错误:对于类型Session,方法createQueue(String)未定义

时间:2017-10-17 15:56:21

标签: java jms activemq

当我尝试下面的代码时,为Producer和&产生以下错误目的地。我使用的是正确的连接工厂吗?

  • 对于类型Session

    ,方法createQueue(String)未定义
    import org.apache.activemq.ActiveMQConnection;
    import org.apache.activemq.ActiveMQConnectionFactory;
    import javax.jms.Connection;
    import javax.jms.DeliveryMode;
    import javax.jms.Destination;
    import javax.jms.ExceptionListener;
    import javax.jms.JMSException;
    import javax.jms.Message;
    import javax.jms.MessageConsumer;
    import javax.jms.MessageProducer;
    import javax.jms.QueueConnection;
    import javax.jms.QueueConnectionFactory;
    import javax.jms.Session;
    import javax.jms.TextMessage;  
    
        public class MQProdCons {
        public static void main(String[] args) {
            try {            
            QueueConnectionFactory connectionFactory = new ActiveMQConnectionFactory(getSendHost());              
            QueueConnection connection = connectionFactory.createQueueConnection();  
            connection.start();
            // Create a session
            Session session = connection.createQueueSession(false,
                    Session.AUTO_ACKNOWLEDGE);
            // Connect to queues
            Destination requestQ = session.createQueue (getReportQueue());
    
            MessageProducer producer = session.createProducer(requestQ);
            Destination responseQ = session.createQueue(getReceiveQueue());
    
            MessageConsumer consumer = session.createConsumer(responseQ);
            producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
    

1 个答案:

答案 0 :(得分:0)

我找到了解决方案! 您使用了错误的导入。使用org.hibernate.Session,错误将消失。