【发布时间】:2015-01-02 04:45:20
【问题描述】:
我有一个小问题......我正在公开一个 REST 服务,它以 JSON 格式获取数据列表...... 以下是我的流程:-
<flow name="MainService" doc:name="MainService">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8082" doc:name="HTTP"/>
<jersey:resources doc:name="REST">
<component class="com.test.services.schema.maindata.v1.Impl.MainDataImpl"/>
</jersey:resources>
</flow>
现在,如果我点击该服务,我将收到以下格式的响应:-
{
"retrieveAllData":
[
{
"response": "The Data retrieved from the Database",
"id": 1231,
"name": "abc",
"age": 561,
"designation": "Senior Software Engineer"
},
{
"response": "The Data retrieved from the Database",
"id": 165,
"name": "test",
"age": 561,
"designation": "Senior Software Engineer"
},
{
"response": "The Data retrieved from the Database",
"id": 134,
"name": "test2",
"age": 561,
"designation": "Senior Software Engineer"
},
{
"response": "The Data retrieved from the Database",
"id": 7,
"name": "test3",
"age": 561,
"designation": "Senior Software Engineer"
},
{
"response": "The Data retrieved from the Database",
"id": 9,
"name": "testagain",
"age": 561,
"designation": "Senior Software Engineer"
},
{
"response": "The Data retrieved from the Database",
"id": 10,
"name": "newteat",
"age": 561,
"designation": "Senior Software Engineer"
},
{
"response": "The Data retrieved from the Database",
"id": 11,
"name": "ani",
"age": 561,
"designation": "Senior Software Engineer"
},
{
"response": "The Data retrieved from the Database",
"id": 12,
"name": "test",
"age": 561,
"designation": "Senior Software Engineer"
},
{
"response": "The Data retrieved from the Database",
"id": 135,
"name": "fff",
"age": 561,
"designation": "Senior Software Engineer"
},
{
"response": "The Data retrieved from the Database",
"id": 166,
"name": "fff",
"age": 561,
"designation": "Senior Software Engineer"
},
{
"response": "The Data retrieved from the Database",
"id": 167,
"name": "fff",
"age": 561,
"designation": "Senior Software Engineer"
},
{
"response": "The Data retrieved from the Database",
"id": 444,
"name": "fff",
"age": 561,
"designation": "Senior Software Engineer"
},
{
"response": "The Data retrieved from the Database",
"id": 446,
"name": "fff",
"age": 561,
"designation": "Senior Software Engineer"
},
{
"response": "The Data retrieved from the Database",
"id": 447,
"name": "fff",
"age": 561,
"designation": "Senior Software Engineer"
},
{
"response": "The Data retrieved from the Database",
"id": 442,
"name": "fff",
"age": 561,
"designation": "Senior Software Engineer"
},
{
"response": "The Data retrieved from the Database",
"id": 133,
"name": "fff",
"age": 561,
"designation": "Senior Software Engineer"
},
{
"response": "The Data retrieved from the Database",
"id": 4,
"name": "againtest",
"age": 561,
"designation": "Senior Software Engineer"
},
{
"response": "The Data retrieved from the Database",
"id": 3,
"name": "fdf",
"age": 561,
"designation": "Senior Software Engineer"
},
{
"response": "The Data retrieved from the Database",
"id": 8,
"name": "fff",
"age": 561,
"designation": "Senior Software Engineer"
},
{
"response": "The Data retrieved from the Database",
"id": 445,
"name": "fff",
"age": 561,
"designation": "Senior Software Engineer"
}
]
}
现在,由于这个响应又长又大,我想把这个响应分成 5 个小部分,比如:-
{
"response": "The Data retrieved from the Database",
"id": 447,
"name": "test",
"age": 561,
"designation": "Senior Software Engineer"
},
{
"response": "The Data retrieved from the Database",
"id": 442,
"name": "test2",
"age": 561,
"designation": "Senior Software Engineer"
},
{
"response": "The Data retrieved from the Database",
"id": 133,
"name": "fff",
"age": 561,
"designation": "Senior Software Engineer"
},
{
"response": "The Data retrieved from the Database",
"id": 4,
"name": "test3",
"age": 561,
"designation": "Senior Software Engineer"
},
{
"response": "The Data retrieved from the Database",
"id": 3,
"name": "fff",
"age": 561,
"designation": "Senior Software Engineer"
}
所以,我遵循了以下内容:- Mule - split a big JSON list into multiple smaller JSON lists
在我的流程中的球衣组件之后,我添加了以下内容:-
<json:json-to-object-transformer returnClass="java.util.Map"/>
<foreach batchSize="5">
<json:object-to-json-transformer/>
<logger message="ResponseLogdadasd :- #[message.payload]" level="INFO" doc:name="ResponseLogger"/>
</foreach>
现在,我收到以下异常:-
********************************************************************************
Message : Infinite recursion (StackOverflowError) (through reference chain: ->org.mule.DefaultMuleContext["workManager"]->org.mule.work.MuleWorkManager["muleContext"]->org.mule.DefaultMuleContext["workManager"]->org.mule.work.MuleWorkManager["muleContext"]->org.mule.DefaultMuleContext["workManager"]->org.mule.work.MuleWorkManager["muleContext"]->org.mule.DefaultMuleContext["workManager"]->org.mule.work.MuleWorkManager["muleContext"]->org.mule.DefaultMuleContext["workManager"]->org.mule.work.MuleWorkManager["muleContext"]->org.mule.DefaultMuleContext["workManager"]->org.mule.work.MuleWorkManager["muleContext"]->org.mule.DefaultMuleContext["workManager"]->org.mule.work.MuleWorkManager["muleContext"]->org.mule.DefaultMuleContext["workManager"]->org.mule.work.MuleWorkManager["muleContext"]->org.mule.DefaultMuleContext["workManager"]->org.mule.work.MuleWorkManager["muleContext"]->org.mule.DefaultMuleContext["workManager"]->org.mule.work.MuleWorkManager["muleContext"]->org.mule.DefaultMuleContext["workManager"]->org.mule.work.MuleWorkManager["muleContext"]->org.mule.DefaultMuleContext["workManager"]->org.mule.work.MuleWorkManager["muleContex...--------------------------------------------------------------------------------
Root Exception stack trace:
java.lang.StackOverflowError
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:792)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************
我做得对吗?这是我可以在批量大小为 5 中将响应分成更小的部分的方式吗?请给个建议
【问题讨论】:
标签: json mule mule-studio