Re: Starting a bridge in a new thread


Ian Bell <i.bell@...>
 

Hi

 

Either option is fine as Mama.start is a blocking call until Mama.stop is called, which causes it to return.

For the second one you should be aware that the call-back is invoked after Mama.start has returned, i.e. after Mama.stop is called.

Think of it as onStopComplete rather than start.

The reason for this is so that you know when it is safe to destroy transports, queues etc on shutdown.

If you use option 1 you need to take care of this interaction yourself.

 

Thanks

Ian

 

From: openmama-dev-bounces@... [mailto:openmama-dev-bounces@...] On Behalf Of Hari Shyam
Sent: 19 February 2015 17:07
To: openmama-dev@...
Subject: [Openmama-dev] Starting a bridge in a new thread

 

Hi team,

 

Is it necessary to start a bridge on a separate thread?

 

new Thread() {

       public void run() {

              try {

                     Mama.start(bridge);

              } catch (RuntimeException e) {

                                                                     }

              }.start();

}

}

 

Or should we use this

 

Mama.startBackground(bridge, new MamaStartBackgroundCallback() {

                    

                     @Override

                     public void onStartComplete(int paramInt) {

                          

                           logger.info("mama started");

                          

                     }

              });

 

 

For the second option, the callback is never called.

 

Thanks,
Hari



---
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and delete this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.

Please refer to http://www.db.com/en/content/eu_disclosures.htm for additional EU corporate and regulatory disclosures and to http://www.db.com/unitedkingdom/content/privacy.htm for information about privacy.

Join Openmama-dev@lists.openmama.org to automatically receive all group messages.