title: Mule message enricher from jdbc source
body: <p>I'd like to enrich the current message with two variables, LAST_POLL_START and LAST_POLL_END. These variables are then going to be used to build another jdbc query.</p>
  
  <p>However, I cannot understand how I should use the enricher. The code I've tried is below, and it is inspired by the code found <a href="http://www.mulesoft.org/jira/browse/MULE-5541?page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#issue-tabs" rel="nofollow">here</a> and on <a href="http://blogs.mulesoft.org/enrich-your-experience-orchestration-and-data-enrichment-with-mule-3-1/" rel="nofollow">Mule's blog</a>. In my mind, this should work. I'm using mule-3.2.0, and the jdbc query works and returns the correct values.</p>
  
  <pre><code>&lt;flow name="MasterFlow" processingStrategy="synchronous"&gt;
      &lt;quartz:inbound-endpoint jobName="cronJobPoolTime" cronExpression="0 0/1 * * * ?"&gt;
          &lt;quartz:endpoint-polling-job&gt;
              &lt;quartz:job-endpoint ref="jdbc_quartzDummy"/&gt;
          &lt;/quartz:endpoint-polling-job&gt;
      &lt;/quartz:inbound-endpoint&gt;      
      &lt;flow-ref name="GetPollingTimes" /&gt;
      &lt;!-- Do other things --&gt;
  &lt;/flow&gt;
  
  &lt;!-- Below is needed when using Quartz trigger --&gt;
  &lt;jdbc:endpoint name="jdbc_quartzDummy" connector-ref="tabuConnector" queryKey="quartzDummy" /&gt;
  
  &lt;flow name="GetPollingTimes"&gt;
      &lt;enricher&gt;
          &lt;jdbc:outbound-endpoint queryKey="getPollTimes" exchange-pattern="request-response" /&gt;
          &lt;enrich target="#[variable:last_poll_start]" source="#[map-payload:LAST_POLL_START]"/&gt;
          &lt;enrich target="#[variable:last_poll_end]" source="#[map-payload:LAST_POLL_END]"/&gt;
      &lt;/enricher&gt;
      &lt;logger level="INFO" message="last_poll_start = #[variable:last_poll_start]" /&gt;
  &lt;/flow&gt;
  </code></pre>
  
  <p>The error message is:</p>
  
  <pre><code>WARN  2011-12-27 15:38:00,831 [scheduler-ESB_Worker-1] org.mule.DefaultMuleMessage: setProperty(key, value) called with null value; removing key: last_poll_start; please report the following stack trace to dev@mule.codehaus.org
  java.lang.Throwable
      at org.mule.DefaultMuleMessage.setProperty(DefaultMuleMessage.java:456)
      at org.mule.expression.VariableExpressionEnricher.enrich(VariableExpressionEnricher.java:24)
      at org.mule.expression.DefaultExpressionManager.enrich(DefaultExpressionManager.java:248)
      at org.mule.expression.DefaultExpressionManager.enrich(DefaultExpressionManager.java:237)
      at org.mule.enricher.MessageEnricher.enrich(MessageEnricher.java:69)
      at org.mule.enricher.MessageEnricher.process(MessageEnricher.java:43)
      at org.mule.processor.chain.DefaultMessageProcessorChain.doProcess(DefaultMessageProcessorChain.java:99)
      at org.mule.processor.chain.AbstractMessageProcessorChain.process(AbstractMessageProcessorChain.java:64)
      at org.mule.processor.AbstractInterceptingMessageProcessorBase.processNext(AbstractInterceptingMessageProcessorBase.java:105)
      at org.mule.processor.AsyncInterceptingMessageProcessor.process(AsyncInterceptingMessageProcessor.java:90)
      at org.mule.processor.chain.DefaultMessageProcessorChain.doProcess(DefaultMessageProcessorChain.java:99)
      at org.mule.processor.chain.AbstractMessageProcessorChain.process(AbstractMessageProcessorChain.java:64)
      at org.mule.processor.AbstractInterceptingMessageProcessorBase.processNext(AbstractInterceptingMessageProcessorBase.java:105)
      at org.mule.interceptor.AbstractEnvelopeInterceptor.process(AbstractEnvelopeInterceptor.java:55)
      at org.mule.processor.AbstractInterceptingMessageProcessorBase.processNext(AbstractInterceptingMessageProcessorBase.java:105)
      at org.mule.processor.AbstractFilteringMessageProcessor.process(AbstractFilteringMessageProcessor.java:41)
      at org.mule.processor.chain.DefaultMessageProcessorChain.doProcess(DefaultMessageProcessorChain.java:99)
      at org.mule.processor.chain.AbstractMessageProcessorChain.process(AbstractMessageProcessorChain.java:64)
      at org.mule.processor.chain.InterceptingChainLifecycleWrapper.doProcess(InterceptingChainLifecycleWrapper.java:56)
      at org.mule.processor.chain.AbstractMessageProcessorChain.process(AbstractMessageProcessorChain.java:64)
      at org.mule.processor.chain.InterceptingChainLifecycleWrapper.process(InterceptingChainLifecycleWrapper.java:87)
      at org.mule.construct.Flow.process(Flow.java:64)
      at org.mule.config.spring.factories.FlowRefFactoryBean$1.process(FlowRefFactoryBean.java:44)
      at org.mule.processor.chain.DefaultMessageProcessorChain.doProcess(DefaultMessageProcessorChain.java:99)
      at org.mule.processor.chain.AbstractMessageProcessorChain.process(AbstractMessageProcessorChain.java:64)
      at org.mule.processor.AbstractInterceptingMessageProcessorBase.processNext(AbstractInterceptingMessageProcessorBase.java:105)
      at org.mule.interceptor.AbstractEnvelopeInterceptor.process(AbstractEnvelopeInterceptor.java:55)
      at org.mule.processor.AbstractInterceptingMessageProcessorBase.processNext(AbstractInterceptingMessageProcessorBase.java:105)
      at org.mule.processor.AbstractFilteringMessageProcessor.process(AbstractFilteringMessageProcessor.java:41)
      at org.mule.processor.chain.DefaultMessageProcessorChain.doProcess(DefaultMessageProcessorChain.java:99)
      at org.mule.processor.chain.AbstractMessageProcessorChain.process(AbstractMessageProcessorChain.java:64)
      at org.mule.processor.chain.InterceptingChainLifecycleWrapper.doProcess(InterceptingChainLifecycleWrapper.java:56)
      at org.mule.processor.chain.AbstractMessageProcessorChain.process(AbstractMessageProcessorChain.java:64)
      at org.mule.processor.chain.InterceptingChainLifecycleWrapper.process(InterceptingChainLifecycleWrapper.java:87)
      at org.mule.construct.AbstractPipeline$1.process(AbstractPipeline.java:138)
      at org.mule.processor.chain.DefaultMessageProcessorChain.doProcess(DefaultMessageProcessorChain.java:99)
      at org.mule.processor.chain.AbstractMessageProcessorChain.process(AbstractMessageProcessorChain.java:64)
      at org.mule.processor.chain.InterceptingChainLifecycleWrapper.doProcess(InterceptingChainLifecycleWrapper.java:56)
      at org.mule.processor.chain.AbstractMessageProcessorChain.process(AbstractMessageProcessorChain.java:64)
      at org.mule.processor.chain.InterceptingChainLifecycleWrapper.process(InterceptingChainLifecycleWrapper.java:87)
      at org.mule.processor.chain.DefaultMessageProcessorChain.doProcess(DefaultMessageProcessorChain.java:99)
      at org.mule.processor.chain.AbstractMessageProcessorChain.process(AbstractMessageProcessorChain.java:64)
      at org.mule.processor.chain.InterceptingChainLifecycleWrapper.doProcess(InterceptingChainLifecycleWrapper.java:56)
      at org.mule.processor.chain.AbstractMessageProcessorChain.process(AbstractMessageProcessorChain.java:64)
      at org.mule.processor.chain.InterceptingChainLifecycleWrapper.process(InterceptingChainLifecycleWrapper.java:87)
      at org.mule.transport.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:190)
      at org.mule.transport.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:163)
      at org.mule.transport.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:150)
      at org.mule.transport.quartz.jobs.EndpointPollingJob$1.doInTransaction(EndpointPollingJob.java:162)
      at org.mule.transport.quartz.jobs.EndpointPollingJob$1.doInTransaction(EndpointPollingJob.java:125)
      at org.mule.transaction.TransactionTemplate.execute(TransactionTemplate.java:45)
      at org.mule.transport.quartz.jobs.EndpointPollingJob.doExecute(EndpointPollingJob.java:169)
      at org.mule.transport.quartz.jobs.AbstractJob.execute(AbstractJob.java:36)
      at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
      at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:534)
  </code></pre>
  
  <p>Changing the enrich source to #[payload]:</p>
  
  <pre><code>&lt;enrich target="#[variable:last_poll_start]" source="#[payload]"/&gt;
  &lt;logger level="INFO" message="last_poll_start = #[variable:last_poll_start]" /&gt;
  </code></pre>
  
  <p>Produces (from log file):</p>
  
  <pre><code>org.mule.api.processor.LoggerMessageProcessor: last_poll_start = [{LAST_POLL_START=2011-12-21, LAST_POLL_END=2000-01-01}]
  </code></pre>