cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
49
Views
0
Helpful
0
Comments
cdnadmin
Level 11
Level 11
This document was generated from CDN thread

Created by: Assaf D on 26-06-2010 08:37:31 PM
Hi,
 
I have more than 1,500 CiscoIPPhone which I have to analyze their jtapi CallEvent and respond with some java/xml code actions  (like DB query and XML Push).
 
I would like to know how to manage the outgoing/incoming concurrent CallEvents without loosing any of them due to an heavy load (Consider that the server machine all required resources).
 
Regards
 
Assaf 
 
 
 

Subject: RE: JTapi concurrent CallEvent throuhput
Replied by: Oliver Henning on 04-08-2010 12:07:00 PM
Hi Assaf,

from my own experience I can recommend the following. Please contact me if you want to help with a problem I have ;-) with XML push.

Your CiscoCallObserver should only add the incoming events to a queue and exit. A separate thread should process the events in that queue. This way events never get lost due to heavy load or delays in event handling because they are always immediately stored in the queue and event handling is completely independent of event retrieval. Remember to put a lock on the queue.

Have as many observers/queues/threads as CPUs/cores is good. If you have like 4 CPUs it's like:
Terminal 1, Terminal 5, ... observed by Observer1 putting events in Queue1 handled by HandlerThread1
Terminal 2, Terminal 6, ... observed by Observer2 putting events in Queue2 handled by HandlerThread2
Terminal 3, Terminal 7, ... observed by Observer3 putting events in Queue3 handled by HandlerThread3
Terminal 4, Terminal 8, ... observed by Observer4 putting events in Queue4 handled by HandlerThread4

Java Code (production code but slightly modified):

[CiscoCallObserver]
            synchronized (pendingQueue) {
                pendingQueue.add(callEvent);
                pendingQueue.notify();
            }


class EventHandlerThread extends Thread {
        List pendingQueue;
      
        EventHandlerThread(List pendingQueue) {
            this.pendingQueue = pendingQueue;
        }  

        public void run() {
            final ArrayList workingQueue = new ArrayList(3);
          
            while (true) {
                try {
                  
                    synchronized (pendingQueue) {
                      
                        // We now have a lock on the pendingQueue, so we can safely check if it is empty...
                        // This check is necessary because we may have missed the notification
                        // because we were not "wait"ing while we were processing events from our working queue.
                        if(pendingQueue.isEmpty()) {

                            // The queue of pending events is empty, so we can give up the lock and wait...
                            pendingQueue.wait();
                        }
                        else {

                            // New pending events arrived while we processed our working queue.
                            // So add them to our working queue now
                            // We need no lock on the working queue as our method is the only one accessing it
                            workingQueue.addAll(pendingQueue);
                            // Clear the event queue and release the lock
                            // as all pending events are now in our working queue
                            pendingQueue.clear();
                        }
                    }

                    for(int i=0; i < workingQueue.size(); i++) {
                        // Fetch event from working queue and handle it
                        event = (Event)workingQueue.get(i);
                        handleEvent(event);
                    }
                  
                    // Now we have processed all events in the working queue so we can empty it
                    workingQueue.clear();
                }
            }
        }
    };



I would like to know how to manage the outgoing/incoming concurrent CallEvents without loosing any of them due to an heavy load (Consider that the server machine all required resources).
Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community:

Quick Links