You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Arjan Moraal <na...@ajmoraal.fastmail.net> on 2008/01/08 10:21:29 UTC

Inspecting seda queues

Hi all,

Our application consists of a lot of seda queues linking all routes and
components together. But at the moment it is a bit of a black box, once a
message from the JMS goes into a Camel route, there's nothing besides log4j
output until the message comes out at the end of the route. 
Since some of the components might be slow (we've created a one for a slow
proprietary system we are using), it is possible that one of the seda queues
might be filling up and we need to tweak the number of threads, etc.

So I though about some way to get an overview of all the seda queues in the
system and the number of messages waiting in the queues. 

One possibility would be to create a static SedaRegister class where every
SedaProducer registers itself upon instantiation. Via this register any
class inside the same JVM could query the seda queues and write the state to
a textfile, a database, or some management console. Or a JMX wrapper around
this register.

Another possibility would be to have a static Map where every SedaProducer
writes its name and number of messages to, everytime a message is added
to/removed from the queue.

Or is there something in Camel already to achieve this?

Thanks,
Arjan

-- 
View this message in context: http://www.nabble.com/Inspecting-seda-queues-tp14685106s22882p14685106.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Inspecting seda queues

Posted by James Strachan <ja...@gmail.com>.
On 08/01/2008, James Strachan <ja...@gmail.com> wrote:
> On 08/01/2008, Arjan Moraal <na...@ajmoraal.fastmail.net> wrote:
> >
> > Hi all,
> >
> > Our application consists of a lot of seda queues linking all routes and
> > components together. But at the moment it is a bit of a black box, once a
> > message from the JMS goes into a Camel route, there's nothing besides log4j
> > output until the message comes out at the end of the route.
> >
> > Since some of the components might be slow (we've created a one for a slow
> > proprietary system we are using), it is possible that one of the seda queues
> > might be filling up and we need to tweak the number of threads, etc.
> >
> > So I though about some way to get an overview of all the seda queues in the
> > system and the number of messages waiting in the queues.
> >
> > One possibility would be to create a static SedaRegister class where every
> > SedaProducer registers itself upon instantiation. Via this register any
> > class inside the same JVM could query the seda queues and write the state to
> > a textfile, a database, or some management console. Or a JMX wrapper around
> > this register.
> >
> > Another possibility would be to have a static Map where every SedaProducer
> > writes its name and number of messages to, everytime a message is added
> > to/removed from the queue.
> >
> > Or is there something in Camel already to achieve this?
>
> We've been adding some JMX metrics so you can see throughput through
> endpoints and so forth (rather like folks monitor JMS queues using JMX
> stats). Try using trunk (as many of these changes were made after
> 1.2.0), enable JMX
> <camelContext useJmx="true" ... />
>
> and have a look with jConsole at things running and see what you think
> - feedback greatly appreciated.
>
> That reminds me - we really need a JMX page on the wiki describing how
> it works and how to use jConsole etc.
>
>
> I've also been wondering if we need a kinda Browser API in Camel to
> allow you to browse capable endpoints. Not all endpoints will be
> Browser-enabled but many will (e.g. HTTP, Files, JMS, SEDA) - there's
> no reason why you couldn't browse the endpoint to see the pending
> messages available, just like you'd browse a JMS queue.

Here's the 2 JIRAs I've just raised for those issues...

http://issues.apache.org/activemq/browse/CAMEL-284
http://issues.apache.org/activemq/browse/CAMEL-285
-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://open.iona.com

Re: Inspecting seda queues

Posted by cmoulliard <cm...@gmail.com>.
Is Camel JMX working ?

I have activated the JMX by setting the parameter <camelContext
useJmx="true" in my context

but when I launch my jconsole, the screen is desperately empty even if I try
to connect to the link mentioned in the blog service:jmx:rmi:///

Remark : I have launched my Camel context through Eclipse using 
Main starter = new Main();
starter.setApplicationContextUri(spring/camelContext.xml);
starter.run(args);

Regards,

Charles


