You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Janesh S <ja...@tumri.com> on 2008/08/08 05:40:00 UTC

How to shutdown activemq 5.1.0 server?

Hi,

I want to use activemq on a linux server. I have installed activemq 5.1.0. I
could run the server by invoking the activemq executable directly. But I do
not find a way to gracefully shutdown the server as there is no shutdown
script/executable present in the bin directory. 

I read the following document which tells how to make the activemq a service
- http://activemq.apache.org/unix-service.html. But this also needs the
shutdown script. 

I copied the shutdown script from the activemq 4 distribution, but that did
not work. Then I experimented shutting down using the various documented
stop option(s) using - run.jar, activemq-admin etc, but without any success.

Can someone help me with graceful shutdown?

Kind Regards,
Jan
-- 
View this message in context: http://www.nabble.com/How-to-shutdown-activemq-5.1.0-server--tp18884711p18884711.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: How to shutdown activemq 5.1.0 server?

Posted by Janesh S <ja...@tumri.com>.
Hi Madhav,

Before starting the mq server, set the following environment variable. This
enables JMX (Java management extensions) at port 1099. This is needed to
stop the server. This should solve your problem:

export SUNJMX="-Dcom.sun.management.jmxremote.port=1099 
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote=true"

Regards,
Jan


Madhav-5 wrote:
> 
> Hi Janesh,
> 
> When I try "activemq-admin.bat stop", then I'm getting following exception
> trace:
> 
> ERROR: java.lang.RuntimeException: Failed to execute stop task. Reason:
> java.io.IOException: Failed to retrieve RMIServer stub:
> javax.naming.ServiceUnavailableException [Root exception is
> java.rmi.ConnectException: Connection refused to host: localhost; nested
> exception is:
>         java.net.ConnectException: Connection refused: connect]
> java.lang.RuntimeException: Failed to execute stop task. Reason:
> java.io.IOException: Failed to retrieve RMIServer stub:
> javax.naming.ServiceUnavailableException [Root exception is
> java.rmi.ConnectException: Connection refused to host: localhost; nested
> exception is:
>         java.net.ConnectException: Connection refused: connect]
>         at
> org.apache.activemq.console.command.ShutdownCommand.runTask(ShutdownCommand.java:104)
>         at
> org.apache.activemq.console.command.AbstractCommand.execute(AbstractCommand.java:57)
>         at
> org.apache.activemq.console.command.ShellCommand.runTask(ShellCommand.java:129)
>         at
> org.apache.activemq.console.command.AbstractCommand.execute(AbstractCommand.java:57)
>         at
> org.apache.activemq.console.command.ShellCommand.main(ShellCommand.java:79)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>         at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>         at java.lang.reflect.Method.invoke(Method.java:597)
>         at org.apache.activemq.console.Main.runTaskClass(Main.java:222)
>         at org.apache.activemq.console.Main.main(Main.java:106)
> ERROR: java.lang.Exception: java.io.IOException: Failed to retrieve
> RMIServer stub: javax.naming.ServiceUnavailableException
> [Root exception is java.rmi.ConnectException: Connection refused to host:
> localhost; nested exception is:
>         java.net.ConnectException: Connection refused: connect]
> 
> 
> 
> ----------------
> When I try "java -jar run.jar stop", then I get following exception:
> 
> ERROR: java.lang.RuntimeException: Failed to execute stop task. Reason:
> java.io.IOException: Failed to retrieve RMIServer stub:
> javax.naming.ServiceUnavailableException [Root exception is
> java.rmi.ConnectException: Connection refused to host: localhost; nested
> exception is:
>         java.net.ConnectException: Connection refused: connect]
> java.lang.RuntimeException: Failed to execute stop task. Reason:
> java.io.IOException: Failed to retrieve RMIServer stub:
> javax.naming.ServiceUnavailableException [Root exception is
> java.rmi.ConnectException: Connection refused to host: localhost; nested
> exception is:
>         java.net.ConnectException: Connection refused: connect]
>         at
> org.apache.activemq.console.command.ShutdownCommand.runTask(ShutdownCommand.java:104)
>         at
> org.apache.activemq.console.command.AbstractCommand.execute(AbstractCommand.java:57)
>         at
> org.apache.activemq.console.command.ShellCommand.runTask(ShellCommand.java:129)
>         at
> org.apache.activemq.console.command.AbstractCommand.execute(AbstractCommand.java:57)
>         at
> org.apache.activemq.console.command.ShellCommand.main(ShellCommand.java:79)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>         at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>         at java.lang.reflect.Method.invoke(Method.java:597)
>         at org.apache.activemq.console.Main.runTaskClass(Main.java:222)
>         at org.apache.activemq.console.Main.main(Main.java:106)
> 
> 
> Could you please help me figuring out the problem?
> 
> -Madhav
> 
> 
> On Wed, Aug 13, 2008 at 7:38 AM, Janesh S <ja...@tumri.com> wrote:
> 
>>
>> Hi,
>>
>> Finally I wrote the scripts myself and thought of sharing it on the forum
>> for public reference:
>>
>> #!/bin/sh
>> # Startup script for Apache ActiveMQ
>> ###################################################################
>>
>> MQ_HOME=<full-path>/apache-activemq-5.1.0
>>
>> cd $MQ_HOME/bin
>>
>> export SUNJMX="-Dcom.sun.management.jmxremote.port=1099
>> -Dcom.sun.management.jmxremote.authenticate=false
>> -Dcom.sun.management.jmxremote.ssl=false
>> -Dcom.sun.management.jmxremote=true"
>>
>> ./activemq &
>>
>>
>> #!/bin/sh
>> # Shutdown script for Apache ActiveMQ
>> #########################################################
>>
>> MQ_HOME=<full-path>/apache-activemq-5.1.0
>> cd $MQ_HOME/bin
>> java -jar run.jar stop
>>
>> Regards,
>> Jan
>>
>> --
>> View this message in context:
>> http://www.nabble.com/How-to-shutdown-activemq-5.1.0-server--tp18884711p18955816.html
>> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>>
>>
> 
> 
> -- 
> -Madhav
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-shutdown-activemq-5.1.0-server--tp18884711p18961584.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: How to shutdown activemq 5.1.0 server?

