package mapmessage;

import implementation.ClientJMS;

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

import javax.jms.MessageProducer;

import javax.jms.Session;



/* Annick Fron
 * Envoi de donnees dans un MapMessage
 */


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);
			MapMessage message= session.createMapMessage();
			message.setString("Article", "Ordinateur");
			message.setInt("Quantite", 4);
			sender.send( message);
			session.close();
			connexion.close();
			System.out.println("Message envoye");


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