• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 329
  • Last Modified:

flush a failed JMX connection

I connect to a server using JMX connection periodically each 10 sec.
using JMXConnectorFactory.connect
when I unplug the network cable and plug it again ket's say after 20 seconds, seems like there exist more than one connection is already alive.
I want to flush memory if I tried a failed connection so when I plug again the cable I only have one connection not several connections.
0
bachra04
Asked:
bachra04
  • 4
  • 4
  • 2
1 Solution
 
CEHJCommented:
Do you shut down the client cleanly?
0
 
objectsCommented:
make sure you are catching all exceptions (and not ignoring any) and handling them correctly.
0
 
bachra04Author Commented:
Actually the problem I have is this:

I have two threads:

The timer thread and the daemon thread.

The daemon thread has a queue of events and periodically checks this queue to pop events and handle them.

When the daemon receives a TIME OUT event, it makes a JMX connection to get some data.

The problem happens when there is a network problem, at this time since the daemon spends a lot of time trying to make a JMX connection; meanwhile the timer just put another TIME OUT event in the queue and by the time the connection is restored the daemon ends up with 4 or 5 TIME OUT events in his queue and processes them one after the other.

This threading model is not done by me and I shouldnt change at least right now.
I need a good solution to avoid this accumulation of TIME OUT events in the queue.
You have to know that queue is also holding other kinds of events (config change event&) so that the daemon can handle them.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
objectsCommented:
you need to limit your queu to only hold one tiomeout at a time, for example by a check when timeouts are added.
0
 
CEHJCommented:
What causes the TIME OUT?
0
 
objectsCommented:
or maybe stop the timer while trying to make a connection
0
 
bachra04Author Commented:
I need to use wait and signal in the same way used in C++.
just to let the timer waiting before sending the event till he gets notified by the daemon.
Do you know how to do it in java?
0
 
CEHJCommented:
Just make your daemon own a BlockingQueue. When it's full, the timer thread, offering, will not be able to enqueue

http://java.sun.com/javase/6/docs/api/java/util/concurrent/ArrayBlockingQueue.html
0
 
CEHJCommented:
:-)
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now