Posted by Madhav <rr...@gmail.com>.
Hi Janesh,

When I try "activemq-admin.bat stop", then I'm getting following exception
trace:

ERROR: java.lang.RuntimeException: Failed to execute stop task. Reason:
java.io.IOException: Failed to retrieve RMIServer stub:
javax.naming.ServiceUnavailableException [Root exception is
java.rmi.ConnectException: Connection refused to host: localhost; nested
exception is:
        java.net.ConnectException: Connection refused: connect]
java.lang.RuntimeException: Failed to execute stop task. Reason:
java.io.IOException: Failed to retrieve RMIServer stub:
javax.naming.ServiceUnavailableException [Root exception is
java.rmi.ConnectException: Connection refused to host: localhost; nested
exception is:
        java.net.ConnectException: Connection refused: connect]
        at
org.apache.activemq.console.command.ShutdownCommand.runTask(ShutdownCommand.java:104)
        at
org.apache.activemq.console.command.AbstractCommand.execute(AbstractCommand.java:57)
        at
org.apache.activemq.console.command.ShellCommand.runTask(ShellCommand.java:129)
        at
org.apache.activemq.console.command.AbstractCommand.execute(AbstractCommand.java:57)
        at
org.apache.activemq.console.command.ShellCommand.main(ShellCommand.java:79)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.activemq.console.Main.runTaskClass(Main.java:222)
        at org.apache.activemq.console.Main.main(Main.java:106)
