On Thu, 2011-08-11 at 17:06 +0200, Oscar Pernas wrote:
> public class SubscribeAdvisory implements MessageListener{
> 
>     private Logger mLogger = Logger.getLogger(getClass());
> 
>     private Connection connection;
>     private Session session;
> 
>     //ParĂ¡metros propios JMS
>     private String clientId="Connection_Advisories_client";
>     private String username="";
>     private String password="";
>     private String url="";
> 
> public static void main(String[] args) {
>     SubscribeAdvisory ClientConsumer = new SubscribeAdvisory();
>     ClientConsumer.run();
>  }
> 
> public void run(){
> try {
>  ServiceLocator.getInstance().getApplicationConfig();
> mLogger.warn("--------SubscribeAdvisory---------------");
>                mLogger.warn("---username     :"+username);
>              mLogger.warn("---pwd   :"+password);
>                mLogger.warn("---URL     :"+url);
>                mLogger.warn("---CLIENTID     :"+clientId);
>              mLogger.warn("----------------------------------------");
> 
>                         ActiveMQConnectionFactory connectionFactory =
> new
> ActiveMQConnectionFactory(username, password, url);
> 
> connection = connectionFactory.createConnection();
> connection.setClientID(clientId);
>  connection.start();
>  session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
> 
> Topic connectionAdvisory = AdvisorySupport.CONNECTION_ADVISORY_TOPIC;
>  MessageConsumer consumer =
> session.createConsumer(connectionAdvisory);
>  consumer.setMessageListener(this);
>  } catch (Exception e) {
>              mLogger.error("Exception run client: " + e);
>  e.printStackTrace();
>     }
>     }
>  public void onMessage(Message message) {
> try {
> ActiveMQMessage messageMQ = (ActiveMQMessage) message;
>  DataStructure data = (DataStructure)messageMQ.getDataStructure();
>  if (data.getDataStructureType() ==
> ConnectionInfo.DATA_STRUCTURE_TYPE){
> ConnectionInfo connectionInfo = (ConnectionInfo) data;
>  mLogger.warn("CONNECT---->: "+connectionInfo.getConnectionId());
> }else if (data.getDataStructureType() ==
> RemoveInfo.DATA_STRUCTURE_TYPE){
>  RemoveInfo removeInfo = (RemoveInfo) data;
> mLogger.info("DESCONNECT  : "+removeInfo.getObjectId());
>  }else {
> mLogger.info("Unknow message : "+data);
>      }
> 
> 
>         } catch (Exception e) {
>         mLogger.error("Exception OnMessage: " + e);
>             e.printStackTrace();
>         }
> } 

Your app has nothing to keep it running if the only threads that are
active at some point are daemon threads which happens when the failed
transport gets destroyed.  You need to add something into you app to
keep it running like reading from standard input or something.

Regards


-- 
Tim Bish
------------
FuseSource
Email: tim.b...@fusesource.com
Web: http://fusesource.com
Twitter: tabish121
Blog: http://timbish.blogspot.com/



Reply via email to