More about closed session :)

Could be possible that the closing problem could occur because the Session is not per Thread, even if it is accessed by only on thread at the time(or it should be accessed, but sometime is not - backport-concurent problems)?

The code look like that :
class MyStorageQueue {
  private  Session session;
  private Queue queue;
  protected final Semaphore lock = new Semaphore(1, true);
    ....
 public Object consume() {
    ....
 }

 public void publish(Object object) {
    ....
 }
}

and usage in different threads
MyStorageQueue queue = getNextQueue(...);
if (queue.lock.tryAcquire()) {
               try {
                      Object value = consume(queue);
                       .....
               } finally {
                   queue.lock.release();
               }
}

Anyway I created a wrapper over an ActiveMQ session, and dump the stack trace to see who calls the close method.



Adrian Tarau wrote:
Debugging remove is not a problem, the problem is that I need to start the application in debug mode and keep the IDE with a breakpoint for days until it happens.

I think I will recompile the ActiveMQ and dump the thread stack trace :)

Sanjiv Jivan wrote:
You can attach your debugger to the Java process on the remote machine and set the breakpoint on the session.close() call. Once the breakpoint it hit,
you can examine the call stack in your debugger.

Use the JPDA socket JVM args when starting your Java process. Eg : -Xdebug -Xnoagent -Djava.compiler=NONE-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005


On 7/13/06, Adrian Tarau <[EMAIL PROTECTED]> wrote:

That's great but this usually happens on the remote machine, after a few
days :)

James Strachan wrote:
> Maybe try run your code in a debugger and set breakpoints in the
> ActiveMQSession class to see where & why the session gets closed? (The
> code's pretty easy to follow, its a relatively simple class).
>
>
> On 7/13/06, Adrian Tarau <[EMAIL PROTECTED]> wrote:
>> James, do you want the sources or can you recommend me some actions? To
>> create the session all the time, not to cache it?
>>
>> Adrian Tarau wrote:
>> > Ok, so who close the session? :)
>> >
>> > James Strachan wrote:
>> >> Sorry I forgot about that :)
>> >>
>> >> The only time a VM broker is shut down is explicitly via application
>> >> code or a shutdown handler.
>> >>
>> >> On 7/13/06, Adrian Tarau <[EMAIL PROTECTED]> wrote:
>> >>> I use vm connector so no connection problems should be involved,
>> right?
>> >>>
>> >>> James Strachan wrote:
>> >>> > BTW are you using auto-reconnect? It could be that the socket is
>> >>> > terminated due to some network issue?
>> >>> >
>> >>> >
>> >>>
>>
http://incubator.apache.org/activemq/how-can-i-support-auto-reconnection.html
>>
>> >>>
>> >>> >
>> >>> >
>> >>> > On 7/13/06, Adrian Tarau <[EMAIL PROTECTED]> wrote:
>> >>> >> I made a search for "close" in the source code and except from
>> >>> produces,
>> >>> >> consumers and inputstream and outputstream I don't close the
>> >>> connection
>> >>> >> or session, except on the JVM shutdown(Thread hook).
>> >>> >>
>> >>> >> I can provide you(private - not on the mailing list) the
>> source code
>> >>> >> because this is very annoying.
>> >>> >> Thanks.
>> >>> >>
>> >>> >> James Strachan wrote:
>> >>> >> > Apart from inactivity timeouts on the transport layer, we
>> >>> generally
>> >>> >> > don't close sessions. Are you sure nothing in your application
>> >>> code is
>> >>> >> > trying to close the session?
>> >>> >> >
>> >>> >> > On 7/13/06, Adrian Tarau <[EMAIL PROTECTED]> wrote:
>> >>> >> >> I have this issue for some time with ActiveMQ 4.0 and 4.0.1.
>> >>> >> >>
>> >>> >> >> I use vm transport and create one session used to produce and
>> >>> consume
>> >>> >> >> messages. Everything works fine, days in a row, until it
>> start to
>> >>> >> throw
>> >>> >> >> exception that "Session is closed". There are any watch
>> dogs that
>> >>> >> close
>> >>> >> >> sessions after a while, based on some criteria?
>> >>> >> >>
>> >>> >> >> I couldn't find any rule, when or why it happens.
>> >>> >> >> Should I create the session all the time - I understood is
>> time
>> >>> >> >> consuming and it should be safe to cache it.
>> >>> >> >>
>> >>> >> >> Thanks.
>> >>> >> >>
>> >>> >> >> *javax.jms.IllegalStateException: The Session is closed
>> >>> >> >>     at
>> >>> >> >>
>> >>> >>
>> >>>
>> org.apache.activemq.ActiveMQSession.checkClosed(ActiveMQSession.java
:577)
>>
>> >>>
>> >>> >>
>> >>> >> >>
>> >>> >> >>     at
>> >>> >> >>
>> >>> >>
>> >>>
>> org.apache.activemq.ActiveMQSession.createConsumer(ActiveMQSession.java
:799)*
>>
>> >>>
>> >>> >>
>> >>> >> >>
>> >>> >> >>
>> >>> >> >>
>> >>> >> >
>> >>> >> >
>> >>> >>
>> >>> >>
>> >>> >
>> >>> >
>> >>>
>> >>>
>> >>
>> >>
>> >
>>
>>
>
>





Reply via email to