Hi Tim,
Is my first time with Java Client... my code is:
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();
}
}
2011/8/11 Timothy Bish <[email protected]>
> On Thu, 2011-08-11 at 16:42 +0200, Oscar Pernas wrote:
> > Hi all,
> >
> > Im using Java Client to make a small application to catch all advisory
> > messages from the broker. Ive set the following connection string:
> >
> > failover://(tcp://localhost:61616)
> >
> >
> > The application starts succesfully, but if I stop the broker, after a few
> > secons, my application exits. The last message that I could read is:
> >
> > org.apache.activemq.transport.failover.FailoverTransport
> > handleTransportFailure
> > Transport failed to tcp://localhost:61616 , attempting to automatically
> > reconnect due to: java.io.EOFException
> >
> >
> > If I shutdown and start the broker quickly, the application still
> continue
> > receiving data. I've set so many different connection parameters like
> > soTimeout, maxConnectionAttemps, but nothing works.
> >
>
> We'd probably need to see the app code to tell for sure, sound like you
> are dropping out due to an exception listener or something but can't
> really tell without code.
>
> Regards
>
> --
> Tim Bish
> ------------
> FuseSource
> Email: [email protected]
> Web: http://fusesource.com
> Twitter: tabish121
> Blog: http://timbish.blogspot.com/
>
>
>
>
--
Óscar Pernas Plaza.