ERROR: java.lang.Exception: java.io.IOException: Failed to retrieve
RMIServer stub: javax.naming.ServiceUnavailableException
[Root exception is java.rmi.ConnectException: Connection refused to host:
localhost; nested exception is:
        java.net.ConnectException: Connection refused: connect]



----------------
When I try "java -jar run.jar stop", then I get following exception:

ERROR: java.lang.RuntimeException: Failed to execute stop task. Reason:
java.io.IOException: Failed to retrieve RMIServer stub:
javax.naming.ServiceUnavailableException [Root exception is
java.rmi.ConnectException: Connection refused to host: localhost; nested
exception is:
        java.net.ConnectException: Connection refused: connect]
java.lang.RuntimeException: Failed to execute stop task. Reason:
java.io.IOException: Failed to retrieve RMIServer stub:
javax.naming.ServiceUnavailableException [Root exception is
java.rmi.ConnectException: Connection refused to host: localhost; nested
exception is:
        java.net.ConnectException: Connection refused: connect]
        at
org.apache.activemq.console.command.ShutdownCommand.runTask(ShutdownCommand.java:104)
        at
org.apache.activemq.console.command.AbstractCommand.execute(AbstractCommand.java:57)
        at
org.apache.activemq.console.command.ShellCommand.runTask(ShellCommand.java:129)
        at
org.apache.activemq.console.command.AbstractCommand.execute(AbstractCommand.java:57)
        at
org.apache.activemq.console.command.ShellCommand.main(ShellCommand.java:79)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.activemq.console.Main.runTaskClass(Main.java:222)
        at org.apache.activemq.console.Main.main(Main.java:106)


Could you please help me figuring out the problem?

-Madhav


On Wed, Aug 13, 2008 at 7:38 AM, Janesh S <ja...@tumri.com> wrote:

>
> Hi,
>
> Finally I wrote the scripts myself and thought of sharing it on the forum
> for public reference:
>
> #!/bin/sh
> # Startup script for Apache ActiveMQ
> ###################################################################
>
> MQ_HOME=<full-path>/apache-activemq-5.1.0
>
> cd $MQ_HOME/bin
>
> export SUNJMX="-Dcom.sun.management.jmxremote.port=1099
> -Dcom.sun.management.jmxremote.authenticate=false
> -Dcom.sun.management.jmxremote.ssl=false
> -Dcom.sun.management.jmxremote=true"
>
> ./activemq &
>
>
> #!/bin/sh
> # Shutdown script for Apache ActiveMQ
> #########################################################
>
> MQ_HOME=<full-path>/apache-activemq-5.1.0
> cd $MQ_HOME/bin
> java -jar run.jar stop
>
> Regards,
> Jan
>
> --
> View this message in context:
> http://www.nabble.com/How-to-shutdown-activemq-5.1.0-server--tp18884711p18955816.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>


-- 
-Madhav

Re: How to shutdown activemq 5.1.0 server?

Posted by Janesh S <ja...@tumri.com>.
Hi,

Finally I wrote the scripts myself and thought of sharing it on the forum
for public reference:

#!/bin/sh
# Startup script for Apache ActiveMQ
###################################################################

MQ_HOME=<full-path>/apache-activemq-5.1.0

cd $MQ_HOME/bin

export SUNJMX="-Dcom.sun.management.jmxremote.port=1099
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote=true"

./activemq &


#!/bin/sh
# Shutdown script for Apache ActiveMQ
#########################################################

MQ_HOME=<full-path>/apache-activemq-5.1.0
cd $MQ_HOME/bin
java -jar run.jar stop

Regards,
Jan

-- 
View this message in context: http://www.nabble.com/How-to-shutdown-activemq-5.1.0-server--tp18884711p18955816.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: How to shutdown activemq 5.1.0 server?

Posted by Janesh S <ja...@tumri.com>.
Hi,

Can someone please help me with the shutdown? Thanks.

Jan


Hi Bruce,

Thanks!

