I have a mule flow that starts with a jms inbound endpoint.
My requirement is to prevent the queue from reading any messages until I explicitly enable the connector for the endpoint.
So I have an Initializer implementing MuleContextNotificationListener, override onNotification like below:
@Override
public void onNotification(MuleContextNotification ctxNotification) {
System.out.println("Notification order event: " + ctxNotification.getActionName() );
if(ctxNotification.getAction() == MuleContextNotification.CONTEXT_STARTING
|| ctxNotification.getAction() == MuleContextNotification.CONTEXT_STARTED){
try{
//Startup with the Staging and Error Q readers disabled.
System.out.println("STOPPING QUEUES : Staging and Error Queues");
//ctxNotification.getMuleContext().getRegistry().lookupConnector("lynxJMSConnectorStagingQReaderNormal").stop();
ctxNotification.getMuleContext().getRegistry().lookupConnector("lynxJMSConnectorStagingQReaderDR").stop();
ctxNotification.getMuleContext().getRegistry().lookupConnector("lynxJMSConnectorErrorQReader").stop();
ctxNotification.getMuleContext().getRegistry().lookupEndpointFactory().getInboundEndpoint("errorQueueReader").stop();
System.out.println("STOPPED QUEUES");
}catch(MuleException me){
me.printStackTrace();
}
}
}
But the flow still kicks off (reads messages from the jms queue) even while the application is initializing. What should I do to intercept when a connector is initialized so I can stop it? If not, what mechanism should I use to stop the connector from reading it. I already have the code to start/stop the connector from an http call.
I am using Mule 3.2.2 without annotations.
Thanks,
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…