Hi Nirmal, With using following[1] kind of code segment we ll be able to do that.
Thanks Shammi [1] while (true) { try { TextMessage textMessage = (TextMessage) topicSubscriber.receive(); if (textMessage != null) { System.out.println("textMessage = " + textMessage); } } catch (JMSException e) { try { if (topicSubscriber != null) { topicSubscriber.close(); } if (topicSession != null) { topicSession.close(); } if (topicConnection != null) { topicConnection.close(); } } catch (JMSException e1) { //ignore } finally { try { topicConnection = topicConnectionFactory.createTopicConnection(); topicConnection.start(); topicSession = topicConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE); topic = (Topic)ctx.lookup(topicName); topicSubscriber = topicSession.createSubscriber(topic); } catch (NamingException e1) { e1.printStackTrace(); } catch (JMSException e1) { e1.printStackTrace(); } } } } On Wed, May 29, 2013 at 10:17 AM, Shammi Jayasinghe <sha...@wso2.com> wrote: > Hi Nirmal, > > As we discussed offline, we ll have to retry for creating the connection > to the server , once it is got disconnected. AFAIK we need to handle it > with our client code to make the connection to the server once it got > disconnected. > > Thanks > Shammi > > > > On Tue, May 28, 2013 at 9:31 PM, Nirmal Fernando <nir...@wso2.com> wrote: > >> Hi Shammi, >> >> This still fails to me. When I shutdown the server where the topic lives, >> I see following error [1]. >> >> Note that what I'm using is a Topic. >> >> And my client is at [2], am I doing something wrong? >> >> [1] >> >> TID: [0] [ELB] [2013-05-28 15:12:47,589] ERROR >> {org.wso2.andes.client.state.AMQStateManager} - No Waiters for error >> saving as last error:Exception thrown against AMQConnection: >> >> Host: cc.wso2.com >> Port: 5673 >> Virtual Host: carbon >> Client ID: clientID >> Active session count: 1: org.wso2.andes.AMQDisconnectedException: Server >> closed connection and reconnection not permitted. >> {org.wso2.andes.client.state.AMQStateManager} >> TID: [0] [ELB] [2013-05-28 15:12:47,590] ERROR >> {org.wso2.andes.client.AMQConnection} - Throwable Received but no listener >> set: org.wso2.andes.AMQDisconnectedException: Server closed connection and >> reconnection not permitted. {org.wso2.andes.client.AMQConnection} >> >> >> [2] >> >> Properties initialContextProperties = new Properties(); >> initialContextProperties.put("java.naming.factory.initial", >> "org.wso2.andes.jndi.PropertiesFileInitialContextFactory"); >> >> String mbServerUrl = null; >> if (ConfigHolder.getInstance().getLbConfig() != null) { >> mbServerUrl = >> ConfigHolder.getInstance().getLbConfig().getLoadBalancerConfig().getMbServerUrl(); >> >> } >> String connectionString = >> "amqp://admin:admin@clientID/carbon?brokerlist='tcp://" + >> (mbServerUrl == null ? >> TopologyConstants.DEFAULT_MB_SERVER_URL : mbServerUrl) + >> "'&reconnect='true'"; >> >> initialContextProperties.put("connectionfactory.qpidConnectionfactory", >> connectionString); >> >> try { >> InitialContext initialContext = new >> InitialContext(initialContextProperties); >> TopicConnectionFactory topicConnectionFactory = >> (TopicConnectionFactory) >> initialContext.lookup("qpidConnectionfactory"); >> TopicConnection topicConnection = >> topicConnectionFactory.createTopicConnection(); >> topicConnection.start(); >> TopicSession topicSession = >> topicConnection.createTopicSession(false, >> Session.AUTO_ACKNOWLEDGE); >> >> Topic topic = topicSession.createTopic(topicName); >> TopicSubscriber topicSubscriber = >> topicSession.createSubscriber(topic); >> >> topicSubscriber.setMessageListener(new TopologyListener()); >> >> } catch (NamingException e) { >> log.error(e.getMessage(), e); >> } catch (JMSException e) { >> log.error(e.getMessage(), e); >> } >> >> >> >> On Mon, May 27, 2013 at 10:46 PM, Nirmal Fernando <nir...@wso2.com>wrote: >> >>> Great... Thanks a lot Shammi!! I'll try this. >>> >>> >>> On Mon, May 27, 2013 at 10:44 PM, Shammi Jayasinghe <sha...@wso2.com>wrote: >>> >>>> Hi Nirmal, >>>> >>>> It seems the problem is with your connection URL. The way you have >>>> created the connection string should be as bellow[1]. I have checked and >>>> verified the the re-connection of the subscriber with the following client >>>> code[2]. >>>> >>>> [1] >>>> String connectionString = "amqp://admin:admin@clientID >>>> /carbon?brokerlist='tcp://localhost:5672'&reconnect='true'"; >>>> >>>> [2] >>>> Properties initialContextProperties = new Properties(); >>>> initialContextProperties.put("java.naming.factory.initial", >>>> >>>> "org.wso2.andes.jndi.PropertiesFileInitialContextFactory"); >>>> String connectionString = "amqp://admin:admin@clientID >>>> /carbon?brokerlist='tcp://localhost:5672'&reconnect='true'"; >>>> >>>> initialContextProperties.put("connectionfactory.qpidConnectionfactory", >>>> connectionString); >>>> String queueName = "bar"; >>>> initialContextProperties.put("queue."+queueName, queueName); >>>> >>>> >>>> try { >>>> InitialContext initialContext = new >>>> InitialContext(initialContextProperties); >>>> ConnectionFactory queueConnectionFactory >>>> = (ConnectionFactory) >>>> initialContext.lookup("qpidConnectionfactory"); >>>> Destination destination = (Destination) >>>> initialContext.lookup(queueName); >>>> int count = 0; >>>> >>>> Connection queueConnection = >>>> queueConnectionFactory.createConnection(); >>>> queueConnection.start(); >>>> >>>> >>>> try { >>>> Session queueSession = >>>> queueConnection.createSession(false, QueueSession.AUTO_ACKNOWLEDGE); >>>> >>>> >>>> MessageConsumer messageConsumer = >>>> queueSession.createConsumer(destination); >>>> while (true) { >>>> >>>> try { >>>> TextMessage textMessage = (TextMessage) >>>> messageConsumer.receive(); >>>> if (textMessage != null) { >>>> textMessage.getJMSRedelivered(); >>>> System.out.println("textMessage = " + >>>> textMessage); >>>> System.out.println("got the message = " + >>>> count); >>>> System.out.println("ReceivedTime = " + >>>> System.currentTimeMillis()); >>>> count++; >>>> } >>>> } catch (JMSException e) { >>>> .. >>>> >>>> Thanks >>>> Shammi >>>> >>>> >>>> >>>> On Mon, May 27, 2013 at 7:53 PM, Nirmal Fernando <nir...@wso2.com>wrote: >>>> >>>>> Hasitha/Shammi, >>>>> >>>>> Any help on this would be appreciated. >>>>> >>>>> >>>>> On Sun, May 26, 2013 at 3:19 PM, Nirmal Fernando <nir...@wso2.com>wrote: >>>>> >>>>>> Exactly Paul. But it seems not happening in my subscriber, hence I >>>>>> wanted to know, what I'm doing wrong. >>>>>> >>>>>> >>>>>> On Sun, May 26, 2013 at 3:11 PM, Paul Fremantle <p...@wso2.com>wrote: >>>>>> >>>>>>> Ok. So I have a subscriber to a topic. The server goes down. The >>>>>>> client should automatically reconnect and resubscribe. Yes I agree! >>>>>>> >>>>>>> Paul >>>>>>> >>>>>>> >>>>>>> On 26 May 2013 10:13, Nirmal Fernando <nir...@wso2.com> wrote: >>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> On Sun, May 26, 2013 at 2:15 PM, Paul Fremantle <p...@wso2.com>wrote: >>>>>>>> >>>>>>>>> I don't understand: the topic subscribers should be completely >>>>>>>>> independent of the publisher. The subscribers should not be >>>>>>>>> disconnected at >>>>>>>>> all, let alone needing to reconnect. >>>>>>>>> >>>>>>>> >>>>>>>> Ok... now I get why you all didn't understand :-) ... sorry, my >>>>>>>> bad. What I wanted to say was "when the topic got re-created (eg: MB >>>>>>>> (where >>>>>>>> the topic lives) got restarted), subscribers didn't reconnect." >>>>>>>> >>>>>>>>> >>>>>>>>> Paul >>>>>>>>> >>>>>>>>> >>>>>>>>> On 25 May 2013 14:38, Nirmal Fernando <nir...@wso2.com> wrote: >>>>>>>>> >>>>>>>>>> Hi All, >>>>>>>>>> >>>>>>>>>> I've a topic publisher and set of subscribers. When the publisher >>>>>>>>>> is restarted, subscribers do not reconnect. >>>>>>>>>> >>>>>>>>>> Following log [1] can be seen in a subscriber. >>>>>>>>>> >>>>>>>>>> Subscriber's code is at [2]. >>>>>>>>>> >>>>>>>>>> What am I missing in the code? >>>>>>>>>> >>>>>>>>>> [1] >>>>>>>>>> >>>>>>>>>> TID: [0] [SCC] [2013-05-24 16:10:04,981] ERROR >>>>>>>>>> {org.wso2.andes.client.state.AMQStateManager} - No Waiters for error >>>>>>>>>> saving as last error:Exception thrown against AMQConnection: >>>>>>>>>> Host: cc.wso2.com >>>>>>>>>> Port: 5673 >>>>>>>>>> Virtual Host: carbon >>>>>>>>>> Client ID: clientID >>>>>>>>>> Active session count: 1: org.wso2.andes.AMQDisconnectedException: >>>>>>>>>> Server closed connection and reconnection not permitted. >>>>>>>>>> {org.wso2.andes.client.state.AMQStateManager} >>>>>>>>>> TID: [0] [SCC] [2013-05-24 16:10:04,982] ERROR >>>>>>>>>> {org.wso2.andes.client.AMQConnection} - Throwable Received but no >>>>>>>>>> listener >>>>>>>>>> set: org.wso2.andes.AMQDisconnectedException: Server closed >>>>>>>>>> connection and >>>>>>>>>> reconnection not permitted. {org.wso2.andes.client.AMQConnection} >>>>>>>>>> >>>>>>>>>> [2] >>>>>>>>>> >>>>>>>>>> Properties initialContextProperties = new Properties(); >>>>>>>>>> >>>>>>>>>> initialContextProperties.put("java.naming.factory.initial", >>>>>>>>>> >>>>>>>>>> "org.wso2.andes.jndi.PropertiesFileInitialContextFactory"); >>>>>>>>>> >>>>>>>>>> String connectionString = >>>>>>>>>> "amqp://admin:admin@clientID/carbon?brokerlist='tcp://" >>>>>>>>>> + >>>>>>>>>> mbServerIp + "?reconnect='true''"; >>>>>>>>>> >>>>>>>>>> initialContextProperties.put("connectionfactory.qpidConnectionfactory", >>>>>>>>>> connectionString); >>>>>>>>>> >>>>>>>>>> try { >>>>>>>>>> InitialContext initialContext = new >>>>>>>>>> InitialContext(initialContextProperties); >>>>>>>>>> TopicConnectionFactory topicConnectionFactory = >>>>>>>>>> (TopicConnectionFactory) >>>>>>>>>> initialContext.lookup("qpidConnectionfactory"); >>>>>>>>>> TopicConnection topicConnection = >>>>>>>>>> topicConnectionFactory.createTopicConnection(); >>>>>>>>>> topicConnection.start(); >>>>>>>>>> TopicSession topicSession = >>>>>>>>>> topicConnection.createTopicSession(false, >>>>>>>>>> Session.AUTO_ACKNOWLEDGE); >>>>>>>>>> >>>>>>>>>> Topic topic = topicSession.createTopic(topicName); >>>>>>>>>> TopicSubscriber topicSubscriber = >>>>>>>>>> topicSession.createSubscriber(topic); >>>>>>>>>> >>>>>>>>>> topicSubscriber.setMessageListener(new >>>>>>>>>> TopologyListener()); >>>>>>>>>> >>>>>>>>>> } catch (NamingException e) { >>>>>>>>>> log.error(e.getMessage(), e); >>>>>>>>>> } catch (JMSException e) { >>>>>>>>>> log.error(e.getMessage(), e); >>>>>>>>>> } >>>>>>>>>> >>>>>>>>>> -- >>>>>>>>>> >>>>>>>>>> Thanks & regards, >>>>>>>>>> Nirmal >>>>>>>>>> >>>>>>>>>> Senior Software Engineer- Platform Technologies Team, WSO2 Inc. >>>>>>>>>> Mobile: +94715779733 >>>>>>>>>> Blog: http://nirmalfdo.blogspot.com/ >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> _______________________________________________ >>>>>>>>>> Dev mailing list >>>>>>>>>> Dev@wso2.org >>>>>>>>>> http://wso2.org/cgi-bin/mailman/listinfo/dev >>>>>>>>>> >>>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> -- >>>>>>>>> Paul Fremantle >>>>>>>>> CTO and Co-Founder, WSO2 >>>>>>>>> OASIS WS-RX TC Co-chair, VP, Apache Synapse >>>>>>>>> >>>>>>>>> UK: +44 207 096 0336 >>>>>>>>> US: +1 646 595 7614 >>>>>>>>> >>>>>>>>> blog: http://pzf.fremantle.org >>>>>>>>> twitter.com/pzfreo >>>>>>>>> p...@wso2.com >>>>>>>>> >>>>>>>>> wso2.com Lean Enterprise Middleware >>>>>>>>> >>>>>>>>> Disclaimer: This communication may contain privileged or other >>>>>>>>> confidential information and is intended exclusively for the >>>>>>>>> addressee/s. >>>>>>>>> If you are not the intended recipient/s, or believe that you may have >>>>>>>>> received this communication in error, please reply to the sender >>>>>>>>> indicating >>>>>>>>> that fact and delete the copy you received and in addition, you >>>>>>>>> should not >>>>>>>>> print, copy, retransmit, disseminate, or otherwise use the information >>>>>>>>> contained in this communication. Internet communications cannot be >>>>>>>>> guaranteed to be timely, secure, error or virus-free. The sender does >>>>>>>>> not >>>>>>>>> accept liability for any errors or omissions. >>>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> -- >>>>>>>> >>>>>>>> Thanks & regards, >>>>>>>> Nirmal >>>>>>>> >>>>>>>> Senior Software Engineer- Platform Technologies Team, WSO2 Inc. >>>>>>>> Mobile: +94715779733 >>>>>>>> Blog: http://nirmalfdo.blogspot.com/ >>>>>>>> >>>>>>>> >>>>>>> >>>>>>> >>>>>>> -- >>>>>>> Paul Fremantle >>>>>>> CTO and Co-Founder, WSO2 >>>>>>> OASIS WS-RX TC Co-chair, VP, Apache Synapse >>>>>>> >>>>>>> UK: +44 207 096 0336 >>>>>>> US: +1 646 595 7614 >>>>>>> >>>>>>> blog: http://pzf.fremantle.org >>>>>>> twitter.com/pzfreo >>>>>>> p...@wso2.com >>>>>>> >>>>>>> wso2.com Lean Enterprise Middleware >>>>>>> >>>>>>> Disclaimer: This communication may contain privileged or other >>>>>>> confidential information and is intended exclusively for the >>>>>>> addressee/s. >>>>>>> If you are not the intended recipient/s, or believe that you may have >>>>>>> received this communication in error, please reply to the sender >>>>>>> indicating >>>>>>> that fact and delete the copy you received and in addition, you should >>>>>>> not >>>>>>> print, copy, retransmit, disseminate, or otherwise use the information >>>>>>> contained in this communication. Internet communications cannot be >>>>>>> guaranteed to be timely, secure, error or virus-free. The sender does >>>>>>> not >>>>>>> accept liability for any errors or omissions. >>>>>>> >>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> >>>>>> Thanks & regards, >>>>>> Nirmal >>>>>> >>>>>> Senior Software Engineer- Platform Technologies Team, WSO2 Inc. >>>>>> Mobile: +94715779733 >>>>>> Blog: http://nirmalfdo.blogspot.com/ >>>>>> >>>>>> >>>>> >>>>> >>>>> -- >>>>> >>>>> Thanks & regards, >>>>> Nirmal >>>>> >>>>> Senior Software Engineer- Platform Technologies Team, WSO2 Inc. >>>>> Mobile: +94715779733 >>>>> Blog: http://nirmalfdo.blogspot.com/ >>>>> >>>>> >>>> >>>> >>>> -- >>>> Best Regards,* >>>> >>>> Shammi Jayasinghe* >>>> Senior Software Engineer; WSO2, Inc.; http://wso2.com, >>>> mobile: +94 71 4493085 >>>> >>>> >>> >>> >>> -- >>> >>> Thanks & regards, >>> Nirmal >>> >>> Senior Software Engineer- Platform Technologies Team, WSO2 Inc. >>> Mobile: +94715779733 >>> Blog: http://nirmalfdo.blogspot.com/ >>> >>> >> >> >> -- >> >> Thanks & regards, >> Nirmal >> >> Senior Software Engineer- Platform Technologies Team, WSO2 Inc. >> Mobile: +94715779733 >> Blog: http://nirmalfdo.blogspot.com/ >> >> > > > -- > Best Regards,* > > Shammi Jayasinghe* > Senior Software Engineer; WSO2, Inc.; http://wso2.com, > mobile: +94 71 4493085 > > -- Best Regards,* Shammi Jayasinghe* Senior Software Engineer; WSO2, Inc.; http://wso2.com, mobile: +94 71 4493085
_______________________________________________ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev