You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by Radhakrishna Kalyan <nr...@gmail.com> on 2013/12/16 16:58:46 UTC

Graceful shutdown in OpenEJB recommendation

Hi,

I would like to have a graceful shutdown in my standalone Openejb
application.

I have used the following code in my public static void main(String...
args) method
Is it the correct way of doing a graceful shutdown?

--------------------------------------------------
*public static void main(String... a){*
....Some code

* properties.put("openejb.embedded.initialcontext.close", "destroy");*

*final EJBContainer ejbContainer =
EJBContainer.createEJBContainer(properties);
ejbContainer.getContext().bind("inject", this);*

....Some code












* Runtime.getRuntime().addShutdownHook(new Thread() {
@Override                public void run() {
LOG.info("Shutting down..");                    try
{                        ejbContainer.close();
LOG.info("Bye");                    } catch (Exception e) {
                        LOG.error("Graceful shutdown went wrong. SIGKILL
(kill -9) if you want.", e);                    }
}            });*

*Thread.currentThread().join();*
}
--------------------------------------------------

I would like to know is there any benefit of


*properties.put("openejb.embedded.initialcontext.close", "destroy"); *
As I found the value can be either "*destroy*" or "*logout*". Which one is
preferred?

Re: Graceful shutdown in OpenEJB recommendation

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Here is how I do generally (exception map() is empty in most of my
mains): http://svn.apache.org/repos/asf/tomee/tomee/trunk/maven/openejb-embedded-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/embedded/OpenEJBEmbeddedMojo.java
Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau



2013/12/16 Nrkkalyan <nr...@gmail.com>:
> But you said it is the correct way to use openejb in a standalone application is
>>> EJBContainer ejbContainer =
>>> EJBContainer.createEJBContainer(properties);
>>> ejbContainer.getContext().bind("inject", this);*
>
>
> If not then can you give some pointers on the recommended way of starting ejb container in a standalone application.
>
> Regards
> /Kalyan
> 0733312584
>
> PS: May have typos due to using mobile
>
> On 16 dec 2013, at 18:58, Romain Manni-Bucau <rm...@gmail.com> wrote:
>
>> Noone. These properties are for clients. With EJbContainer in a main they
>> will not change anything for you
>> Le 16 déc. 2013 16:59, "Radhakrishna Kalyan" <nr...@gmail.com> a écrit :
>>
>>> Hi,
>>>
>>> I would like to have a graceful shutdown in my standalone Openejb
>>> application.
>>>
>>> I have used the following code in my public static void main(String...
>>> args) method
>>> Is it the correct way of doing a graceful shutdown?
>>>
>>> --------------------------------------------------
>>> *public static void main(String... a){*
>>> ....Some code
>>>
>>> * properties.put("openejb.embedded.initialcontext.close", "destroy");*
>>>
>>> *final EJBContainer ejbContainer =
>>> EJBContainer.createEJBContainer(properties);
>>> ejbContainer.getContext().bind("inject", this);*
>>>
>>> ....Some code
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> * Runtime.getRuntime().addShutdownHook(new Thread() {
>>> @Override                public void run() {
>>> LOG.info("Shutting down..");                    try
>>> {                        ejbContainer.close();
>>> LOG.info("Bye");                    } catch (Exception e) {
>>>                        LOG.error("Graceful shutdown went wrong. SIGKILL
>>> (kill -9) if you want.", e);                    }
>>> }            });*
>>>
>>> *Thread.currentThread().join();*
>>> }
>>> --------------------------------------------------
>>>
>>> I would like to know is there any benefit of
>>>
>>>
>>> *properties.put("openejb.embedded.initialcontext.close", "destroy"); *
>>> As I found the value can be either "*destroy*" or "*logout*". Which one is
>>> preferred?
>>>

Re: Graceful shutdown in OpenEJB recommendation

Posted by Nrkkalyan <nr...@gmail.com>.
But you said it is the correct way to use openejb in a standalone application is
>> EJBContainer ejbContainer =
>> EJBContainer.createEJBContainer(properties);
>> ejbContainer.getContext().bind("inject", this);*


If not then can you give some pointers on the recommended way of starting ejb container in a standalone application. 

Regards 
/Kalyan 
0733312584

PS: May have typos due to using mobile

On 16 dec 2013, at 18:58, Romain Manni-Bucau <rm...@gmail.com> wrote:

> Noone. These properties are for clients. With EJbContainer in a main they
> will not change anything for you
> Le 16 déc. 2013 16:59, "Radhakrishna Kalyan" <nr...@gmail.com> a écrit :
> 
>> Hi,
>> 
>> I would like to have a graceful shutdown in my standalone Openejb
>> application.
>> 
>> I have used the following code in my public static void main(String...
>> args) method
>> Is it the correct way of doing a graceful shutdown?
>> 
>> --------------------------------------------------
>> *public static void main(String... a){*
>> ....Some code
>> 
>> * properties.put("openejb.embedded.initialcontext.close", "destroy");*
>> 
>> *final EJBContainer ejbContainer =
>> EJBContainer.createEJBContainer(properties);
>> ejbContainer.getContext().bind("inject", this);*
>> 
>> ....Some code
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> * Runtime.getRuntime().addShutdownHook(new Thread() {
>> @Override                public void run() {
>> LOG.info("Shutting down..");                    try
>> {                        ejbContainer.close();
>> LOG.info("Bye");                    } catch (Exception e) {
>>                        LOG.error("Graceful shutdown went wrong. SIGKILL
>> (kill -9) if you want.", e);                    }
>> }            });*
>> 
>> *Thread.currentThread().join();*
>> }
>> --------------------------------------------------
>> 
>> I would like to know is there any benefit of
>> 
>> 
>> *properties.put("openejb.embedded.initialcontext.close", "destroy"); *
>> As I found the value can be either "*destroy*" or "*logout*". Which one is
>> preferred?
>> 

Re: Graceful shutdown in OpenEJB recommendation

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Noone. These properties are for clients. With EJbContainer in a main they
will not change anything for you
Le 16 déc. 2013 16:59, "Radhakrishna Kalyan" <nr...@gmail.com> a écrit :

> Hi,
>
> I would like to have a graceful shutdown in my standalone Openejb
> application.
>
> I have used the following code in my public static void main(String...
> args) method
> Is it the correct way of doing a graceful shutdown?
>
> --------------------------------------------------
> *public static void main(String... a){*
> ....Some code
>
> * properties.put("openejb.embedded.initialcontext.close", "destroy");*
>
> *final EJBContainer ejbContainer =
> EJBContainer.createEJBContainer(properties);
> ejbContainer.getContext().bind("inject", this);*
>
> ....Some code
>
>
>
>
>
>
>
>
>
>
>
>
> * Runtime.getRuntime().addShutdownHook(new Thread() {
> @Override                public void run() {
> LOG.info("Shutting down..");                    try
> {                        ejbContainer.close();
> LOG.info("Bye");                    } catch (Exception e) {
>                         LOG.error("Graceful shutdown went wrong. SIGKILL
> (kill -9) if you want.", e);                    }
> }            });*
>
> *Thread.currentThread().join();*
> }
> --------------------------------------------------
>
> I would like to know is there any benefit of
>
>
> *properties.put("openejb.embedded.initialcontext.close", "destroy"); *
> As I found the value can be either "*destroy*" or "*logout*". Which one is
> preferred?
>