You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2021/03/12 05:23:38 UTC

[GitHub] [pulsar] pointearth opened a new issue #9892: Pulsar function Should support Generic output Message

pointearth opened a new issue #9892:
URL: https://github.com/apache/pulsar/issues/9892


   **Is your feature request related to a problem? Please describe.**
   
   We can prodcue a Generic message with pulsar.client.api:
   `RecordSchemaBuilder recordSchemaBuilder = SchemaBuilder.record(USER_CONST.SCHEMA_NAME);
           recordSchemaBuilder.field(USER_CONST.AGE).type(SchemaType.INT32);
           recordSchemaBuilder.field(USER_CONST.NAME).type(SchemaType.STRING);
           recordSchemaBuilder.field(USER_CONST.JSON_FOR_EVENT).type(SchemaType.STRING);
           SchemaInfo schemaInfo = recordSchemaBuilder.build(SchemaType.AVRO);
           GenericSchema userSchema = Schema.generic(schemaInfo);
           Producer<GenericRecord> producer = pulsarClient.newProducer( userSchema)
                   .topic(TOPIC_CONST.TOPIC_FUN_GENERIC)
                   .create();
           User user = new User();
           user.age = 27;
           user.name = "Simon Generic";
           Gson gson = new Gson();
           String jsonForEvent = gson.toJson(user);
           GenericRecordBuilder genericRecordBuilder = userSchema.newRecordBuilder();
           GenericRecord genericRecord = genericRecordBuilder
                   .set(USER_CONST.AGE, user.age)
                   .set(USER_CONST.NAME,user.name)
                   .set(USER_CONST.JSON_FOR_EVENT, jsonForEvent)
                   .build();`
   
   but, I am trying many ways to produce dynamic object into pulsar, just like:
   `public class FunWrapGeneric implements Function<String, GenericRecord> {
       @Override
       public GenericRecord process(String input, Context context) throws Exception {`
   
   but I always got failed. Can we support this? because I don't want to define a particular wrap class to wrap a POJO class. because the only different thing between this wrap class and the POJO class is wrap class always add a json field to any POJO class.
    
   **Describe the solution you'd like**
   1. Add GenericRecord support for pulsar function
   `public class FunWrapGeneric implements Function<String, GenericRecord>`
   2. or Add an override of pulsar function want a Generic class as a parameter of pulsar function
    `FunWrapGeneric implements Function<String,Schema>` 
   
   cc @sijie @codelipenghui 
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] codelipenghui commented on issue #9892: Pulsar function Should support Generic output Message

Posted by GitBox <gi...@apache.org>.
codelipenghui commented on issue #9892:
URL: https://github.com/apache/pulsar/issues/9892#issuecomment-1058892588


   The issue had no activity for 30 days, mark with Stale label.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] eolivelli commented on issue #9892: Pulsar function Should support Generic output Message

Posted by GitBox <gi...@apache.org>.
eolivelli commented on issue #9892:
URL: https://github.com/apache/pulsar/issues/9892#issuecomment-797266819


   This is related to:
   https://github.com/apache/pulsar/pull/9590
   and to
   https://github.com/apache/pulsar/pull/9481
   
   I really would like to see this feature land soon.
   I believe that the work at #9590 could be extended in order to add an integration test about this specific case


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org