Hi Ismail,
there is currently no way of properly shutting down the standalone version of Membrane. I usually use Ctrl+C or Eclipse's stop button, which effectively kills the process.
Do you have a use case where a proper shutdown is required? I would be interested in hearing about it.
Note that Membrane already has some shutdown behaviour, but there is no way of triggering a proper shutdown with Membrane's standalone deployment. The shutdown logic exists to support reloading of the proxies.xml configuration file, as well as other deployment methods (OSGi, J2EE web app). When either the proxies.xml changed or the Membrane OSGi bundle is stopped or the Membrane J2EE web app is undeployed, any listening TCP server ports are closed. This allows restarting Membrane's spring context (as well as the OSGi bundle or web app) without restarting the container.
Internally, Membrane uses a Spring context and the Spring life-cycle phase 0 to manage its objects. For standalone deployment, this gives you the the following structure of nested components:
[RouterCLI [spring-context [Router [Transport [TCP ports] ] [interceptors] ] ]
Currently,
* RouterCLI has no method of triggering a shutdown. (Modifying the proxies.xml configuration file triggers a shutdown of the spring-context (and the nested Router and Transport, closing the TCP ports), but this shutdown is always followed immediately by a restart).
* The Interceptor interface has no counterpart of init() for shutdown. (Effectively interceptors currently do not have the concept of shutting down.)
The last issue can be worked around though:
In proxies.xml, define
<spring:bean
id="myInterceptor"
class="com.predic8.example.MyInterceptor" />
<router>
<serviceProxy name="localhost" port="2001" >
<spring:ref bean="myInterceptor" />
<target host="localhost" port="8080"/>
</serviceProxy>
and implement
package com.predic8.example;
public class MyInterceptor extends com.predic8.membrane.core.interceptor.AbstractInterceptor implements org.springframework.context.Lifecycle { ... }
This way, your interceptor can implement start() and stop() methods, which will be called by Spring.
Best, Tobias