Dear All,
I’m implementing a Java-based RPC service over XMPP. I’m using ejabberd and smack as an xmpp client.
When i’m sending 100 simple XMPP messages to a recipient (takes only seconds), the other entity receives it very slowly (takes minutes).
The recipient entity has only a packetlistener and printing the delivery timestamp.
I edited the source code of smack to print the packet listener call’s date and the code was invoked very slowly.
Whet could be the problem? Is there a timing problem/configuration in ejabberd or the smack library contains a scheduling?
Any help is much appreciated.
Thanks in advance!
Here is a code sample demonstrating my problem:
public class XMPPSimpleTest { private static CountDownLatch latch; public static void main(String[] args) throws Exception { int messageCount = 1000;
long time = 0;
latch = new CountDownLatch( messageCount );
String domain = "prototype"; ConnectionConfiguration config1 =
new ConnectionConfiguration(
"localhost", 5222, domain
);
config1.setCompressionEnabled( true );
config1.setReconnectionAllowed( true ); XMPPConnection conn1 = new XMPPConnection( config1 );
conn1.connect();
conn1.login( "test1", "test1" ); ConnectionConfiguration config2 =
new ConnectionConfiguration(
"localhost", 5222, domain
);
config2.setCompressionEnabled( true );
config2.setReconnectionAllowed( true ); XMPPConnection conn2 = new XMPPConnection( config2 );
conn2.connect();
conn2.login( "test2", "test2" ); Chat c = conn1.getChatManager().createChat( "test2@"+domain, new MessageListener(){
@Override
public void processMessage(Chat chat, Message message) {
}
} ); System.out.println(" " + (time = System.currentTimeMillis()) );
for( int i=0; i<messageCount; ++i )
c.sendMessage("Domo");
conn2.addPacketListener(
new PacketListener(){
@Override
public void processPacket(Packet packet) {
System.out.println(packet + " " + latch.getCount() );
latch.countDown();
}
},
new PacketTypeFilter( Message.class )
); latch.await(); System.out.println(" " + (System.currentTimeMillis()-time) ); conn1.disconnect(); conn2.disconnect();
} }
If you run it, you will see, that only 3-4 messages arrives in a second. Any idea?