parallel-consumer icon indicating copy to clipboard operation
parallel-consumer copied to clipboard

vertxHttpReqInfo only supports GET (Unable to call HTTP POST or PUT etc)

Open OpenSourceTycoon opened this issue 2 years ago • 18 comments

Hi There,

I'm able to consume the Kafka Message, but while i trigger the async API call using

Stream<JStreamVertxParallelEoSStreamProcessor.VertxCPResult<String,String>> resultStream = parallelConsumer.vertxHttpReqInfoStream(record -> {
String apiReq = "{id:1}";
// Need to call POST VERB
Map<String, String> params = UniMaps.of("recordKey", "12345", "payload", apiReq );
return new VertxParallelEoSStreamProcessor.RequestInfo("abc.workin.net", 8443, "/api/v1/limit", params);

This is internally calling GET VERB ( not POST VERB ). Can someone help me understand the POST call ?

OpenSourceTycoon avatar Nov 23 '21 13:11 OpenSourceTycoon

@astubbs : Can you help me on this ?

OpenSourceTycoon avatar Nov 24 '21 10:11 OpenSourceTycoon

Hi @OpenSourceTycoon ! Welcome to the project, and thanks for submitting this issue! We appreciate your involvement.

You have indeed uncovered some missing features :) The vertxReqInfo method currently only supports GET requests, as seen on this line.

It shouldn't be hard to add support for the other methods.

However, in the mean time, as a workaround, you can simply use the other methods - either vertxHttpRequest, or vertxWebClient which let you construct any sort of request you want that VertX's WebClient interface supports.

Let me know if that solves your problem.

astubbs avatar Nov 24 '21 11:11 astubbs

@astubbs : can you provide examples for vertxHttpRequest, or vertxWebClient ?

OpenSourceTycoon avatar Nov 24 '21 14:11 OpenSourceTycoon

Sure!


    void webClientExample(VertxParallelStreamProcessor<String, String> parallelConsumer) {
        parallelConsumer.vertxHttpRequest((wc, rec) -> wc.post("some uri"),
                httpResponseFuture -> {
                },
                httpResponseAsyncResult -> {
                }
        );
    }

    void httpRequestExample(VertxParallelStreamProcessor<String, String> parallelConsumer) {
        parallelConsumer.vertxHttpWebClient((wc, rec) -> wc.post("some uri").send(),
                httpResponseFuture -> {
                }
        );
    }

astubbs avatar Nov 24 '21 14:11 astubbs

I've also added a PR to make the API simpler for your use- assuming you aren't interested in using the callback hooks?

https://github.com/confluentinc/parallel-consumer/pull/181/files

astubbs avatar Nov 24 '21 15:11 astubbs

@astubbs PR available for Merge Process. Can you provide the release jars path after merge process. ? Thanks in advance.

OpenSourceTycoon avatar Nov 24 '21 18:11 OpenSourceTycoon

The PR doesn't need to be merged to solve your problem. Just use the "no op" call back functions like in the example above. E.g. :httpResponseFuture -> {}

astubbs avatar Nov 24 '21 19:11 astubbs

Thanks @astubbs. I'm using below code

parallelConsumer.vertxHttpWebClient((wc, rec) -> wc.postAbs("some uri").send(), httpResponseFuture -> { } );

However, i see "Failed to create SSL connection" - Vert.x Vertical Fail : Failed to create SSL connection" issue

OpenSourceTycoon avatar Nov 25 '21 14:11 OpenSourceTycoon

There is a method on the HttpClientOptions, we need to call that method with false. We can use options class in to my code.

OpenSourceTycoon avatar Nov 25 '21 14:11 OpenSourceTycoon

Are you still having an issue? Can you provide. Full failing example perhaps with a broken test?

astubbs avatar Nov 25 '21 14:11 astubbs

@astubbs : Yes. our usecase is

  • Pull multiple kafka messages from Confluent Cluster
  • Call Parallel API calls to API
  • Persist the data

OpenSourceTycoon avatar Nov 25 '21 14:11 OpenSourceTycoon

Please find the code

VertxParallelStreamProcessor<String,String> parallelConsumer;

public void run(){
Consumer<String,String> kafakaConsumer = getKafkaConsumer();

var options = parallelConsumerOptions.<String, String>builder().ordering(KEY).consumer(kafakaConsumer).maxConcurrency(10).build();

this.parallelConsumer = VertxParallelStreamProcessor.createEosStreamProcessor(options);

parallelConsumer.subscrribe(of("test-topic"));

parallelConsumer.vertxHttpWebClient((wc,rec) -> wc.postAbs("https://www.google.com").putHeaders("Content-Type","application/json").sendJson("{}").onSuccess(response -> { log.info("Response""+response.bodyAsString())}
.onFailure(err -> log.info("Failure"); }), httpResponseFuture -> {
});

}

OpenSourceTycoon avatar Nov 25 '21 15:11 OpenSourceTycoon

What's the issue?

astubbs avatar Nov 25 '21 15:11 astubbs

2021-11-25 11:47:44.084 [vert.x-eventloop-thread-1] INFO c.j.c.r.u.a.c.ParallelConsumer - Failure --Failed to create SSL connection 2021-11-25 11:47:44.084 [vert.x-eventloop-thread-1] ERROR i.c.p.v.VertxParallelEoSStreamProcessor - Vert.x Vertical fail: Failed to create SSL connection

OpenSourceTycoon avatar Nov 25 '21 15:11 OpenSourceTycoon

our port is 8443 not 443. vert.x function validating the SSL Certificate and not able to see the CIPHER. May be we can set - HttpClinetOptions.setTrustAll(true); Not sure ..how to map with webclient object.

OpenSourceTycoon avatar Nov 25 '21 16:11 OpenSourceTycoon

I'm referring this example

OpenSourceTycoon avatar Nov 25 '21 16:11 OpenSourceTycoon

Hi Antony,

I updated the thread - https://github.com/confluentinc/parallel-consumer/issues/180

On Thu, Nov 25, 2021 at 9:00 PM Antony Stubbs @.***> wrote:

What's the issue?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/confluentinc/parallel-consumer/issues/180#issuecomment-979304855, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABF5VWLSDMBUPQ3JVTFKEDUNZJCHANCNFSM5ITPSBBQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

-- Krishna Rao Veeramachaneni

OpenSourceTycoon avatar Nov 25 '21 16:11 OpenSourceTycoon

@OpenSourceTycoon Were you able to solve this issue?

ozturkberkay avatar Jan 20 '22 14:01 ozturkberkay