WSO2 ESB Convert 70MB JSON payload to XML - wso2-esb

Can WSO2 ESB convert 70MB json payload to xml with passthrough transport?
I tried but getting JVM heap running out of memory (2GB heap size).
Any suggestions?

Mabye you can try convert this JSON in JAVA code and use it as Class mediator, like this https://docs.wso2.com/display/ESB481/Class+Mediator

Related

Java Component in Mule does not use project's UTF-8 encoding

I have a java component in Mule that is returning a String. When I print that string from within the java component, it reads as UTF-8 just fine in the console. However, when I return this as the payload, the subsequent logger and all downstream components can no longer read the UTF-8 characters. I've confirmed that my project's encoding setting is set to 'UTF-8'. I've also:
Setting MULE_ENCODING=UTF-8 before and after the Java component, both as an outbound property and invocation property.
Setting the encoding on the message in a mule expression, but that failed message.setEncoding('UTF-8') with an error stating it could not find the method setEncoding()
Using the following in the java component:
eventContext.getMessage().setPayload(myString);
eventContext.getMessage().setEncoding("UTF-8");
return eventContext.getMessage().getPayload();
Switching to a java transformer instead of a component, using the below config on the transformer, explicitly setting encoding to "UTF-8".
<custom-transformer encoding="UTF-8"
class="myDomain.myJavaTransformer" doc:name="Java"/>
I'm not sure what else to try to ensure the payload coming out of the java component/transformer is not interpreted or converted to another encoding...
The output should read: “Outstanding New Environmental Scientist”
The logger currently outputs is “Outstanding New Environmental Scientistâ€. I've corrected this in other parts of the flow by adding encoding=UTF-8 to any VM endpoints, for example. I've also confirmed that this can print correctly in a logger elsewhere in the flow.
There seems to be something happening after the String is returned from within the java class referenced by the java component and the subsequent mule logger...
try <object-to-string-transformer encoding="..." /> right after your java component
I had a problem with encoding too. It was not completely similar to your case but I took this action and it worked for me. (Byte to array using java serialization)
<set-property propertyName="MULE_ENCODING" value="UTF-8" doc:name="Property" />
<byte-array-to-string-transformer encoding="UTF-8" doc:name="Byte Array to String"/>
I used that when message is coming to my flow.
Also there is properties in wrapper and you can set that as well.
How are you reading the RSS feed? If it is using an endpoint, try setting the 'encoding' attribute for that endpoint?

How to store protobuffer object in redis cache?

I'm using Jedis as the java client to connect to Redis servers. I am also using protocol buffers to write the data in jedis or redis cache. But I'm not finding the way how to write or set the protobuf object to redis. Am I missing something or Jedis doesn't provide the way to store protobuf object as value?
This is a late answer...
You can serialize the Protobuf message into a binary string, and save it to Redis using the SET command. However, whenever you need to get the Protobuf message, you have to get the binary string back, and deserialize it. Even if you only want to get a single field.
Another solution is that you can use the redis-protobuf module to save the Protobuf message into Redis. With this module, you can read or write the Protobuf message. If you only need a single field, you don't need to get the whole message back, redis-protobuf will only return that field.
Disclaimer: I'm the author of redis-protobuf.

Create api using mulesoft studio

How can i create a simple api using mulesoft stodio? I am using the MySql Database and trying to create REST apis and following this tutorial.
http://www.mulesoft.org/documentation/display/current/Creating+an+API+for+a+MySQL+Database
But facing the error
Error executing graph: ERROR (com.mulesoft.mule.module.datamapper.api.exception.DataMapperExecutionException). Message payload is of type: ArrayList
You have something wrong with your DataMapper definitions, probably a mismatch between the data coming from MySql and the data types for the fields in your DataMapper. Check your data types, the complete error message in Mule Studio, and the output of the Logger between the MySql component and DataMapper if you have a configuration similar to the example in the tutorial.
i was in assumption that the data mapper source data does not match with the payload it received.
according to error , the data-mapper input is of some format you defined but the received input is of array-list.
I am getting the 404 response on the link that you had mentioned in your question.
Your error is not related to what you were asking about How to create Rest API in mule.
As per concern about creating Rest API mule offers two ways:
Using the Rest Component (Recommended when you have rest specification defined in java using the jersey or apache-axis)
ApiKit Router with RAML (Higly recommended by mulesoft community)
As per your concern about error.
you might have not properly mapped the input fields of datamapper with the outbound messages from DB connector.
DB Connector always returns the response as ArrayList that need to be caste into any collection like Map or Array.
I recommend kindly use data sense feature of mulesoft DB connector that will automatically map the input fields of data mapper.
if possible share your flow.
Hope this helps.
Check the inbound properties of data mapper. output of DB query should not be in unknown format. If it is unknown format, then there is something wrong with your query output.
If you are looking for API creation, then check out the below link.
https://docs.mulesoft.com/anypoint-platform-for-apis/walkthrough-design-existing
check the document how to create API
https://docs.mulesoft.com/anypoint-platform-for-apis/
and regarding the DataMapper error just check the input data type to the output data type you are mapping. just cross check the input format to output format.
I suggest to use data weave now . Data mapper is obsolete . Define metadata for your HTTP end by giving some sample JSON and with database you will automatically get metadata extracted by data sense. Now you can use drag and drop for mapping your fields and it will transform input to requited output. you can also look data weave expression generated and now you can change that easily to tweak that.

SBJson Stream Parser

I'm working in Xcode 4.3.2 + building for an app in iOS 5.
I've decided to use SBJson to parse streams of data from our server. I've verified that I'm receiving a valid JSON response from the server. My question concerns the design behind the classes SBJsonStreamParser and the SBJsonParser.
It appears that in SBJsonParser the method "objectWithData" takes the data received from the JSON response and uses the SBJsonStreamParserAccumulator to append the stream of data into a single JSON document. Once the data stream is gathered into one object, it is then parsed by the "parse" method in SBJsonStreamParser.
I've run into several issues when requesting larger JSON documents. The size of the responses seem to be reasonable (specially 9.4 KB response). It appears that the SBJsonStreamParser breaks when getting a data stream greater than a certain size. The parser succeeds when the response is small (~3KB), but fails when the response is larger (~10KB).
I used NSLog to verify that in both cases, pulling a small & large stream, the methods are successfully receiving the full json document - because it looks like [{"id": .... 123}]. I'm convinced that the issue is that the data stream is too long.
I'm wondering if I'm using SBJson incorrectly or is this simply a limitation of the parser? Is there anything that I can configure that allows SBJsonStreamParser to not throw an error for larger (but reasonable) data streams & continue to parse the full response?
Thanks in advance!
Actually you have the workings of objectWithData: backwards. SBJsonStreamParserAccumulator is used to accumulate the parsed output, not the unparsed data stream.

How to send image through axis2

My Service class designed through Axis2, I am able to send any data type of resords like
(premetive datatypes). I don't know how to send Image file.
Have a read of the documentation - its very good for Axis2 -> http://axis.apache.org/axis2/java/core/docs/mtom-guide.html
There are some code examples in there too on how to transfer images using Axis2
Use soap with attachment option or MTOM..Following posts are helpful
http://www.ibm.com/developerworks/webservices/library/ws-soapatt/
http://www.keith-chapman.org/2008/09/attachments-mtom-swa-and-base64binary.html