package acquittement.manuel;

import implementation.ClientJMS;

import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.MessageProducer;

import javax.jms.Session;
import javax.jms.TextMessage;


/* Annick Fron
 * A Lancer avant le recepteur
 */


public class Emetteur extends ClientJMS {


	public static void main(String[] args) {
	
		new Emetteur().run();
	}
	public void run() {

		try {
			ConnectionFactory cf=getConnectionFactory();
			Connection connexion= cf.createConnection();
			Session session = connexion.createSession(false, Session.AUTO_ACKNOWLEDGE);
			Destination queue = session.createQueue("SampleQ1");
			MessageProducer sender = session.createProducer(queue);
			// envoi de deux messages
			TextMessage mess= session.createTextMessage("Hello");
			sender.send( mess);
			mess= session.createTextMessage("Hello");
			sender.send( mess);
			session.close();
			connexion.close();
			System.out.println("Message envoye");


		} catch (JMSException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
