Hi,

Part of my camel route consists of a JMS queue, being polled and its
messages being stored in a db, depending on message type. The route is
transacted, and therefore it's not possible to configure redeliveryDelay in
the ActiveMQXAConnectionFactory bean, but i had to use a custom processor
"redeliveryDelay" instead that checks the JMSXDeliveryCount in the header
and introduces a delay depending on the retry count.
I would like to have the possibility to configure/manage this processor and
its methods through jconsole/jmx but am having some problems with it:
- without using the annotations @ManagedResource, @ManagedAttribute i can
see the processor mbean, but cannot see its methods
- with annotations the processor mbean is not visible anymore (even if i
"implement Service" like mentioned in the camel FAQ, or if i implement the
deprecated ManagementAware). I also tried using only @ManagedResource or
@ManagedAttribute separately...
- when moving the processor to the recoverable camel:onException route
(preferable since its only executed when needed) the mbean is not visible at
all; even without annotations.


Any ideas?

regards, Tim


Relevant part of route:

<camel:route id="routeStoreInDB">
        <camel:from uri="jms:queue:incoming?transacted=true" />
        <camel:transacted ref="PROPAGATION_REQUIRED"/>
        <camel:process ref="redeliveryDelay" id="redeliveryDelay"/>
        <camel:choice>
                <camel:when>
                        <camel:spel>#{request.headers['CamelHL7MessageType'] ==
'ADT'}</camel:spel>
                                <camel:bean ref="ADTHandler" 
method="processADT" />
                        </camel:when>
                        <camel:when>
                                
<camel:spel>#{request.headers['CamelHL7MessageType'] ==
'ORM'}</camel:spel>
                                <camel:bean ref="ORMHandler" 
method="processORM" />
                        </camel:when>
                <camel:otherwise>
                        <camel:log message="NOT HANDLED 
Type:${header.CamelHL7MessageType}
Msg:${body}" />
                </camel:otherwise>
        </camel:choice>
        <camel:onException> 
                <camel:exception>java.sql.SQLException</camel:exception>
        
<camel:exception>org.springframework.jdbc.CannotGetJdbcConnectionException</camel:exception>
                <camel:handled>
                        <camel:constant>false</camel:constant>
                </camel:handled>
                <camel:log message="Recoverable error occurred! Will retry in a 
few
seconds..." loggingLevel="ERROR" logName="routeStoreInDB_ORM"/>
                
                <camel:rollback markRollbackOnly="true" />
        </camel:onException>
        <camel:onException> 
                <camel:exception>java.lang.Exception</camel:exception>
        
<camel:exception>org.springframework.jdbc.UncategorizedSQLException</camel:exception>
                <camel:handled>
                        <camel:constant>true</camel:constant>
                </camel:handled>
                <camel:log message="Irrecoverable error occurred!" 
loggingLevel="ERROR"
logName="routeStoreInDB_ORM"/>
                <camel:to uri="jms:queue:DLQ" />
</camel:onException>
</camel:route>


Processor code:

import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.api.management.ManagedAttribute;
import org.apache.camel.api.management.ManagedResource;

@ManagedResource
public class redeliveryDelay implements Processor {
    
    private long delay = 0;
    
    @ManagedAttribute
    public long getDelay() {
        return delay;
    }

    @ManagedAttribute
    public void setDelay(long delay) {
        this.delay = delay;
    }
    
    @Override
    public void process(Exchange exchange) throws Exception {
        String redeliveryCountAsString =
exchange.getIn().getHeader("JMSXDeliveryCount", String.class);
        if(redeliveryCountAsString==null) { redeliveryCountAsString="1"; }
        int redeliveryCount = Integer.parseInt(redeliveryCountAsString);
        
        switch (redeliveryCount) {
            case  0: this.setDelay(0);             break;
            case  1: 
            case  2: 
            case  3: this.setDelay(5000);          break;   // 3 x 5 seconds
            case  4: this.setDelay(60*1000);       break;   // 1 minute
            case  5: this.setDelay(5*60*1000);     break;   // 5 minutes
            case  6: this.setDelay(30*60*1000);    break;   // 30 minutes
            case  7: this.setDelay(60*60*1000);    break;   // 60 minutes
            default: this.setDelay(8*60*60*1000); break;   // every 8 hours
        }
        
        Thread.sleep(this.getDelay());
    }
    
}



--
View this message in context: 
http://camel.465427.n5.nabble.com/Custom-processor-methods-not-visible-in-JConsole-tp5768796.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to