我想每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>
答案 0 :(得分:1)
通过添加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,如下所示: -
<logger message="#[message.payload]" level="INFO" doc:name="Logger"/>
并删除echo component ...
并在JDBC组件中进行 exchange-pattern =“request-response”,如下所示: -
<jdbc-ee:outbound-endpoint queryKey="select_qry" queryTimeout="-1" connector-ref="Database" exchange-pattern="request-response" doc:name="Database"/>