Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try binding to EventData #278

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open

Try binding to EventData #278

wants to merge 1 commit into from

Conversation

pragnagopa
Copy link
Member

No description provided.

@pragnagopa
Copy link
Member Author

pragnagopa commented Mar 4, 2019

EventHubs library is part of the lib folder:
javafunctionlib

lib folder is part of default class path.

Binding to eventdata fails with:

Exception: UnsupportedOperationException: Interface can't be instantiated! Interface name: com.microsoft.azure.eventhubs.EventData
Stack: java.lang.RuntimeException: Unable to invoke no-args constructor for interface com.microsoft.azure.eventhubs.EventData. Registering an InstanceCreator with Gson for this type may fix this problem.
[3/4/2019 2:44:00 AM] 	at com.google.gson.internal.ConstructorConstructor$14.construct(ConstructorConstructor.java:228)
[3/4/2019 2:44:00 AM] 	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:212)
[3/4/2019 2:44:00 AM] 	at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:41)
[3/4/2019 2:44:00 AM] 	at com.google.gson.internal.bind.ArrayTypeAdapter.read(ArrayTypeAdapter.java:72)
[3/4/2019 2:44:00 AM] 	at com.google.gson.Gson.fromJson(Gson.java:927)
[3/4/2019 2:44:00 AM] 	at com.google.gson.Gson.fromJson(Gson.java:892)
[3/4/2019 2:44:00 AM] 	at com.google.gson.Gson.fromJson(Gson.java:841)

EventData object needs to rehydrated from the input data:

    EventData data = new EventData(message);
    LinkedHashMap<String, Object> sysProps = new LinkedHashMap<>();
    sysProps.put("x-opt-offset", offset);
    sysProps.put("x-opt-sequence-number", sequenceNumber);
    addSystemProperties(data, sysProps);

@pragnagopa pragnagopa closed this Apr 24, 2019
@pragnagopa pragnagopa reopened this Apr 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant