Open tarinidash opened 5 years ago
@tarinidash - Did you get to resolve this ? I have a similar issue where , a function generateSplunkData(@HttpTrigger) sends HttpResponseMessage to processSplunkData((@EventHubTrigger) to read the response sent . But I get the following exception .
Exception: UnsupportedOperationException: Interface can't be instantiated! Interface name: com.microsoft.azure.functions.HttpResponseMessage
Stack: java.lang.RuntimeException: Unable to invoke no-args constructor for interface com.microsoft.azure.functions.HttpResponseMessage. Registering an InstanceCreator with Gson for this type may fix this problem.
@FunctionName("processSplunkData")
public void processSplunkData(
@EventHubTrigger(
name = "msg",
eventHubName = "", // blank because the value is included in the connection string
cardinality = Cardinality.ONE,
connection = "EventHubConnectionString")
HttpResponseMessage item,
@CosmosDBOutput(
name = "databaseOutput",
databaseName = "TelemetryDb",
collectionName = "Reports",
connectionStringSetting = "CosmosDBConnectionString")
OutputBinding<HttpResponseMessage> document,
final ExecutionContext context) {
context.getLogger().info("Event hub message received: " + item.toString());
if(item!=null) document.setValue(item);
}
Hey @dcr007 I am assuming in your case there is a @HttpTrigger which creates this HttpResponseMessage which is stored in an eventHub. If I remember correctly, I gave up on this and made my @HttpTrigger to return a custom class/Bean. I was able to read and deserialize this custom class from @EventHubTrigger
@FunctionName("HttpTrigger-Sample")
@EventHubOutput(name = "message",
eventHubName = "%eventHubName%",
connection = "AzureEventHubConnection")
public final CustomResponseBody run(
@HttpTrigger(name = "httpRequestMessage",
methods = {HttpMethod.POST},
authLevel = AuthorizationLevel.ANONYMOUS) final HttpRequestMessage<Optional<CustomRequest>> httpRequestMessage,
final ExecutionContext context) {
Assert.notNull(httpRequestMessage, "httpRequestMessage cannot be null");
logger = context.getLogger();
CustomResponseBody responseBody =. getCustomResponse(logger, httpRequestMessage);
return responseBody;
}
In the above case CustomResponseBody is a custom Java Bean that I created. Hope it helps.
Thanks
hey tarinidash - thanks ! So does the CustomResponseBody
implements HttpResponseMessage
?
I have a function(@HttpTrigger) which writes HttpResponseMessage to email topic. I am trying to create another function(@EventHubTrigger) to read message from this topic.
I understand HttpResponseMessage is an interface. Is there any implementation class available that I can cast to?