Hadrian Zbarcea wrote:
> 
> Hi Arjan,
> 
> Yeah, that would work.  I'm glad you got it running.  We'll make it 
> nicer with camel-285 :).
> 
> Thanks
> Hadrian
> 
> Arjan Moraal wrote:
>>
>> Arjan Moraal wrote:
>>   
>>> Hi Hadrian,
>>>
>>>
>>> Hadrian Zbarcea wrote:
>>>     
>>>> Thanks for your interest in Camel.  Enabling JMX in your code is fairly 
>>>> easy.  This is what you have to do:
>>>>
>>>>       
>>> Thanks, I've got it working now.
>>> Can't find the actual number of messages in a seda queue though, the
>>> seda
>>> endpoints just have an uri attribute at the moment.
>>> But I guess adding current number of messages is part of the work to be
>>> done for CAMEL-285
>>>
>>>     
>>
>> I managed to include the number of messages in the seda queue by adding
>> the
>> following method to ManagedEndpoint.java:
>>
>>     @ManagedAttribute(description = "Messages In Queue")
>>     public int getMessagesInQueue() throws Exception {
>>         if (endpoint instanceof SedaEndpoint) {
>>             return ((SedaEndpoint)endpoint).getQueue().size();
>>         } else {
>>             return -1;
>>         }
>>     }
>>
>> Not really an elegant solution, but it works for us for the moment.
>>
>> Thanks,
>> Arjan
>>
>>   
> 
> 

-- 
View this message in context: http://www.nabble.com/Inspecting-seda-queues-tp14685106s22882p16851040.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Inspecting seda queues

Posted by Hadrian Zbarcea <hz...@gmail.com>.
Hi Arjan,

Yeah, that would work.  I'm glad you got it running.  We'll make it 
nicer with camel-285 :).

Thanks
Hadrian

Arjan Moraal wrote:
>
> Arjan Moraal wrote:
>   
>> Hi Hadrian,
>>
>>
>> Hadrian Zbarcea wrote:
>>     
>>> Thanks for your interest in Camel.  Enabling JMX in your code is fairly 
>>> easy.  This is what you have to do:
>>>
>>>       
>> Thanks, I've got it working now.
>> Can't find the actual number of messages in a seda queue though, the seda
>> endpoints just have an uri attribute at the moment.
>> But I guess adding current number of messages is part of the work to be
>> done for CAMEL-285
>>
>>     
>
> I managed to include the number of messages in the seda queue by adding the
> following method to ManagedEndpoint.java:
>
>     @ManagedAttribute(description = "Messages In Queue")
>     public int getMessagesInQueue() throws Exception {
>         if (endpoint instanceof SedaEndpoint) {
>             return ((SedaEndpoint)endpoint).getQueue().size();
>         } else {
>             return -1;
>         }
>     }
>
> Not really an elegant solution, but it works for us for the moment.
>
> Thanks,
> Arjan
>
>   

Re: Inspecting seda queues

Posted by Arjan Moraal <na...@ajmoraal.fastmail.net>.


Arjan Moraal wrote:
> 
> Hi Hadrian,
> 
> 
> Hadrian Zbarcea wrote:
>> 
>> Thanks for your interest in Camel.  Enabling JMX in your code is fairly 
>> easy.  This is what you have to do:
>> 
> 
> Thanks, I've got it working now.
> Can't find the actual number of messages in a seda queue though, the seda
> endpoints just have an uri attribute at the moment.
> But I guess adding current number of messages is part of the work to be
> done for CAMEL-285
> 

I managed to include the number of messages in the seda queue by adding the
following method to ManagedEndpoint.java:

    @ManagedAttribute(description = "Messages In Queue")
    public int getMessagesInQueue() throws Exception {
        if (endpoint instanceof SedaEndpoint) {
            return ((SedaEndpoint)endpoint).getQueue().size();
        } else {
            return -1;
        }
    }

Not really an elegant solution, but it works for us for the moment.

Thanks,
Arjan

-- 
View this message in context: http://www.nabble.com/Inspecting-seda-queues-tp14685106s22882p14713961.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Inspecting seda queues

Posted by Arjan Moraal <na...@ajmoraal.fastmail.net>.
Hi Hadrian,


Hadrian Zbarcea wrote:
> 
> Thanks for your interest in Camel.  Enabling JMX in your code is fairly 
> easy.  This is what you have to do:
> 

Thanks, I've got it working now.
Can't find the actual number of messages in a seda queue though, the seda
endpoints just have an uri attribute at the moment.
But I guess adding current number of messages is part of the work to be done
for CAMEL-285


