Hello guys,

I was able to bundle the ActiveMQ and push it into the Apache Felix context
but I faced an issue when I started playing with it:

Here is the scenario :
1/ I created the ActiveMQ bundle inside apache felix, I run it and it
listens to the needed port. 2/ I created the producer bundle and putted all
the needed connection and queue creation in the start method. 3/ I created
the consumer bundle following the same strategy Once I start the producer,
I can see my message sent. Once I run the consumer it's ok I can see the
message received, the issue is once I stop the producer bundle and I
restart it, I was waiting to get a notification from my consumer bundle but
not, I do have to restart the consumer so it knows about the new message
and throw it out. Do you have an idea on how could I get notified by my
bundle once a new message pushed into the broker queue ?


I'm thinking about the fact that I did not used the multithreading, but I'm
not sure, in the activeMq tutos it creates the producers/consumers using
threads.
So probably that's the issue..

Do I have to register my bundle in the osgi service registry ?!


Here is the code I'm using inside my bundle and start method (it does not
implement runnable or runs this inside a thread):

 //this is my start method
           // Create a ConnectionFactory
            ActiveMQConnectionFactory connectionFactory = new
ActiveMQConnectionFactory("vm://localhost");

            // Create a Connection
            Connection connection = connectionFactory.createConnection();
            connection.start();

            // Create a Session
            Session session = connection.createSession(false,
Session.AUTO_ACKNOWLEDGE);

            // Create the destination (Topic or Queue)
            Destination destination = session.createQueue("TEST.FOO");

            // Create a MessageProducer from the Session to the Topic or Queue
            MessageProducer producer = session.createProducer(destination);
            producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);

            // Create a messages
            String text = "Hello world! From: " +
Thread.currentThread().getName() + " : " + this.hashCode();
            TextMessage message = session.createTextMessage(text);

            // Tell the producer to send the message
            System.out.println("Sent message: "+ message.hashCode() +
" : " + Thread.currentThread().getName());
            producer.send(message);

            // Clean up
            session.close();
            connection.close();



Thanks all for your help and sharing about osgi!
_______________________________________________
OSGi Developer Mail List
osgi-dev@mail.osgi.org
https://mail.osgi.org/mailman/listinfo/osgi-dev

Reply via email to