This discussion is archived
7 Replies Latest reply: Apr 21, 2011 12:39 PM by ak RSS

connection loss

807581 Newbie
Currently Being Moderated
I'm using SunONE Message Queue 3.0.1 with durable subscribers. Is there a way for a subscriber to sense the loss of connection to the broker as soon as it occurs? If not, I wonder whether the subscriber can somehow ping the connection to keep it alive when no messages are being sent for a while. I can't use the reconnect property because my listeners need to receive messages in CLIENT_ACKNOWLEDGE mode. The connection loss I'm referring to is that reported in the broker log file with the message "Closing: clientId@clientIPAddress..."
Thanks.
  • 1. Re: connection loss
    807581 Newbie
    Currently Being Moderated
    I'm using SunONE Message Queue 3.0.1 with durable
    subscribers. Is there a way for a subscriber to sense
    the loss of connection to the broker as soon as it
    occurs?
    Are you not receiving notification on the exception listener
    when the connection closed ???

    In general:
    - synchronous (receive()) subscribers will receive an
    exception in receive when the connection is closed

    - asynchronous (onMessage) subscribers will NOT
    receive an exception, however the application can
    register an exception listener who will receive the
    noticiation (and then notify the subscriber)


    NOTE:

    There are a few very rare cases where the client may
    not receive the error. These occur when there is some
    sort of network failure between the client and the broker.
    The application ends up with a "half-open" connection
    (the tcp stack has not realized that the connection has
    gone because there has been no normal activity)

    [see bug 4953659 for a workaround for this problem
    if you run into it]
  • 2. Re: connection loss
    807581 Newbie
    Currently Being Moderated
    My subscribers are asynchronous, they implement ExceptionListener too, and I've registered them as exception listeners for the topic connection. What I saw is that if I disconnet the net cable of the machine where the message listeners have been started, then their onException method is called straightaway, but when the connection just times out gracefully (provided that is what really happens), I find the "Closing:..." in the broker log file, but it seems the onException isn't called on the client side or, at least, it isn't called as soon as the connection is lost.
    Still, I have to say that I haven't had the chance to test the whole matter that much, because every time it takes some days for the connection to be lost after I start the message listeners.
    I couldn't find the bug you were talking about in the bug database: the number you wrote is the bug ID, isn't it? I did my search at http://developer.java.sun.com/developer/bugParade/index.jshtml.
    Thanks.
  • 3. Re: connection loss
    807581 Newbie
    Currently Being Moderated
    What I
    saw is that if I disconnet the net cable of the
    machine where the message listeners have been
    started, then their onException method is called
    straightaway, but when the connection just times out
    gracefully (provided that is what really happens),
    Please read the section about "half-open" connections which
    was discussed above. The problem you are seeing is
    because you have a "half-open" connection situation.

    When you pull out a network cable, an application ONLY
    receives notification from tcp if data is flowing on the system.

    On the broker side, the connection will closed. This is because
    the broker periodically "PINGS" the client to make sure that
    it is still there (writing data on to the system) which allows
    the broker to realize that the connection is gone.

    The client does not currently send periodic pings to the
    broker (see the bug I mentioned) so the broker will
    receive an exception but the client will not.

    Again .. please look at the bug I mentioned to get more
    information about how to work around this type of problem
    on the client
  • 4. Re: connection loss
    807581 Newbie
    Currently Being Moderated
    I've already tried to look for the bug you mentioned, but I couldn't find it. I searched by bug id 4953659.
  • 5. Re: connection loss
    807581 Newbie
    Currently Being Moderated
    Here's the workaround info from the bug:

    If the client is only a subscriber, it can still generate traffic between the client and broker by either creating a session and closing it or creating a temporary topic and deleting it. If the client periodically does either of these things, it will trigger the ExceptionListener.onException.
  • 6. Re: connection loss
    856936 Newbie
    Currently Being Moderated
    hi my name is naveen,

    I am also facing same problem,

    iam using Message Listner and onMessage is not firing always, when i restart my server all message are getting up clear.

    while restarting my server my servlet will create session and connection to JMS, its very strange problem, and iam not getting any Exceptions or Error messages.

    how to implement Exception listner in JMS could you please let me know, and did you fine solution for this problem.

    thaks
    Naveen
  • 7. Re: connection loss
    ak Explorer
    Currently Being Moderated
    Please see MQ 4.5 doc on connection ping related properties
    http://download.oracle.com/docs/cd/E18930_01/html/821-2438/aeooe.html
    http://download.oracle.com/docs/cd/E18930_01/html/821-2438/aeont.html

    JMS ExceptionListener Java doc and specification
    http://download.oracle.com/javaee/6/api/
    http://www.oracle.com/technetwork/java/jms-136181.html