-- 
View this message in context: http://www.nabble.com/Inspecting-seda-queues-tp14685106s22882p14713121.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Inspecting seda queues

Posted by Hadrian Zbarcea <hz...@gmail.com>.
Hi Arjan,

Thanks for your interest in Camel.  Enabling JMX in your code is fairly 
easy.  This is what you have to do:

        protected InstrumentationAgent iAgent;
        [...]

        CamelContext context = new DefaultCamelContext();

        iAgent = new InstrumentationAgentImpl();
        iAgent.setCamelContext(context);
        iAgent.enableJmx(null, 0);
        iAgent.start();

You can then use jconsole to connect to 
"service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi" and see your 
metrics (you can pass your own domain name and port in enableJmx() if 
you want to override the defaults: "org.apache.camel" and "1099").

If you got the source from the apache repository you can take a look at:
camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationUsingDefaultsTest.java

Please keep an eye on the jira's James created too.

Cheers
Hadrian


Arjan Moraal wrote:
> James.Strachan wrote:
>   
>> We've been adding some JMX metrics so you can see throughput through
>> endpoints and so forth (rather like folks monitor JMS queues using JMX
>> stats). Try using trunk (as many of these changes were made after
>> 1.2.0), enable JMX
>> <camelContext useJmx="true" ... />
>>
>>     
>
> That's about what we need I think. Do you know how to enable it from Java
> code? We're not using Spring configuration but just start Camel from a
> standalone Java app by calling
>     CamelContext context = new DefaultCamelContext();
>
> Thanks,
> Arjan
>
>   

Re: Inspecting seda queues

Posted by Arjan Moraal <na...@ajmoraal.fastmail.net>.

James.Strachan wrote:
> 
> We've been adding some JMX metrics so you can see throughput through
> endpoints and so forth (rather like folks monitor JMS queues using JMX
> stats). Try using trunk (as many of these changes were made after
> 1.2.0), enable JMX
> <camelContext useJmx="true" ... />
> 

That's about what we need I think. Do you know how to enable it from Java
code? We're not using Spring configuration but just start Camel from a
standalone Java app by calling
    CamelContext context = new DefaultCamelContext();

Thanks,
Arjan

-- 
View this message in context: http://www.nabble.com/Inspecting-seda-queues-tp14685106s22882p14689812.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Inspecting seda queues

Posted by James Strachan <ja...@gmail.com>.
On 08/01/2008, Arjan Moraal <na...@ajmoraal.fastmail.net> wrote:
>
> Hi all,
>
> Our application consists of a lot of seda queues linking all routes and
> components together. But at the moment it is a bit of a black box, once a
> message from the JMS goes into a Camel route, there's nothing besides log4j
> output until the message comes out at the end of the route.
>
> Since some of the components might be slow (we've created a one for a slow
> proprietary system we are using), it is possible that one of the seda queues
> might be filling up and we need to tweak the number of threads, etc.
>
> So I though about some way to get an overview of all the seda queues in the
> system and the number of messages waiting in the queues.
>
> One possibility would be to create a static SedaRegister class where every
> SedaProducer registers itself upon instantiation. Via this register any
> class inside the same JVM could query the seda queues and write the state to
> a textfile, a database, or some management console. Or a JMX wrapper around
> this register.
>
> Another possibility would be to have a static Map where every SedaProducer
> writes its name and number of messages to, everytime a message is added
> to/removed from the queue.
>
> Or is there something in Camel already to achieve this?

We've been adding some JMX metrics so you can see throughput through
endpoints and so forth (rather like folks monitor JMS queues using JMX
stats). Try using trunk (as many of these changes were made after
1.2.0), enable JMX
<camelContext useJmx="true" ... />

and have a look with jConsole at things running and see what you think
- feedback greatly appreciated.

That reminds me - we really need a JMX page on the wiki describing how
it works and how to use jConsole etc.


I've also been wondering if we need a kinda Browser API in Camel to
allow you to browse capable endpoints. Not all endpoints will be
Browser-enabled but many will (e.g. HTTP, Files, JMS, SEDA) - there's
no reason why you couldn't browse the endpoint to see the pending
messages available, just like you'd browse a JMS queue.

-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://open.iona.com