Member since
06-07-2017
11
Posts
0
Kudos Received
0
Solutions
01-19-2018
08:29 AM
@Shu Thank you so much for your answer and for taking time to prepare an environment to test my PoC. I really appreciate that. My problem was that I was trying to read the Json with "JsonPathReader" service. Changing to "JsonTreeReader" made the trick. Anyway, I went forward with the PoC and now I'm sending the converted Avro data to a Kafka cluster and I'm trying to deserialize it after consuming. For all this, I'm using the Hortonworks schema-registry which works fine in Nifi but I can't get it to work in Java. I've tryied the example here but I'm getting an error at the time of declaring the deserializedObject. Here you can see the code: public void runAvroSerDesApis(byte[] serializedData, String name) throws IOException {
this.serializedData = serializedData;
this.name = name;
//using builtin avro serializer/deserializer
/*AvroSnapshotSerializer avroSnapshotSerializer = new AvroSnapshotSerializer();
avroSnapshotSerializer.init(config);*/
AvroSnapshotDeserializer deserializer = schemaRegistryClient.getDefaultDeserializer(AvroSchemaProvider.TYPE);
deserializer.init(config);
Object deviceObject = createGenericRecordForDevice(name);
SchemaMetadata schemaMetadata = createSchemaMetadata("avro-serializer-schema-" + System.currentTimeMillis());
//byte[] serializedData = avroSnapshotSerializer.serialize(deviceObject, schemaMetadata);
Object deserializedObj = deserializer.deserialize(new ByteArrayInputStream(serializedData), schemaMetadata, null);
LOG.info("Serialized and deserialized objects are equal: [{}] ", deviceObject.equals(deserializedObj));
}
The line retrieving the error is "Object deserializedObj = deserializer.deserialize(new ByteArrayInputStream(serializedData), schemaMetadata, null);" and it says more or less that "actual and format argument lists differ in lenght" Is there any example someone could provide about how to deserialize an Avro message in Java using Hortonworks Schema-Registry? I'm using v0.2.1. Thanks in advance.
... View more
01-16-2018
01:05 PM
Hello,
I'm trying to convert an array of Json to avro and I'm facing some difficulties. This is the Json I want to convert: [{"MeasureId":"nifiHeartBeat", "Value":"1", "AuditDateTime":"Tue Jan 16 13:48:58 CET 2018", "DATA_SOURCE":"20083"}] And here is the schema I'm declaring in the ConvertJSONToAvro processor (based on what I rode here😞 {
"type": "record",
"name": "NifiHeartBeat_v3",
"fields": [
{
"name": "columns",
"type": {
"type": "array",
"items": {
"type": "record",
"name": "columnValues",
"fields": [
{
"name": "MeasureId",
"type": "string",
"default": "null"
},
{
"name": "Value",
"type": "string",
"default": "null"
},
{
"name": "AuditDateTime",
"type": "string",
"default": "null"
},
{
"name": "DATA_SOURCE",
"type": "string",
"default": "null"
}
]
}
}
}
]
}
This is the error I'm getting: 2018-01-16 14:00:25,780 WARN [Timer-Driven Process Thread-3] o.a.n.processors.kite.ConvertJSONToAvro ConvertJSONToAvro[id=b0a67367-f541-38d5-176f-c07d4a75dd24] Failed to convert 1/1 records from JSON to Avro Note: If I get this to work I would move the schema to Hortonworks Schema-Registry, but I wanted to get it work in "local" first. Could someone help me please? Thanks in advance.
... View more
Labels:
- Labels:
-
Schema Registry
09-15-2017
12:03 PM
Hi @Matt Clarke, Thank you. So, how about cleaning this cache eventually? Is it possible to clean it whenever a duplicate is found? I'm trying with the Eviction Strategy Property but no getting anything so far... I would like to clean the cache whenever a duplicate is found. Thanks!
... View more
09-13-2017
10:44 AM
So, I've accomplished the comparisson of two flowfiles. Trying to complicate this a bit more, what about if I have more than two flowfiles to compare? Is there any processor for this? Other option would be to "play" with the DetectDuplicate and create different levels of comparisson... but I don't like it so much thus the DetectDuplicate itself is very clean. Any idea @Matt Clarke, @Rob ? Thanks!
... View more
09-13-2017
09:38 AM
Hi @Matt Clarke, That processor made the trick. It's exactly what I was looking for. Thank you so much. Best, Jon
... View more
09-12-2017
12:49 PM
Yes, I've tried to use RouteOnAttribute but the thing is that I want to compare two different flowfiles attributes... and as far as I understand, RouteOnAttribute doesn't allow this kind of comparison... tell me if I'm wrong!
... View more
09-12-2017
12:48 PM
Hi @Matt Clarke, I just want to compare some attributes from both flowfiles... I'll try with that processor and I'll be back!
... View more
09-08-2017
07:19 AM
Hi, New question added here: https://community.hortonworks.com/questions/135939/compare-attributes-of-different-flowfiles.html Hope you can help me. Jon
... View more
09-07-2017
03:12 PM
Hello, Is it possible to compare the attributes of two different flowfiles and only pass one if the comparisson results matched? Thank you, Jon
... View more
Labels:
- Labels:
-
Apache NiFi
09-07-2017
01:11 PM
Hello, Is it possible to compare the attributes of two different flowfiles and only pass one if the comparisson results matched? Thank you, Jon
... View more