package it.mice.voila.runtime.runtime.jms.test;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;


/**
 *
 */
public class JMSMessageServiceExampleListener implements MessageListener{

	/** {@inheritDoc}
	 * @see javax.jms.MessageListener#onMessage(javax.jms.Message)
	 */
	public void onMessage(Message message) {
		  try {
			  System.out.println("eccomi");
	            System.out.println(this + " : Message Driven POJO received message");
	            System.out.println(message);

	            if(message instanceof TextMessage) {
	                System.out.println(this + " : " + ((TextMessage) message).getText());
	            }
	            else {
	                System.out.println(this + " : " + message.toString());
	            }
	            Thread.sleep(10000);
	            System.out.println("Terminato");
	        }
	        catch (JMSException ex){
	            throw new RuntimeException(ex);
	        } catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
    }
}