I tried enabling the JMX using each of the following options, but still was
unable to stop the server using the "activemq-admin stop" command:


-- 
View this message in context: http://www.nabble.com/How-to-shutdown-activemq-5.1.0-server--tp18884711p18902281.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: How to shutdown activemq 5.1.0 server?

Posted by Janesh S <ja...@tumri.com>.
Hi Bruce,

Setting the SUNJMX variable (as follows) before starting the server using
"activmq-admin start" helped. I was then able to gracefully shutdown the
server using "activemq-admin stop".

export SUNJMX="-Dcom.sun.management.jmxremote.port=1099
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote=true"

Thanks a lot for your help.

Kind Regards,
Jan

-- 
View this message in context: http://www.nabble.com/How-to-shutdown-activemq-5.1.0-server--tp18884711p18957138.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: How to shutdown activemq 5.1.0 server?

Posted by Bruce Snyder <br...@gmail.com>.
On Fri, Aug 8, 2008 at 2:21 AM, Janesh S <ja...@tumri.com> wrote:
>
> Hi Bruce,
>
> Thanks!
>
> I tried enabling the JMX using each of the following options, but still was
> unable to stop the server using the "activemq-admin stop" command:
>
> ------------------------------------------------------------------------------------------------------------------------------------------
> 1. Added useJmx="true" (within <broker> element) in the conf/activemq.xml
> and started the server using the following command: ./activemq
> xbean:../conf/activemq.xml
>
> 2. Tried started the server as follows: "activemq
> broker:(tcp://localhost:61616, tcp://localhost:5000)?useJmx=true" as given
> in documentation, but this fails to start. I got this error "bash: syntax
> error near unexpected token `('"
>
> 3. Set this option in environment using export: "export
> SUNJMX="-Dcom.sun.management.jmxremote.port=1099
> -Dcom.sun.management.jmxremote.authenticate=false
> -Dcom.sun.management.jmxremote.ssl=false
> -Dcom.sun.management.jmxremote=true""
>
> and then started the activemq like this: ./activemq
>
> On stopping using "./activemq-admin stop" I got the following error:
>
> "./activemq-admin stop
> Error: Exception thrown by the agent : java.rmi.server.ExportException: Port
> already in use: 1099; nested exception is:
>        java.net.BindException: Address already in use"
>
> ------------------------------------------------------------------------------------------------------------------------------------------
>
> Can you please help? Thanks.

I had to modify the activemq-admin script to adjust the SUNJMX
variable a bit to get it to work properly. Below is the full variable
after my modification:

SUNJMX="-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=1616
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false"

After adding the -Dcom.sun.management.jmxremote system property, the
activemq-admin script works as expected.

FWIW, the active-admin script's start function won't return. It just
runs ActiveMQ in place which is not what most people expect. So you
should probably use the activemq script or the wrapper executable to
startup ActiveMQ. Once it's started, you can use the activemq-admin
script to perform the other functions.

Bruce
-- 
perl -e 'print unpack("u30","D0G)U8V4\@4VYY9&5R\"F)R=6-E+G-N>61E<D\!G;6%I;\"YC;VT*"
);'

Apache ActiveMQ - http://activemq.org/
Apache Camel - http://activemq.org/camel/
Apache ServiceMix - http://servicemix.org/

Blog: http://bruceblog.org/

Re: How to shutdown activemq 5.1.0 server?

Posted by Janesh S <ja...@tumri.com>.
Hi Bruce,

Thanks!

I tried enabling the JMX using each of the following options, but still was
unable to stop the server using the "activemq-admin stop" command:

------------------------------------------------------------------------------------------------------------------------------------------
1. Added useJmx="true" (within <broker> element) in the conf/activemq.xml
and started the server using the following command: ./activemq
xbean:../conf/activemq.xml

2. Tried started the server as follows: "activemq
broker:(tcp://localhost:61616, tcp://localhost:5000)?useJmx=true" as given
in documentation, but this fails to start. I got this error "bash: syntax
error near unexpected token `('"

3. Set this option in environment using export: "export
SUNJMX="-Dcom.sun.management.jmxremote.port=1099
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote=true""

and then started the activemq like this: ./activemq

On stopping using "./activemq-admin stop" I got the following error:

"./activemq-admin stop
Error: Exception thrown by the agent : java.rmi.server.ExportException: Port
already in use: 1099; nested exception is: 
        java.net.BindException: Address already in use"

------------------------------------------------------------------------------------------------------------------------------------------

Can you please help? Thanks.

Kind Regards,
Janesh
 



bsnyder wrote:
> 
> On Thu, Aug 7, 2008 at 9:40 PM, Janesh S <ja...@tumri.com> wrote:
>>
>> Hi,
>>
>> I want to use activemq on a linux server. I have installed activemq
>> 5.1.0. I
>> could run the server by invoking the activemq executable directly. But I
>> do
>> not find a way to gracefully shutdown the server as there is no shutdown
>> script/executable present in the bin directory.
>>
>> I read the following document which tells how to make the activemq a
>> service
>> - http://activemq.apache.org/unix-service.html. But this also needs the
>> shutdown script.
>>
>> I copied the shutdown script from the activemq 4 distribution, but that
>> did
>> not work. Then I experimented shutting down using the various documented
>> stop option(s) using - run.jar, activemq-admin etc, but without any
>> success.
>>
>> Can someone help me with graceful shutdown?
> 
> Use the activemq-admin script that is in the bin directory. It's
> described here:
> 
> http://activemq.apache.org/activemq-command-line-tools-reference.html
> 
> Just run it like this:
> 
> $ ./bin/activemq-admin stop
> 
> Just note that you must first enable JMX in the activemq startup
> script for the activemq-admin script to work correctly.
> 
> Bruce
> -- 
> perl -e 'print
> unpack("u30","D0G)U8V4\@4VYY9&5R\"F)R=6-E+G-N>61E<D\!G;6%I;\"YC;VT*"
> );'
> 
> Apache ActiveMQ - http://activemq.org/
> Apache Camel - http://activemq.org/camel/
> Apache ServiceMix - http://servicemix.org/
> 
> Blog: http://bruceblog.org/
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-shutdown-activemq-5.1.0-server--tp18884711p18887750.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: How to shutdown activemq 5.1.0 server?

Posted by Bruce Snyder <br...@gmail.com>.
On Thu, Aug 7, 2008 at 9:40 PM, Janesh S <ja...@tumri.com> wrote:
>
> Hi,
>
> I want to use activemq on a linux server. I have installed activemq 5.1.0. I
> could run the server by invoking the activemq executable directly. But I do
> not find a way to gracefully shutdown the server as there is no shutdown
> script/executable present in the bin directory.
>
> I read the following document which tells how to make the activemq a service
> - http://activemq.apache.org/unix-service.html. But this also needs the
> shutdown script.
>
> I copied the shutdown script from the activemq 4 distribution, but that did
> not work. Then I experimented shutting down using the various documented
> stop option(s) using - run.jar, activemq-admin etc, but without any success.
>
> Can someone help me with graceful shutdown?

Use the activemq-admin script that is in the bin directory. It's
described here:

http://activemq.apache.org/activemq-command-line-tools-reference.html

Just run it like this:

$ ./bin/activemq-admin stop

Just note that you must first enable JMX in the activemq startup
script for the activemq-admin script to work correctly.

Bruce
-- 
perl -e 'print unpack("u30","D0G)U8V4\@4VYY9&5R\"F)R=6-E+G-N>61E<D\!G;6%I;\"YC;VT*"
);'

Apache ActiveMQ - http://activemq.org/
Apache Camel - http://activemq.org/camel/
Apache ServiceMix - http://servicemix.org/

Blog: http://bruceblog.org/