package durable.subscriber;

import implementation.ClientJMS;

import javax.jms.Connection;
import javax.jms.ConnectionFactory;

import javax.jms.JMSException;


import javax.jms.Session;



/* Annick Fron
 * Reception d'un Topic a posteriori
 */

public class Desinscription extends ClientJMS {

	/**
	 * @param args
	 */
	public static void main(String[] args) {

		new Desinscription().run();
	}

	public void run() {
		ConnectionFactory cf = getConnectionFactory();
		Connection connexion;
		try {
			connexion = cf.createConnection();
			// mettre un ID a la connexion
			connexion.setClientID("Client1");
			Session session = connexion.createSession(false,
					Session.AUTO_ACKNOWLEDGE);
	
			session.unsubscribe("Abonnement1");

			// ne pas oublier de demarrer la connexion
			connexion.start();
	
			connexion.close();

		} catch (JMSException e) {
			
			System.out.println(e.getMessage());
		}
		
	}
}
