I get it working switching to 4.0M3 version. The same program that I had sent and did not work in 3.2.1 works in this version and all our application now works fine with activemq. I was seen version's 4 roadmap and one item to be implemented called my attention: "in 3.x we sent a message once with a list of all the MessageConsumers on it so that we could avoid sending multiple messages over a socket when several consumers are on the same connection. We should add back that optimisation" May this optimization (missing in version 4 so far) be the cause of that missbehavior ?

That's all for now,

Marcelo


Datacom - Marcelo wrote:

I just did more tests with these samples now only with windows arch. (3 computers 2 xp professional 1 2003 server). I did 2 tests one the broker runs in 2003 server and the other the broker runs in a xp professional. In both when I send a message from windows 2003 server all 3 subscribers receive that message but when a I send a message from windows XP, only the 2 windows xp receives that message.

There is no firewall enabled in any computer. I'm sending a copy of this mail to devel-mailing list because I believe that may be a bug (In the code I wrote or in activemq). The only conclusion I get is that may be an architecture dependant problem as we can see in all these tests in Solaris, Win2k, XP and 2003 server.


Marcelo

-----------------------------------------

Hi, as I told I write 2 small classes to demonstrate what is happening here. The scenario is composed by 3 computers, one running activemq-server (last stable version) in windows 2000 professional, one running solaris 8 and ond running windows xp professional. Java 5_04 is used to run the codes.

I've created a common topic, a simple selector and I'd published a message to all three subscribers from one computer at a time. Here is the results:

When win 2k publishes:
solaris receives,
windows xp does not,
win2k receives (itself)
------------------------
When solaris publishes:
solaris receives (itself),
windows xp does not,
win2k receives
------------------
When windows xp publishes:
solaris receives,
windows xp receives (it self),
win2k receives

I sent attached the classes I used to run the tests, I may be doing something wrong but this same tests run fine with OpenJMS and they are so simple. Just have to pass the openJMS server ip as parameter and the message is published or topic subscriber.

Thanks in advance,


------------------------------------------------------------------------

//package a;

import java.util.Hashtable;

import javax.jms.*;
import javax.naming.Context;
import javax.naming.InitialContext;

import org.activemq.jndi.ActiveMQInitialContextFactory;

public class Mreceiver implements MessageListener {

   public Mreceiver (String jmsServer) {
       Hashtable<String, String> properties = new Hashtable<String, String>();
       Context context;
       TopicConnectionFactory factory;
       Topic topic;
       TopicConnection connection;
       TopicSession session;
       TopicSubscriber tsub;
       String selector = "type=2";
       properties.put(
           Context.INITIAL_CONTEXT_FACTORY,
           ActiveMQInitialContextFactory.class.getName());
       int port = 61616;
       String url = null;

       url = "tcp://" + jmsServer + ":" + port;
       properties.put(Context.PROVIDER_URL, url);
       properties.put("topic.NMS", "NMS");
       try {
           context = new InitialContext(properties);
           factory = (TopicConnectionFactory) 
context.lookup("ConnectionFactory");
           topic = (Topic) context.lookup("NMS");
           connection = factory.createTopicConnection();
           session = connection.createTopicSession(false, 
Session.AUTO_ACKNOWLEDGE);
           tsub = session.createSubscriber(topic, selector, false);
           tsub.setMessageListener(this);
           connection.start();
       } catch (Exception e) {
           System.out.println("Error " + e);
       }
   }
/**
    *
    */
   public static void main(String[] args) {
       String host = args[0];
       System.out.println("Conectando-se ao servidor JMS em " + host);
       new Mreceiver(host);

   }

   public void onMessage (Message msg) {
       System.out.println("Message received");
   }
}

------------------------------------------------------------------------

//package a;

import java.util.Hashtable;

import javax.jms.DeliveryMode;
import javax.jms.Message;
import javax.jms.Session;
import javax.jms.Topic;
import javax.jms.TopicConnection;
import javax.jms.TopicConnectionFactory;
import javax.jms.TopicPublisher;
import javax.jms.TopicSession;
import javax.naming.Context;
import javax.naming.InitialContext;

import org.activemq.jndi.ActiveMQInitialContextFactory;


public class Msender {

   public Msender(String jmsServer) {
       Hashtable<String, String> properties = new Hashtable<String, String>();
       Context context;
       TopicConnectionFactory factory;
       Topic topic;
       TopicConnection connection;
       TopicSession session;
       TopicPublisher publisher;
       properties.put(
           Context.INITIAL_CONTEXT_FACTORY,
           ActiveMQInitialContextFactory.class.getName());
       int port = 61616;
       String url = null;

       url = "tcp://" + jmsServer + ":" + port;

       properties.put(Context.PROVIDER_URL, url);
       properties.put("topic.NMS", "NMS");
       try {
           context = new InitialContext(properties);
           factory = (TopicConnectionFactory) 
context.lookup("ConnectionFactory");
           topic = (Topic) context.lookup("NMS");
           connection = factory.createTopicConnection();
           session = connection.createTopicSession(false, 
Session.AUTO_ACKNOWLEDGE);
           publisher = session.createPublisher(topic);
           Message message = session.createMessage();
           message.setStringProperty("host", "192.168.11.116");
           message.setIntProperty("type", 2);
           publisher.publish(message, DeliveryMode.NON_PERSISTENT, 4, 3000);
       } catch (Exception e) {
           // TODO Auto-generated catch block
           e.printStackTrace();
       }
       System.out.println("Sent message to server in " + jmsServer);
       System.exit(0);
} /**
    *
    */
   public static void main(String[] args) {
       String host = args[0];
       System.out.println("Connecting in JMS server in " + host);
       new Msender(host);

   }

}


Reply via email to