Hello,

I was trying to implement an interceptor to log some events happening in the
broker. I want the events to be logged as messages in queue. Thus, the
monitoring client could access the log by consuming messages from that
queue.

(I didn't uses advisory topics because I want to dequeue treated messages so
that they will not be treated many times).

So I used interceptors as described  here
<http://activemq.apache.org/interceptors.html>  .
This example worked correctly for me. However when I do this modification
(to put the log as messages in a queue), I doesn't work any more. (The
modification is in Bold)


public class MyBroker extends BrokerFilter {
     public MyBroker(Broker next) {
        super(next);                
    }
    public void addConnection(ConnectionContext context, ConnectionInfo
info) throws Exception {       
         
        *factory = new
ActiveMQConnectionFactory(ActiveMQConnection.DEFAULT_BROKER_URL);
        connection = factory.createConnection();
        connection.start();
        session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        destination = session.createQueue("monitoring.notifications");
        producer = session.createProducer(destination);
        TextMessage message = session.createTextMessage();
        message.setText("addConnection "+info.getConnectionId()+"  
!"+info.getClientId());
        producer.send(message);
        session.close();
        connection.close();*
        super.addConnection(context, info);
    }   
}/


This seemed logic for me since my modification passes throw the interceptor
witch makes infinite calls for this class.
For this reason, I thought to take profit of the object "next" in this
implementation which is of type org.apache.activemq.broker.Broker to put a
message in the queue.

Could you please help me ?

Regards,




--
View this message in context: 
http://activemq.2283324.n4.nabble.com/put-a-message-in-queue-using-org-apache-activemq-broker-Broker-tp4697413.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Reply via email to