Skip to content

Instantly share code, notes, and snippets.

@ricston-git
Created March 5, 2018 13:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ricston-git/bb3844da7efcc4a6d53fee23269eae7c to your computer and use it in GitHub Desktop.
Save ricston-git/bb3844da7efcc4a6d53fee23269eae7c to your computer and use it in GitHub Desktop.
@Override
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException
{
muleContext = getMuleContext(jobExecutionContext);
if (muleContext.isPrimaryPollingInstance() ||
TRUE.equals(jobExecutionContext.getJobDetail().getJobDataMap().get(PROPERTY_JOB_DYNAMIC)))
{
doExecute(jobExecutionContext);
}
}
<custom-connector name="CustomPollingConnector" class="org.mule.transport.polling.MessageProcessorPollingConnector">
<service-overrides messageReceiver="com.ricston.blogs.polling.NonClusterAwarePollingMessageReceiver"/>
</custom-connector>
public class NonClusterAwareJob extends EventGeneratorJob {
@Override
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
doExecute(jobExecutionContext);
}
}
public class NonClusterAwarePollingMessageReceiver extends MessageProcessorPollingMessageReceiver {
/** Constructors **/
/**
* A method which ignores the cluster member state and performs the polls regardless.
* Returning 'true' (i.e. the default value in the super-class) will cause only primary node to poll.
* Returning 'false' will cause ALL nodes in the cluster to poll.
*/
@Override
protected boolean pollOnPrimaryInstanceOnly() {
return false;
}
}
<flow name="sample-quartz-flow">
<quartz:inbound-endpoint address="quartz://myJob?jobDynamic=true" repeatInterval="60000" doc:name="Quartz Poll">
<quartz:event-generator-job>
<quartz:payload>Sample Job data</quartz:payload>
</quartz:event-generator-job>
</quartz:inbound-endpoint>
<logger message="#[payload]" level="INFO" doc:name="Log payload"/>
</flow>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment