EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Efficiency

Also by EldoS: SecureBlackbox
200+ components and classes for digital security, signing, encryption and secure networking.
#25129
Posted: 05/31/2013 04:06:40
by fu bill (Basic support level)
Joined: 04/20/2013
Posts: 5

Hi, Eugene. I test the code using the Java language, it was found in MCQueue message listener is added later, when there are 1000 messagesĀ is received, the message is queued listener handle 1000 messages instead of concurrency. This will not be too inefficient?
#25131
Posted: 05/31/2013 04:12:59
by Eugene Mayevski (EldoS Corp.)

Queues are not independent. In fact, each MCMessenger has one queue (list) of incoming messages. We had some plans to remake this in MsgConnect 3, but this is in distant future.


Sincerely yours
Eugene Mayevski
#25133
Posted: 05/31/2013 06:34:51
by fu bill (Basic support level)
Joined: 04/20/2013
Posts: 5

Although there are a lot of queue, but the queue does not parallel processing message. For example: I was in the queue A suspended thread for 10 seconds, then queue B in 10 seconds after the start of execution. That is to say they cannot work in parallel



Server code
Code

package Server;

import org.eldos.MsgConnect.MCBase.EMCError;
import org.eldos.MsgConnect.MCBase.MCHandleMessageEvent;
import org.eldos.MsgConnect.MCBase.MCHandleMessageListener;
import org.eldos.MsgConnect.MCBase.MCMessage;
import org.eldos.MsgConnect.MCBase.MCMessenger;
import org.eldos.MsgConnect.MCBase.MCQueue;
import org.eldos.MsgConnect.MCSocket.MCInetTransport;
import org.eldos.MsgConnect.MCSocket.MCSocketTransport;


public class Server{
   private MCQueue queueA = new MCQueue();
   private MCQueue queueB = new MCQueue();
   private MCSocketTransport transport = new MCSocketTransport();
   private MCMessenger messenger = new MCMessenger();
   long l = 0;
   long ll = 0;

   /** Creates new form Server */
   public Server() {
      initServerSocket();
   }
   
   public void start(){
      transport.setActive(true);
   }

   private void initServerSocket() {
      // TODO Auto-generated method stub
      try {
         transport.setMessengerAddress("0.0.0.0");
      } catch (EMCError e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
      }
      
      queueA.setMessenger(messenger);
      queueA.setQueueName("SendTestA");
      
      queueA.addUnhandledMessageListener(new MCHandleMessageListener() {
         public boolean handleMessage(MCHandleMessageEvent e) {
            return queue_HandleMessage_A(e);
         }
      });

      transport.setMessenger(messenger);
      transport.setTransportMode(MCInetTransport.stmServer);
      transport.setMessengerPort(8088);
      transport.setMaxTimeout(900000);
      transport.setMaxMsgSize(65535);
      transport.setActive(false);
      transport.setInactivityTime(50000);

      
      queueB.setMessenger(messenger);
      queueB.setQueueName("SendTestB");
      
      queueB.addUnhandledMessageListener(new MCHandleMessageListener() {
         public boolean handleMessage(MCHandleMessageEvent e) {
            return queue_HandleMessage_B(e);
         }
      });

      // call dispatchMessage()
      for (int i = 0; i < 5; i++) {
         new Thread(new Runnable() {
            public void run() {
               // TODO Auto-generated method stub
               while (true) {
                  try {
                     messenger.dispatchMessages();
                     Thread.sleep(100);
                  } catch (EMCError e) {
                     // TODO Auto-generated catch block
                     e.printStackTrace();
                  } catch (InterruptedException e) {
                     // TODO Auto-generated catch block
                     e.printStackTrace();
                  }
               }
            }
         }).start();
      }
      
   }

   boolean queue_HandleMessage_A(MCHandleMessageEvent e) {
      System.out.println("queueA Time:"+System.currentTimeMillis());
      
      try {
         MCMessage message = e.getMessage();
         byte[] data = message.getData();

         if ((data != null) && (data.length > 0)) {
            return true;
         }

         return false;
      } catch (Exception ex) {
         System.out.println(ex.getMessage());

         return false;
      }
   }
   
   
   boolean queue_HandleMessage_B(MCHandleMessageEvent e) {
      System.out.println("queueB Time:"+System.currentTimeMillis());
      
      try {
         Thread.sleep(1000);
      } catch (InterruptedException e1) {
         // TODO Auto-generated catch block
         e1.printStackTrace();
      }
      
      
      
      try {
         MCMessage message = e.getMessage();
         byte[] data = message.getData();

         if ((data != null) && (data.length > 0)) {
            return true;
         }

         return false;
      } catch (Exception ex) {
         System.out.println(ex.getMessage());

         return false;
      }
   }

   
   public static void main(String args[]) {
      Server server = new Server();
      server.start();
   }

}

Reply

Statistics

Topic viewed 3452 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!