这个应该是JMS Provider做的事情吧

解决方案 »

  1.   

    是这样吗?
    sender.send(textmessage,javax.jms.DeliveryMode.PERSISTENT, javax.jms.Message.DEFAULT_PRIORITY,1800000);
      

  2.   

    采用P2P方式,只要接收者没有消费消息,本身就是持久的。
    你先send一个消息,然后关闭服务器,再重启,执行Receiver程序
    消息还是可以成功接收。
      

  3.   

    sender.send(textmessage,javax.jms.DeliveryMode.PERSISTENT, javax.jms.Message.DEFAULT_PRIORITY,1800000);
    也对!
    默认的sender.send(textmessage)就是采用DeliveryMode.PERSISTENT模式;
    DEFAULT_PRIORITY为4。
      

  4.   

    还是不行啊,我的设置如下:
    <jms-server port="9127">
    <!-- Queue bindings, these queues will be bound to their respective JNDI path for
    later retrieval -->
    <queue name="Demo Queue" location="jms/demoQueue">
    <description>A dummy queue</description>
    </queue>
    <queue name="Table Queue" location="jms/theQueue" persistence-file="../persistence/jms/tableQueue.queue">
    <description>A dummy queue</description>
    </queue>
    <queue-connection-factory host="192.168.0.119" location="jms/theQueueConnectionFactory" password="123" port="9127" username="admin" />
    <!-- Topic bindings, these topic will be bound to their respective JNDI path for
    later retrieval -->
    <topic name="Demo Topic" location="jms/demoTopic">
    <description>A dummy topic</description>
    </topic> <!-- path to the log-file where JMS-events/errors are stored -->
    <log>
    <file path="../log/jms.log" />
    </log>
    </jms-server>
      

  5.   

    你用什么服务器?
    如果用sun J2EE RI是非常简单的!
      

  6.   

    orion我没用过。
    原理当然一样了,JMS是独立于Provider的。
    其实最主要是先配置好destination和connectionFactory;
    然后再用JNDI查找,以下是两个基于sun J2EE RI
    的简单程序(21天学通J2EE上的例子),可以参考一下:sender:import javax.naming.*;
    import javax.jms.*;public class PTPSender {
    private QueueConnection queueConnection;
    private QueueSession queueSession;
    private QueueSender queueSender;
    private Queue queue; public static void main(String[] arge) {
    try {
    PTPSender sender=new PTPSender();
    System.out.println("Sending message Hello World");
    sender.sendMessage("Hello World");
    sender.close();
    } catch(Exception e) {
    System.err.println("Exception in PTPSender: "+e);
    }
    } public PTPSender() throws JMSException,NamingException {
    Context context=new InitialContext();
    QueueConnectionFactory queueFactory=(QueueConnectionFactory)context.lookup("jms/QueueConnectionFactory");
    queueConnection=queueFactory.createQueueConnection();
    queueSession=queueConnection.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);
    queue=(Queue)context.lookup("jms/Queue");
    queueSender=queueSession.createSender(queue);
    } public void sendMessage(String msg) throws JMSException {
    TextMessage message=queueSession.createTextMessage();
    message.setText(msg);
    queueSender.send(message);
    } public void close() throws JMSException {
    queueSender.send(queueSession.createMessage());
    queueSender.close();
    queueSession.close();
    queueConnection.close();
    }
    }receiver:import javax.naming.*;
    import javax.jms.*;public class PTPReceiver {
    private QueueConnection queueConnection;
    private QueueSession queueSession;
    private QueueReceiver queueReceiver;
    private Queue queue; public static void main(String[] arge) {
    try {
    PTPReceiver receiver=new PTPReceiver();
    System.out.println("Receiver running");
    String textMsg=receiver.consumeMessage();
    if(textMsg!=null)
    System.out.println("Received: "+textMsg);
    receiver.close();
    //Thread.currentThread().sleep(120000);
    } catch(Exception e) {
    System.err.println("Exception in PTPSender: "+e);
    }
    } public PTPReceiver() throws JMSException,NamingException {
    Context context=new InitialContext();
    QueueConnectionFactory queueFactory=(QueueConnectionFactory)context.lookup("jms/QueueConnectionFactory");
    queueConnection=queueFactory.createQueueConnection();
    queueSession=queueConnection.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);
    queue=(Queue)context.lookup("jms/Queue");
    queueReceiver=queueSession.createReceiver(queue);
    queueConnection.start();
    } public String consumeMessage() throws JMSException {
    String text=null;
    Message message=queueReceiver.receive();
    if(message instanceof TextMessage) {
    text=((TextMessage)message).getText();
    }
    return text;
    } public void close() throws JMSException {
    queueReceiver.close();
    queueSession.close();
    queueConnection.close();
    }
    }
      

  7.   

    我知道问题所在了,orion不是在接受了消息马上存放到磁盘,而是被终止时,自动保存,而我停服务的时候,是kill这个线程的,所以消息没有被保存!
    所以我打算换一种消息服务器,请大家帮我推荐一种!
      

  8.   

    我知道问题所在了,orion不是在接受了消息马上存放到磁盘,而是被终止时,自动保存,而我停服务的时候,是kill这个线程的,所以消息没有被保存!
    所以我打算换一种消息服务器,请大家帮我推荐一种!
      

  9.   

    我知道问题所在了,orion不是在接受了消息马上存放到磁盘,而是被终止时,自动保存,而我停服务的时候,是kill这个线程的,所以消息没有被保存!
    所以我打算换一种消息服务器,请大家帮我推荐一种!
      

  10.   

    一般各类支持j2ee的服务器都包含了JMS,
    如果想要单纯的消息服务器可以试试IBM的MQ Series,
    其他具体情况可以在网上看看。
      

  11.   

    MQ Series报价 120w人民币
    tomcat+openjms