我想每2分钟执行一次查询,但是出现以下错误。

--------------------------------------------------------------------------------
Exception stack is:
1. No serializer found for class org.mule.transport.NullPayload and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS) ) (org.codehaus.jackson.map.JsonMappingException)
  org.codehaus.jackson.map.ser.impl.UnknownSerializer:52 (null)
2. No serializer found for class org.mule.transport.NullPayload and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS) ) (org.codehaus.jackson.map.JsonMappingException) (org.mule.api.transformer.TransformerException)
  org.mule.module.json.transformers.ObjectToJson:107 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/transformer/TransformerException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
org.codehaus.jackson.map.JsonMappingException: No serializer found for class org.mule.transport.NullPayload and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS) )
    at org.codehaus.jackson.map.ser.impl.UnknownSerializer.failForEmpty(UnknownSerializer.java:52)
    at org.codehaus.jackson.map.ser.impl.UnknownSerializer.serialize(UnknownSerializer.java:25)
    at org.codehaus.jackson.map.ser.StdSerializerProvider._serializeValue(StdSerializerProvider.java:610)
    + 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************


我的流程如下。

 <flow name="testdbFlow1" doc:name="testdbFlow1">

        <quartz:inbound-endpoint responseTimeout="10000" doc:name="Quartz" jobName="CronJobSchedule" repeatInterval="0" cronExpression="0 0/2 * ? * MON-FRI" repeatCount="1">
        <quartz:event-generator-job/>
        </quartz:inbound-endpoint>
        <jdbc-ee:outbound-endpoint queryKey="select_qry" queryTimeout="-1"  connector-ref="Database" doc:name="Database"/>
        <json:object-to-json-transformer doc:name="Object to JSON"/>
        <echo-component doc:name="Echo"/>

    </flow>

最佳答案

通过添加quartz:payload尝试以下操作:

<flow name="testdbFlow1" doc:name="testdbFlow1">
<quartz:inbound-endpoint responseTimeout="10000" doc:name="Quartz" jobName="CronJobSchedule" repeatInterval="0" cronExpression="0 0/2 * ? * MON-FRI" repeatCount="1">
        <quartz:event-generator-job>
<quartz:payload>quartzSchedular started</quartz:payload>
</quartz:event-generator-job>
        </quartz:inbound-endpoint>
        <jdbc-ee:outbound-endpoint queryKey="select_qry" queryTimeout="-1"  connector-ref="Database" doc:name="Database"/>
        <json:object-to-json-transformer doc:name="Object to JSON"/>
        <echo-component doc:name="Echo"/>

    </flow>


更新:-
在json:object-to-json-transformer之后使用记录器,如下所示:-

<logger message="#[message.payload]" level="INFO" doc:name="Logger"/>


并删除回声分量...

并在JDBC组件中进行exchange-pattern =“ request-response”,如下所示:-

<jdbc-ee:outbound-endpoint queryKey="select_qry" queryTimeout="-1"  connector-ref="Database" exchange-pattern="request-response" doc:name="Database"/>

关于java - 如何使用 quartz 在m子中每2分钟运行一次查询,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/25382997/

10-15 11:03