`
jncz
  • 浏览: 28943 次
最近访客 更多访客>>
社区版块
存档分类
最新评论

【提问】对于自关联的表 使用dbunit如何保持数据库状态

阅读更多
比如区域,会有下级地市等等,对于dbunit来说他貌似只能对表与表之间的关联关系进行处理,对于同一表中记录与记录之间的关系,他处理不了,会出现外键约束违例。由于对dbunit目前了解的比较肤浅,还请大家能不吝赐教。
分享到:
评论
1 楼 long110 2007-05-17  
package com.javaeye.jms.jboss;  
  
import javax.jms.Connection;  
import javax.jms.ConnectionFactory;  
import javax.jms.Destination;  
import javax.jms.JMSException;  
import javax.jms.MessageConsumer;  
import javax.jms.MessageProducer;  
import javax.jms.Queue;  
import javax.jms.QueueSender;  
import javax.jms.Session;  
import javax.jms.TextMessage;  
import javax.naming.Context;  
import javax.naming.InitialContext;  
import javax.naming.NamingException;  
  
public class JbossNativeJmsImpl {  
     
    /** 
     * @author zuly 
     * 
     * following jms ptp domain, use an simple text message to test 
     * 
     * A jms ptp sender will following the steps below! 
     *     1> get an ConnectionFactory use JNDI Lookup Or Initial it yourself 
     *     2> use this ConnectionFactory to start a jms connection

     *        [spec to jms 1.1 apito get the main idea of it ] 
     *     3> use connection to create a jms session 
     *     4> get a queue destination / messege agent 
     *     5> start the Producer[jms1.1 spec] by a session 
     *     6> get messege Object or initial it yourself by implements the messegeor 

     *        it's sub interfaces 
     *     7> call sender or send it selfing 
     *     8> finallized the connection object or it will throw a warning to you! 
     * 
     * @param messege 
     * @throws NamingException 
     * @throws JMSException 
     */  
    public void sendingProcessing(String messege) throws NamingException, JMSException{  
        Context ctx = new InitialContext();  
        ConnectionFactory cf = (ConnectionFactory) ctx.lookup("java:JmsXA");  
        Connection conn = cf.createConnection();  
        Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);  
        Destination dest = (Queue) ctx.lookup("queue/A");  
        MessageProducer msgp = session.createProducer(dest);  
        QueueSender sender = (QueueSender) msgp;  
        TextMessage msg = session.createTextMessage();  
        msg.setText(messege);  
        sender.send(msg);  
        conn.close();  
    }  
     
     
     
    /** 
     * @author zuly 
     * 
     * following jms ptp domain, use an simple text message to test 
     * 
     * A jms ptp retriver will following the steps below! 
     *     1> get an ConnectionFactory use JNDI Lookup Or Initial it yourself 
     *     2> use this ConnectionFactory to start a jms connection 
     *        [spec to jms 1.1 api to get the main idea of it ] 
     *     3> use connection to create a jms session 
     *     4> get a queue destination / messege agent 
     *     5> retrive a consumer from session 
     *     6> start the jms connection to retrivte the message 
     *     7> get message from consumer 
     *  
     * @return textMessege 
     * @throws NamingException 
     * @throws JMSException 
     */  
    public String retriveingProcessing() throws NamingException, JMSException{  
        Context ctx = new InitialContext();  
        ConnectionFactory cf = (ConnectionFactory) ctx.lookup("java:JmsXA");  
        Connection conn = cf.createConnection();  
        Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);  
        Destination dest = (Queue) ctx.lookup("queue/A");  
        MessageConsumer msgconsumer = session.createConsumer(dest);  
        //MessageListener ml = new JmsListenner();  
        //msgconsumer.setMessageListener(ml);  
        conn.start();  
        TextMessage msg = (TextMessage) msgconsumer.receive();  
        conn.close();  
        System.out.println("messege is" + msg.getText());  
        return msg.getText();  
    }  
}  
package com.javaeye.jms.jboss;  
  
import javax.jms.Connection;  
import javax.jms.ConnectionFactory;  
import javax.jms.Destination;  
import javax.jms.JMSException;  
import javax.jms.MessageConsumer;  
import javax.jms.MessageProducer;  
import javax.jms.Queue;  
import javax.jms.QueueSender;  
import javax.jms.Session;  
import javax.jms.TextMessage;  
import javax.naming.Context;  
import javax.naming.InitialContext;  
import javax.naming.NamingException;  
  
public class JbossNativeJmsImpl {  
     
    /** 
     * @author zuly 
     * 
     * following jms ptp domain, use an simple text message to test 
     * 
     * A jms ptp sender will following the steps below! 
     *     1> get an ConnectionFactory use JNDI Lookup Or Initial it yourself 
     *     2> use this ConnectionFactory to start a jms connection

     *        [spec to jms 1.1 apito get the main idea of it ] 
     *     3> use connection to create a jms session 
     *     4> get a queue destination / messege agent 
     *     5> start the Producer[jms1.1 spec] by a session 
     *     6> get messege Object or initial it yourself by implements the messegeor 

     *        it's sub interfaces 
     *     7> call sender or send it selfing 
     *     8> finallized the connection object or it will throw a warning to you! 
     * 
     * @param messege 
     * @throws NamingException 
     * @throws JMSException 
     */  
    public void sendingProcessing(String messege) throws NamingException, JMSException{  
        Context ctx = new InitialContext();  
        ConnectionFactory cf = (ConnectionFactory) ctx.lookup("java:JmsXA");  
        Connection conn = cf.createConnection();  
        Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);  
        Destination dest = (Queue) ctx.lookup("queue/A");  
        MessageProducer msgp = session.createProducer(dest);  
        QueueSender sender = (QueueSender) msgp;  
        TextMessage msg = session.createTextMessage();  
        msg.setText(messege);  
        sender.send(msg);  
        conn.close();  
    }  
     
     
     
    /** 
     * @author zuly 
     * 
     * following jms ptp domain, use an simple text message to test 
     * 
     * A jms ptp retriver will following the steps below! 
     *     1> get an ConnectionFactory use JNDI Lookup Or Initial it yourself 
     *     2> use this ConnectionFactory to start a jms connection 
     *        [spec to jms 1.1 api to get the main idea of it ] 
     *     3> use connection to create a jms session 
     *     4> get a queue destination / messege agent 
     *     5> retrive a consumer from session 
     *     6> start the jms connection to retrivte the message 
     *     7> get message from consumer 
     *  
     * @return textMessege 
     * @throws NamingException 
     * @throws JMSException 
     */  
    public String retriveingProcessing() throws NamingException, JMSException{  
        Context ctx = new InitialContext();  
        ConnectionFactory cf = (ConnectionFactory) ctx.lookup("java:JmsXA");  
        Connection conn = cf.createConnection();  
        Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);  
        Destination dest = (Queue) ctx.lookup("queue/A");  
        MessageConsumer msgconsumer = session.createConsumer(dest);  
        //MessageListener ml = new JmsListenner();  
        //msgconsumer.setMessageListener(ml);  
        conn.start();  
        TextMessage msg = (TextMessage) msgconsumer.receive();  
        conn.close();  
        System.out.println("messege is" + msg.getText());  
        return msg.getText();  
    }  
}  
package com.javaeye.jms.jboss;  
  
import javax.jms.Connection;  
import javax.jms.ConnectionFactory;  
import javax.jms.Destination;  
import javax.jms.JMSException;  
import javax.jms.MessageConsumer;  
import javax.jms.MessageProducer;  
import javax.jms.Queue;  
import javax.jms.QueueSender;  
import javax.jms.Session;  
import javax.jms.TextMessage;  
import javax.naming.Context;  
import javax.naming.InitialContext;  
import javax.naming.NamingException;  
  
public class JbossNativeJmsImpl {  
     
    /** 
     * @author zuly 
     * 
     * following jms ptp domain, use an simple text message to test 
     * 
     * A jms ptp sender will following the steps below! 
     *     1> get an ConnectionFactory use JNDI Lookup Or Initial it yourself 
     *     2> use this ConnectionFactory to start a jms connection

     *        [spec to jms 1.1 apito get the main idea of it ] 
     *     3> use connection to create a jms session 
     *     4> get a queue destination / messege agent 
     *     5> start the Producer[jms1.1 spec] by a session 
     *     6> get messege Object or initial it yourself by implements the messegeor 

     *        it's sub interfaces 
     *     7> call sender or send it selfing 
     *     8> finallized the connection object or it will throw a warning to you! 
     * 
     * @param messege 
     * @throws NamingException 
     * @throws JMSException 
     */  
    public void sendingProcessing(String messege) throws NamingException, JMSException{  
        Context ctx = new InitialContext();  
        ConnectionFactory cf = (ConnectionFactory) ctx.lookup("java:JmsXA");  
        Connection conn = cf.createConnection();  
        Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);  
        Destination dest = (Queue) ctx.lookup("queue/A");  
        MessageProducer msgp = session.createProducer(dest);  
        QueueSender sender = (QueueSender) msgp;  
        TextMessage msg = session.createTextMessage();  
        msg.setText(messege);  
        sender.send(msg);  
        conn.close();  
    }  
     
     
     
    /** 
     * @author zuly 
     * 
     * following jms ptp domain, use an simple text message to test 
     * 
     * A jms ptp retriver will following the steps below! 
     *     1> get an ConnectionFactory use JNDI Lookup Or Initial it yourself 
     *     2> use this ConnectionFactory to start a jms connection 
     *        [spec to jms 1.1 api to get the main idea of it ] 
     *     3> use connection to create a jms session 
     *     4> get a queue destination / messege agent 
     *     5> retrive a consumer from session 
     *     6> start the jms connection to retrivte the message 
     *     7> get message from consumer 
     *  
     * @return textMessege 
     * @throws NamingException 
     * @throws JMSException 
     */  
    public String retriveingProcessing() throws NamingException, JMSException{  
        Context ctx = new InitialContext();  
        ConnectionFactory cf = (ConnectionFactory) ctx.lookup("java:JmsXA");  
        Connection conn = cf.createConnection();  
        Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);  
        Destination dest = (Queue) ctx.lookup("queue/A");  
        MessageConsumer msgconsumer = session.createConsumer(dest);  
        //MessageListener ml = new JmsListenner();  
        //msgconsumer.setMessageListener(ml);  
        conn.start();  
        TextMessage msg = (TextMessage) msgconsumer.receive();  
        conn.close();  
        System.out.println("messege is" + msg.getText());  
        return msg.getText();  
    }  
}  
package com.javaeye.jms.jboss;  
  
import javax.jms.Connection;  
import javax.jms.ConnectionFactory;  
import javax.jms.Destination;  
import javax.jms.JMSException;  
import javax.jms.MessageConsumer;  
import javax.jms.MessageProducer;  
import javax.jms.Queue;  
import javax.jms.QueueSender;  
import javax.jms.Session;  
import javax.jms.TextMessage;  
import javax.naming.Context;  
import javax.naming.InitialContext;  
import javax.naming.NamingException;  
  
public class JbossNativeJmsImpl {  
     
    /** 
     * @author zuly 
     * 
     * following jms ptp domain, use an simple text message to test 
     * 
     * A jms ptp sender will following the steps below! 
     *     1> get an ConnectionFactory use JNDI Lookup Or Initial it yourself 
     *     2> use this ConnectionFactory to start a jms connection

     *        [spec to jms 1.1 apito get the main idea of it ] 
     *     3> use connection to create a jms session 
     *     4> get a queue destination / messege agent 
     *     5> start the Producer[jms1.1 spec] by a session 
     *     6> get messege Object or initial it yourself by implements the messegeor 

     *        it's sub interfaces 
     *     7> call sender or send it selfing 
     *     8> finallized the connection object or it will throw a warning to you! 
     * 
     * @param messege 
     * @throws NamingException 
     * @throws JMSException 
     */  
    public void sendingProcessing(String messege) throws NamingException, JMSException{  
        Context ctx = new InitialContext();  
        ConnectionFactory cf = (ConnectionFactory) ctx.lookup("java:JmsXA");  
        Connection conn = cf.createConnection();  
        Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);  
        Destination dest = (Queue) ctx.lookup("queue/A");  
        MessageProducer msgp = session.createProducer(dest);  
        QueueSender sender = (QueueSender) msgp;  
        TextMessage msg = session.createTextMessage();  
        msg.setText(messege);  
        sender.send(msg);  
        conn.close();  
    }  
     
     
     
    /** 
     * @author zuly 
     * 
     * following jms ptp domain, use an simple text message to test 
     * 
     * A jms ptp retriver will following the steps below! 
     *     1> get an ConnectionFactory use JNDI Lookup Or Initial it yourself 
     *     2> use this ConnectionFactory to start a jms connection 
     *        [spec to jms 1.1 api to get the main idea of it ] 
     *     3> use connection to create a jms session 
     *     4> get a queue destination / messege agent 
     *     5> retrive a consumer from session 
     *     6> start the jms connection to retrivte the message 
     *     7> get message from consumer 
     *  
     * @return textMessege 
     * @throws NamingException 
     * @throws JMSException 
     */  
    public String retriveingProcessing() throws NamingException, JMSException{  
        Context ctx = new InitialContext();  
        ConnectionFactory cf = (ConnectionFactory) ctx.lookup("java:JmsXA");  
        Connection conn = cf.createConnection();  
        Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);  
        Destination dest = (Queue) ctx.lookup("queue/A");  
        MessageConsumer msgconsumer = session.createConsumer(dest);  
        //MessageListener ml = new JmsListenner();  
        //msgconsumer.setMessageListener(ml);  
        conn.start();  
        TextMessage msg = (TextMessage) msgconsumer.receive();  
        conn.close();  
        System.out.println("messege is" + msg.getText());  
        return msg.getText();  
    }  
}  
package com.javaeye.jms.jboss;  
  
import javax.jms.Connection;  
import javax.jms.ConnectionFactory;  
import javax.jms.Destination;  
import javax.jms.JMSException;  
import javax.jms.MessageConsumer;  
import javax.jms.MessageProducer;  
import javax.jms.Queue;  
import javax.jms.QueueSender;  
import javax.jms.Session;  
import javax.jms.TextMessage;  
import javax.naming.Context;  
import javax.naming.InitialContext;  
import javax.naming.NamingException;  
  
public class JbossNativeJmsImpl {  
     
    /** 
     * @author zuly 
     * 
     * following jms ptp domain, use an simple text message to test 
     * 
     * A jms ptp sender will following the steps below! 
     *     1> get an ConnectionFactory use JNDI Lookup Or Initial it yourself 
     *     2> use this ConnectionFactory to start a jms connection

     *        [spec to jms 1.1 apito get the main idea of it ] 
     *     3> use connection to create a jms session 
     *     4> get a queue destination / messege agent 
     *     5> start the Producer[jms1.1 spec] by a session 
     *     6> get messege Object or initial it yourself by implements the messegeor 

     *        it's sub interfaces 
     *     7> call sender or send it selfing 
     *     8> finallized the connection object or it will throw a warning to you! 
     * 
     * @param messege 
     * @throws NamingException 
     * @throws JMSException 
     */  
    public void sendingProcessing(String messege) throws NamingException, JMSException{  
        Context ctx = new InitialContext();  
        ConnectionFactory cf = (ConnectionFactory) ctx.lookup("java:JmsXA");  
        Connection conn = cf.createConnection();  
        Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);  
        Destination dest = (Queue) ctx.lookup("queue/A");  
        MessageProducer msgp = session.createProducer(dest);  
        QueueSender sender = (QueueSender) msgp;  
        TextMessage msg = session.createTextMessage();  
        msg.setText(messege);  
        sender.send(msg);  
        conn.close();  
    }  
     
     
     
    /** 
     * @author zuly 
     * 
     * following jms ptp domain, use an simple text message to test 
     * 
     * A jms ptp retriver will following the steps below! 
     *     1> get an ConnectionFactory use JNDI Lookup Or Initial it yourself 
     *     2> use this ConnectionFactory to start a jms connection 
     *        [spec to jms 1.1 api to get the main idea of it ] 
     *     3> use connection to create a jms session 
     *     4> get a queue destination / messege agent 
     *     5> retrive a consumer from session 
     *     6> start the jms connection to retrivte the message 
     *     7> get message from consumer 
     *  
     * @return textMessege 
     * @throws NamingException 
     * @throws JMSException 
     */  
    public String retriveingProcessing() throws NamingException, JMSException{  
        Context ctx = new InitialContext();  
        ConnectionFactory cf = (ConnectionFactory) ctx.lookup("java:JmsXA");  
        Connection conn = cf.createConnection();  
        Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);  
        Destination dest = (Queue) ctx.lookup("queue/A");  
        MessageConsumer msgconsumer = session.createConsumer(dest);  
        //MessageListener ml = new JmsListenner();  
        //msgconsumer.setMessageListener(ml);  
        conn.start();  
        TextMessage msg = (TextMessage) msgconsumer.receive();  
        conn.close();  
        System.out.println("messege is" + msg.getText());  
        return msg.getText();  
    }  
}  
package com.javaeye.jms.jboss;  
  
import javax.jms.Connection;  
import javax.jms.ConnectionFactory;  
import javax.jms.Destination;  
import javax.jms.JMSException;  
import javax.jms.MessageConsumer;  
import javax.jms.MessageProducer;  
import javax.jms.Queue;  
import javax.jms.QueueSender;  
import javax.jms.Session;  
import javax.jms.TextMessage;  
import javax.naming.Context;  
import javax.naming.InitialContext;  
import javax.naming.NamingException;  
  
public class JbossNativeJmsImpl {  
     
    /** 
     * @author zuly 
     * 
     * following jms ptp domain, use an simple text message to test 
     * 
     * A jms ptp sender will following the steps below! 
     *     1> get an ConnectionFactory use JNDI Lookup Or Initial it yourself 
     *     2> use this ConnectionFactory to start a jms connection

     *        [spec to jms 1.1 apito get the main idea of it ] 
     *     3> use connection to create a jms session 
     *     4> get a queue destination / messege agent 
     *     5> start the Producer[jms1.1 spec] by a session 
     *     6> get messege Object or initial it yourself by implements the messegeor 

     *        it's sub interfaces 
     *     7> call sender or send it selfing 
     *     8> finallized the connection object or it will throw a warning to you! 
     * 
     * @param messege 
     * @throws NamingException 
     * @throws JMSException 
     */  
    public void sendingProcessing(String messege) throws NamingException, JMSException{  
        Context ctx = new InitialContext();  
        ConnectionFactory cf = (ConnectionFactory) ctx.lookup("java:JmsXA");  
        Connection conn = cf.createConnection();  
        Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);  
        Destination dest = (Queue) ctx.lookup("queue/A");  
        MessageProducer msgp = session.createProducer(dest);  
        QueueSender sender = (QueueSender) msgp;  
        TextMessage msg = session.createTextMessage();  
        msg.setText(messege);  
        sender.send(msg);  
        conn.close();  
    }  
     
     
     
    /** 
     * @author zuly 
     * 
     * following jms ptp domain, use an simple text message to test 
     * 
     * A jms ptp retriver will following the steps below! 
     *     1> get an ConnectionFactory use JNDI Lookup Or Initial it yourself 
     *     2> use this ConnectionFactory to start a jms connection 
     *        [spec to jms 1.1 api to get the main idea of it ] 
     *     3> use connection to create a jms session 
     *     4> get a queue destination / messege agent 
     *     5> retrive a consumer from session 
     *     6> start the jms connection to retrivte the message 
     *     7> get message from consumer 
     *  
     * @return textMessege 
     * @throws NamingException 
     * @throws JMSException 
     */  
    public String retriveingProcessing() throws NamingException, JMSException{  
        Context ctx = new InitialContext();  
        ConnectionFactory cf = (ConnectionFactory) ctx.lookup("java:JmsXA");  
        Connection conn = cf.createConnection();  
        Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);  
        Destination dest = (Queue) ctx.lookup("queue/A");  
        MessageConsumer msgconsumer = session.createConsumer(dest);  
        //MessageListener ml = new JmsListenner();  
        //msgconsumer.setMessageListener(ml);  
        conn.start();  
        TextMessage msg = (TextMessage) msgconsumer.receive();  
        conn.close();  
        System.out.println("messege is" + msg.getText());  
        return msg.getText();  
    }  
}  
package com.javaeye.jms.jboss;  
  
import javax.jms.Connection;  
import javax.jms.ConnectionFactory;  
import javax.jms.Destination;  
import javax.jms.JMSException;  
import javax.jms.MessageConsumer;  
import javax.jms.MessageProducer;  
import javax.jms.Queue;  
import javax.jms.QueueSender;  
import javax.jms.Session;  
import javax.jms.TextMessage;  
import javax.naming.Context;  
import javax.naming.InitialContext;  
import javax.naming.NamingException;  
  
public class JbossNativeJmsImpl {  
     
    /** 
     * @author zuly 
     * 
     * following jms ptp domain, use an simple text message to test 
     * 
     * A jms ptp sender will following the steps below! 
     *     1> get an ConnectionFactory use JNDI Lookup Or Initial it yourself 
     *     2> use this ConnectionFactory to start a jms connection

     *        [spec to jms 1.1 apito get the main idea of it ] 
     *     3> use connection to create a jms session 
     *     4> get a queue destination / messege agent 
     *     5> start the Producer[jms1.1 spec] by a session 
     *     6> get messege Object or initial it yourself by implements the messegeor 

     *        it's sub interfaces 
     *     7> call sender or send it selfing 
     *     8> finallized the connection object or it will throw a warning to you! 
     * 
     * @param messege 
     * @throws NamingException 
     * @throws JMSException 
     */  
    public void sendingProcessing(String messege) throws NamingException, JMSException{  
        Context ctx = new InitialContext();  
        ConnectionFactory cf = (ConnectionFactory) ctx.lookup("java:JmsXA");  
        Connection conn = cf.createConnection();  
        Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);  
        Destination dest = (Queue) ctx.lookup("queue/A");  
        MessageProducer msgp = session.createProducer(dest);  
        QueueSender sender = (QueueSender) msgp;  
        TextMessage msg = session.createTextMessage();  
        msg.setText(messege);  
        sender.send(msg);  
        conn.close();  
    }  
     
     
     
    /** 
     * @author zuly 
     * 
     * following jms ptp domain, use an simple text message to test 
     * 
     * A jms ptp retriver will following the steps below! 
     *     1> get an ConnectionFactory use JNDI Lookup Or Initial it yourself 
     *     2> use this ConnectionFactory to start a jms connection 
     *        [spec to jms 1.1 api to get the main idea of it ] 
     *     3> use connection to create a jms session 
     *     4> get a queue destination / messege agent 
     *     5> retrive a consumer from session 
     *     6> start the jms connection to retrivte the message 
     *     7> get message from consumer 
     *  
     * @return textMessege 
     * @throws NamingException 
     * @throws JMSException 
     */  
    public String retriveingProcessing() throws NamingException, JMSException{  
        Context ctx = new InitialContext();  
        ConnectionFactory cf = (ConnectionFactory) ctx.lookup("java:JmsXA");  
        Connection conn = cf.createConnection();  
        Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);  
        Destination dest = (Queue) ctx.lookup("queue/A");  
        MessageConsumer msgconsumer = session.createConsumer(dest);  
        //MessageListener ml = new JmsListenner();  
        //msgconsumer.setMessageListener(ml);  
        conn.start();  
        TextMessage msg = (TextMessage) msgconsumer.receive();  
        conn.close();  
        System.out.println("messege is" + msg.getText());  
        return msg.getText();  
    }  
}  
package com.javaeye.jms.jboss;  
  
import javax.jms.Connection;  
import javax.jms.ConnectionFactory;  
import javax.jms.Destination;  
import javax.jms.JMSException;  
import javax.jms.MessageConsumer;  
import javax.jms.MessageProducer;  
import javax.jms.Queue;  
import javax.jms.QueueSender;  
import javax.jms.Session;  
import javax.jms.TextMessage;  
import javax.naming.Context;  
import javax.naming.InitialContext;  
import javax.naming.NamingException;  
  
public class JbossNativeJmsImpl {  
     
    /** 
     * @author zuly 
     * 
     * following jms ptp domain, use an simple text message to test 
     * 
     * A jms ptp sender will following the steps below! 
     *     1> get an ConnectionFactory use JNDI Lookup Or Initial it yourself 
     *     2> use this ConnectionFactory to start a jms connection

     *        [spec to jms 1.1 apito get the main idea of it ] 
     *     3> use connection to create a jms session 
     *     4> get a queue destination / messege agent 
     *     5> start the Producer[jms1.1 spec] by a session 
     *     6> get messege Object or initial it yourself by implements the messegeor 

     *        it's sub interfaces 
     *     7> call sender or send it selfing 
     *     8> finallized the connection object or it will throw a warning to you! 
     * 
     * @param messege 
     * @throws NamingException 
     * @throws JMSException 
     */  
    public void sendingProcessing(String messege) throws NamingException, JMSException{  
        Context ctx = new InitialContext();  
        ConnectionFactory cf = (ConnectionFactory) ctx.lookup("java:JmsXA");  
        Connection conn = cf.createConnection();  
        Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);  
        Destination dest = (Queue) ctx.lookup("queue/A");  
        MessageProducer msgp = session.createProducer(dest);  
        QueueSender sender = (QueueSender) msgp;  
        TextMessage msg = session.createTextMessage();  
        msg.setText(messege);  
        sender.send(msg);  
        conn.close();  
    }  
     
     
     
    /** 
     * @author zuly 
     * 
     * following jms ptp domain, use an simple text message to test 
     * 
     * A jms ptp retriver will following the steps below! 
     *     1> get an ConnectionFactory use JNDI Lookup Or Initial it yourself 
     *     2> use this ConnectionFactory to start a jms connection 
     *        [spec to jms 1.1 api to get the main idea of it ] 
     *     3> use connection to create a jms session 
     *     4> get a queue destination / messege agent 
     *     5> retrive a consumer from session 
     *     6> start the jms connection to retrivte the message 
     *     7> get message from consumer 
     *  
     * @return textMessege 
     * @throws NamingException 
     * @throws JMSException 
     */  
    public String retriveingProcessing() throws NamingException, JMSException{  
        Context ctx = new InitialContext();  
        ConnectionFactory cf = (ConnectionFactory) ctx.lookup("java:JmsXA");  
        Connection conn = cf.createConnection();  
        Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);  
        Destination dest = (Queue) ctx.lookup("queue/A");  
        MessageConsumer msgconsumer = session.createConsumer(dest);  
        //MessageListener ml = new JmsListenner();  
        //msgconsumer.setMessageListener(ml);  
        conn.start();  
        TextMessage msg = (TextMessage) msgconsumer.receive();  
        conn.close();  
        System.out.println("messege is" + msg.getText());  
        return msg.getText();  
    }  
}  






















相关推荐

    使用DbUnit测试数据库.pdf

    使用DbUnit测试数据库.pdf

    使用dbunit测试数据库

    1。利用MySql数据库建立一个测试的数据库student: 2.建立新的java工程,例如DBUnitSample, 将DbUnit jar文件和MySql数据库驱动文件导入到工程中: 3.编写连接MySql数据库的类以及用于测试的类

    Dbunit数据库连接下载

    java连接数据库最好的选择,可以用于,flash能过控制java来运用数据库

    dbunit数据库测试工具

    用于数据库测试的一个工具,具有很强的灵活性。也是自己在网上找的,分享一下

    DBUNIT 基类DBUNIT 基类DBUNIT 基类DBUNIT 基类DBUNIT 基类

    DBUNIT 基类DBUNIT 基类DBUNIT 基类DBUNIT 基类DBUNIT 基类DBUNIT 基类DBUNIT 基类DBUNIT 基类DBUNIT 基类DBUNIT 基类DBUNIT 基类DBUNIT 基类DBUNIT 基类DBUNIT 基类DBUNIT 基类DBUNIT 基类DBUNIT 基类DBUNIT 基类...

    DBUNIT使用

    DBUNIT使用的详细文档

    dbunit2.2

    dbunit2.2完全包 数据库单元测试

    dbunit使用必需Jar包

    dbunit使用必需Jar包,总共4个必需Jar包

    DBUnit使用文档

    文档是关于DBUnit的ant的使用文档,通俗易懂

    数据库单元测试

    有了DBUnit,一切都变了,DBUnit的目的就是在每个单元测试运行之前将数据库初始化成一个预定义的状态,以保证单元测试时的断言不会因为数据库状态发生了变化而失败,同时可以解决前一个单元测试失败导致对数据库的...

    dbunit-2.4.7.rar

    Dbunit 基本原理就是在跑测试用例运行之前对数据表做用户定义的操作,清空不想要的数据,插入用户自定义的数据,使得该数据表处于用户知道的一种状态。而用户自定义的数据使用项目里的一个 xml 文件来表示。 Xml ...

    介绍dbunit的使用和原理,核心组件介绍

    介绍dbunit的使用和原理,核心组件介绍

    DBUNIT使用手册

    介绍了DBUNIT最新版的使用方法。并给出了一个详细的例子

    dbunit-2.4.7所有jar以及dbunit入门教程

    最新的最全的dbunit jar包以及入门教程

    dbunit-2.4.9 源码

    dbunit-2.4.9 源码 http://www.dbunit.org/apidocs/index.html 代码 API

    dbunit使用实例

    用dbunit的两个例子,很不错,有帮助

    数据库操作的单元测试

    3.2. DBunit使用最佳实践 9 3.2.1. 每一个开发人员需要搞一个数据库实例。 9 3.2.2. 使用XML文件作为DataSet 9 3.2.3. DBUnit的最佳实践是尽可能使用最小的数据集。 10 3.2.4. DatabaseOperation.CLEAN_INSERT 策略 ...

    dbunit-2.4.7.jar下载

    DbUnit(http://dbunit.sourceforge.net/)则是专 门针对数据库测试的对JUnit的一个扩展, 它可以将测试对象数据库置于一个测试轮回之间的状态。 这个是主要jar包

    如何使用DBUnit做数据备份恢复

    NULL 博文链接:https://kanglecjr.iteye.com/blog/2158320

    DBUnit 进行单元测试

    一个很好的DBUnit的例子 博文链接:https://virgoooos.iteye.com/blog/186859

Global site tag (gtag.js) - Google Analytics