User development, A new message was posted in the thread "Problem with cluster failover.":
http://community.jboss.org/message/518899#518899 Author : Krystian Siuda Profile : http://community.jboss.org/people/ksiuda Message: -------------------------------------------------------------- Hi, When an Exception is thrown dealing with Connection/Session/Producer(in the "sender" thread)/Consumer(in the "receiver" thread) the connection is restarted compleatly. The Exception you qoted ("Maximum number of failover attempts exceeded.") has been thrown only by the "receiver" thread, I think that the "prodcuer" was allready blocked at that time (I can check it to be sure if it's revelant). This is how I handle Exceptions in "sender" ("receiver" is very simmilar, this is very dirty code..sorry): public static void sendWrap(ConnectionFactory cf, Destination target) { for(;;) { // just loop forever try { Thread.sleep(1000); send(cf, target); } catch (Exception e) { if(e instanceof InterruptedException) { LOGGER.info("exiting sender", e); return; } else { LOGGER.warn("send got exception", e); } } } } and the "send" method: public static void send(ConnectionFactory cf, Destination target) throws Exception { Connection connection = null; try { connection = cf.createConnection("ecm-user", "ecm-user"); Session session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE); MessageProducer producer = session.createProducer(target); connection.start(); LOGGER.info("Sending"); for(;;) { // some uniq id generation was here TextMessage message = session.createTextMessage(id + "~" + new Date() + "~" + GarbageGenerator.getGarbage()); message.setJMSDeliveryMode(DeliveryMode.PERSISTENT); producer.send(message); if(LOGGER.isTraceEnabled()) { LOGGER.trace("Sent message no: " + id + " id: " + message.getJMSMessageID() + " : " + message.getText()); } else { LOGGER.info("Sent message no: " + id + " id: " + message.getJMSMessageID()); } Thread.sleep(500); if(Thread.interrupted()) { LOGGER.info("sender interrupted"); throw new InterruptedException(); } } } finally { if(connection != null) { connection.close(); } } } The "receiver" and "sender" threads are using two separate ConnectionFactories and Destinations. Those are taken from two separate JNDI lookups. That's because I needed a tool that can send&receive messages from different servers. This is the initialization code: Properties senderProps = new Properties(); senderProps.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory"); senderProps.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces"); senderProps.put(Context.PROVIDER_URL, senderJNP); Properties receiverProps = new Properties(); receiverProps.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory"); receiverProps.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces"); receiverProps.put(Context.PROVIDER_URL, receiverJNP); // Step 1. Create an initial context to perform the JNDI lookup. senderInitialContext = new InitialContext(senderProps); receiverInitialContext = new InitialContext(receiverProps); // Step 3. Perform a lookup on the Connection Factory final ConnectionFactory senderConnectionFactory = (ConnectionFactory)senderInitialContext.lookup(senderCF); final ConnectionFactory receiverConnectionFactory = (ConnectionFactory)senderInitialContext.lookup(receiverCF); // Step 2. Perfom a lookup on the queue final Destination senderTarget = (Destination)senderInitialContext.lookup(senderDest); final Destination receiverTarget = (Destination)senderInitialContext.lookup(receiverDest); Same situation takes place when I'm using HA-JNDI for the lookup (port 1100). Krystian. -------------------------------------------------------------- To reply to this message visit the message page: http://community.jboss.org/message/518899#518899
_______________________________________________ jboss-user mailing list [email protected] https://lists.jboss.org/mailman/listinfo/jboss-user
