You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by dongabda <do...@ikusi.es> on 2009/03/23 17:15:07 UTC

Reconnection

I have a messagebroker and a producer in Java (Both in same PC).
The consumer is in other PC and C++(activemq-cpp.2.2.4)
I use Topics with durableconsumer.
When the messagebroker is stopped and I launch the consumer, it gives a
CMSException. This is perfect. but when all is running (messagebroker,
producer and consumer) if the consumer or producer lost the link, any
exception is launched, and after restore the link, the consumer never
receives any message. 
Why? What can I do to continue receiving messages? 
-- 
View this message in context: http://www.nabble.com/Reconnection-tp22663516p22663516.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Reconnection

Posted by dongabda <do...@ikusi.es>.
The consumer is running in a Linux (Fedora Core 10)
I saw (doing netstat) that the tcp connection appears like ESTABLISHED, and
this is not true because the netkork link is lost.
Any idea?
 

Timothy Bish wrote:
> 
> On Thu, 2009-03-26 at 02:11 -0700, dongabda wrote:
>> Yes, I'm using the excepcionListener and onException, but any exception
>> is
>> captured when the PC lost the network link. If I stop the messagebroker
>> the
>> exception occurs, but with link lost not. How can I resolve it?
>>        
> 
> What OS are you running on?
> 
> 
> -- 
> Tim Bish
> http://fusesource.com
> http://timbish.blogspot.com/
> 
> 
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Reconnection-tp22663516p22725563.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Reconnection

Posted by dongabda <do...@ikusi.es>.
The consumer is running in a PC with linux (Fedora Core10). This PC is
connected to a HUB.
The messagebroker and producer are in other PC and it is connected to other
HUB.
Two HUBS are connected.
The producer is sending messages and consumer receives them well.
When I switch off a HUB, the consumer's listener doesn't catch the
Exception. If I make a netstat in consumer's PC I see that the tcp
connection is established, but is not possible, because the HUB is Down. 
I switch on the HUB again, and the procuder sends messages, but consumer
never receives them.


Andreas Gies-3 wrote:
> 
> Hi,
> 
> perhaps you could come up with a small test case that shows the error ?
> 
> Best regards
> Andreas
> 
> 
> On Mar 26, 2009, at 10:11 AM, dongabda wrote:
> 
>>
>> Yes, I'm using the excepcionListener and onException, but any  
>> exception is
>> captured when the PC lost the network link. If I stop the  
>> messagebroker the
>> exception occurs, but with link lost not. How can I resolve it?
>>
>> -- 
>> View this message in context:
>> http://www.nabble.com/Reconnection-tp22663516p22677750.html
>> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>>
> 
> ---
> Mit freundlichen Grüssen - Kind Regards
> Andreas Gies
> Principal Consultant
> Open Source Center of Competence
> 
> Progress Software GmbH
> Agrippinawerft 26
> 50678 Köln
> 
> E-Mail      	agies@progress.com
> Direct Line 	+49 (0)9953 980349
> Mobile      	+49 (0)170 5759611
> Skype        	+44 (0)20 3239 2922
> Skype       	+353 (0)1 443 4971
> Skype       	+1 (0)781 262 0168
> 
> http://www.progress.com
> http://fusesource.com
> http://open-source-adventures.blogspot.com
> 
> 
> 
> -------------------------------------------------------
> Progress Software GmbH
> Sitz der Gesellschaft: Agrippinawerft 26, 50678 Koeln;
> Niederlassung: Fuerstenrieder Str. 279, 81377 Muenchen
> Amtsgericht Koeln, HRB 15620;
> Geschaeftsfuehrung: David Ireland
> -------------------------------------------------------
> 
> 

-- 
View this message in context: http://www.nabble.com/Reconnection-tp22663516p22726737.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Reconnection

Posted by dongabda <do...@ikusi.es>.
Here is the code, I think can be useful to know the problem.
Thanks for your help.

virtual void run(){
      try {
            // Create a ConnectionFactory
	string brokerURI =
tcp://192.168.233.214:61616?&soLinger=10000&soKeepAlive=true		
            auto_ptr<ConnectionFactory> connectionFactory(
                ConnectionFactory::createCMSConnectionFactory( brokerURI )
);
            // Create a Connection
            connection = connectionFactory->createConnection("","","Test1");
            connection->start();
            connection->setExceptionListener(this);
            // Create a Session
            if( this->sessionTransacted == true ) {
                session = connection->createSession(
Session::SESSION_TRANSACTED );
            } else {
                session = connection->createSession(
Session::AUTO_ACKNOWLEDGE );
            }
                queue = session->createQueue( "Monitor" );
           
            // Create a MessageConsumer from the Session to the Topic or
Queue
            consumer = session->createConsumer( queue, "id='192.168.240.23'"
);

            consumer->setMessageListener( this );
            std::cout.flush();
            std::cerr.flush();

            // Indicate we are ready for messages.
            latch.countDown();

            // Wait while asynchronous messages come in.
			doneLatch.await( waitMillis );
			


        } catch( CMSException& e ) {
            // Indicate we are ready for messages.

            latch.countDown();
		
			bConnected = false;
            e.printStackTrace();
        }catch(Exception& ex){
		}
    }


Andreas Gies-3 wrote:
> 
> Hi,
> 
> perhaps you could come up with a small test case that shows the error ?
> 
> Best regards
> Andreas
> 
> 
> On Mar 26, 2009, at 10:11 AM, dongabda wrote:
> 
>>
>> Yes, I'm using the excepcionListener and onException, but any  
>> exception is
>> captured when the PC lost the network link. If I stop the  
>> messagebroker the
>> exception occurs, but with link lost not. How can I resolve it?
>>
>> -- 
>> View this message in context:
>> http://www.nabble.com/Reconnection-tp22663516p22677750.html
>> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>>
> 
> ---
> Mit freundlichen Grüssen - Kind Regards
> Andreas Gies
> Principal Consultant
> Open Source Center of Competence
> 
> Progress Software GmbH
> Agrippinawerft 26
> 50678 Köln
> 
> E-Mail      	agies@progress.com
> Direct Line 	+49 (0)9953 980349
> Mobile      	+49 (0)170 5759611
> Skype        	+44 (0)20 3239 2922
> Skype       	+353 (0)1 443 4971
> Skype       	+1 (0)781 262 0168
> 
> http://www.progress.com
> http://fusesource.com
> http://open-source-adventures.blogspot.com
> 
> 
> 
> -------------------------------------------------------
> Progress Software GmbH
> Sitz der Gesellschaft: Agrippinawerft 26, 50678 Koeln;
> Niederlassung: Fuerstenrieder Str. 279, 81377 Muenchen
> Amtsgericht Koeln, HRB 15620;
> Geschaeftsfuehrung: David Ireland
> -------------------------------------------------------
> 
> 

-- 
View this message in context: http://www.nabble.com/Reconnection-tp22663516p22904398.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Reconnection

Posted by Timothy Bish <ta...@gmail.com>.
On Tue, 2009-03-24 at 00:46 -0700, dongabda wrote:
> Hi,
> I saw that the consumer doesn't give any exception, it apparently works
> without net link, but after restore the link the consumer doesn't receive
> nothing. How can I know if the connection is down? How can I reconnect it? I
> saw the CMS Api but I don't see any function to know if the session or
> connection are closed. 
> Thanks for your help
> Best regards
> dongabda
> 
> 
> Andreas Gies-3 wrote:
> > 
> > Hi there,
> > 
> > i assume that you have set the clientId and consumer name to the same  
> > value
> > after the reconnect ?
> > 
> > Best regards
> > Andreas
> > 
> > On Mar 23, 2009, at 5:15 PM, dongabda wrote:
> > 
> >>
> >> I have a messagebroker and a producer in Java (Both in same PC).
> >> The consumer is in other PC and C++(activemq-cpp.2.2.4)
> >> I use Topics with durableconsumer.
> >> When the messagebroker is stopped and I launch the consumer, it  
> >> gives a
> >> CMSException. This is perfect. but when all is running (messagebroker,
> >> producer and consumer) if the consumer or producer lost the link, any
> >> exception is launched, and after restore the link, the consumer never
> >> receives any message.
> >> Why? What can I do to continue receiving messages?

If you look at the CMS Connection interface you will find a method that
allows you to set an exception listener on the Connection object, this
listener will be called whenever an exception occurs in any of the
threads that run as part of the Connection, Sessions, etc.  You must
extend the CMS ExceptionListener interface to create a class that will
manage how your client deals with Connection failures, the examples in
the src/example folder all do this.

Regards
Tim.
-- 
Tim Bish
http://fusesource.com
http://timbish.blogspot.com/




Re: Reconnection

Posted by dongabda <do...@ikusi.es>.
Hi,
I saw that the consumer doesn't give any exception, it apparently works
without net link, but after restore the link the consumer doesn't receive
nothing. How can I know if the connection is down? How can I reconnect it? I
saw the CMS Api but I don't see any function to know if the session or
connection are closed. 
Thanks for your help
Best regards
dongabda


Andreas Gies-3 wrote:
> 
> Hi there,
> 
> i assume that you have set the clientId and consumer name to the same  
> value
> after the reconnect ?
> 
> Best regards
> Andreas
> 
> On Mar 23, 2009, at 5:15 PM, dongabda wrote:
> 
>>
>> I have a messagebroker and a producer in Java (Both in same PC).
>> The consumer is in other PC and C++(activemq-cpp.2.2.4)
>> I use Topics with durableconsumer.
>> When the messagebroker is stopped and I launch the consumer, it  
>> gives a
>> CMSException. This is perfect. but when all is running (messagebroker,
>> producer and consumer) if the consumer or producer lost the link, any
>> exception is launched, and after restore the link, the consumer never
>> receives any message.
>> Why? What can I do to continue receiving messages?
>> -- 
>> View this message in context:
>> http://www.nabble.com/Reconnection-tp22663516p22663516.html
>> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>>
> 
> ---
> Mit freundlichen Grüssen - Kind Regards
> Andreas Gies
> Principal Consultant
> Open Source Center of Competence
> 
> Progress Software GmbH
> Agrippinawerft 26
> 50678 Köln
> 
> E-Mail      	agies@progress.com
> Direct Line 	+49 (0)9953 980349
> Mobile      	+49 (0)170 5759611
> Skype        	+44 (0)20 3239 2922
> Skype       	+353 (0)1 443 4971
> Skype       	+1 (0)781 262 0168
> 
> http://www.progress.com
> http://fusesource.com
> http://open-source-adventures.blogspot.com
> 
> 
> 
> -------------------------------------------------------
> Progress Software GmbH
> Sitz der Gesellschaft: Agrippinawerft 26, 50678 Koeln;
> Niederlassung: Fuerstenrieder Str. 279, 81377 Muenchen
> Amtsgericht Koeln, HRB 15620;
> Geschaeftsfuehrung: David Ireland
> -------------------------------------------------------
> 
> 

-- 
View this message in context: http://www.nabble.com/Reconnection-tp22663516p22675484.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Reconnection

Posted by Andreas Gies <ag...@progress.com>.
Hi there,

i assume that you have set the clientId and consumer name to the same  
value
after the reconnect ?

Best regards
Andreas

On Mar 23, 2009, at 5:15 PM, dongabda wrote:

>
> I have a messagebroker and a producer in Java (Both in same PC).
> The consumer is in other PC and C++(activemq-cpp.2.2.4)
> I use Topics with durableconsumer.
> When the messagebroker is stopped and I launch the consumer, it  
> gives a
> CMSException. This is perfect. but when all is running (messagebroker,
> producer and consumer) if the consumer or producer lost the link, any
> exception is launched, and after restore the link, the consumer never
> receives any message.
> Why? What can I do to continue receiving messages?
> -- 
> View this message in context: http://www.nabble.com/Reconnection-tp22663516p22663516.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>

---
Mit freundlichen Grüssen - Kind Regards
Andreas Gies
Principal Consultant
Open Source Center of Competence

Progress Software GmbH
Agrippinawerft 26
50678 Köln

E-Mail      	agies@progress.com
Direct Line 	+49 (0)9953 980349
Mobile      	+49 (0)170 5759611
Skype        	+44 (0)20 3239 2922
Skype       	+353 (0)1 443 4971
Skype       	+1 (0)781 262 0168

http://www.progress.com
http://fusesource.com
http://open-source-adventures.blogspot.com



-------------------------------------------------------
Progress Software GmbH
Sitz der Gesellschaft: Agrippinawerft 26, 50678 Koeln;
Niederlassung: Fuerstenrieder Str. 279, 81377 Muenchen
Amtsgericht Koeln, HRB 15620; 
Geschaeftsfuehrung: David Ireland
-------------------------------------------------------