Hi Thibault,

Looks like the docs are out of date.

If you read the compilation error message carefully, you'll notice Jackson.marshaller is giving you a |Marshaller<java.lang.Integer,akka.http.javadsl.model.*Request**Entity*>|

while completeWithFuture is expecting a |akka.http.javadsl.marshalling.Marshaller<T,akka.http.javadsl.model.*HttpResponse*>)|

Instead you, try complet*OK*WithFuture which takes a |Marshaller<T,akka.http.javadsl.model.*Request**Entity*>|

It's tough to spot the difference and RouteDirectives comes with a lot of overrides. I only knew what to look for because this hit me when calling complete[OK]WithSource on FramedEntityStreamingDirectives which fortunately only has 2 completeXxx methods

Hope that helps,
Michał

On 29/04/17 21:56, Thibault Meyer wrote:
According to http://doc.akka.io/docs/akka-http/10.0.5/java/http/common/json-support.html we have to use

|
akka.http.javadsl.marshallers.jackson.Jackson.marshaller(T.class)
|


But this method does not exists anymore.

|
akka.http.javadsl.marshallers.jackson.Jackson.marshaller()
akka.http.javadsl.marshallers.jackson.Jackson.marshaller(ObjectMappero)
|





Le samedi 29 avril 2017 20:52:12 UTC+2, Thibault Meyer a écrit :

    Hello,

    I have a blocking operation that I would like to run on the custom
    dispatcher. But I can't return completeWithFuture.

    I'm using the latest version of Akka Http on Java 8.


    |
    publicRoutecreateRoute(){
    returnroute(
                path(PathMatchers.segment("shipment")
    .slash(PathMatchers.segment()),trackingNumber ->
    get(()->{
    finalMessageDispatcherdispatcher
    =akkaSystem.dispatchers().lookup("application.dispatcher");
    finalCompletionStage<Integer>c
    =CompletableFuture.<Integer>supplyAsync(()->666,dispatcher);
    returncompleteWithFuture(c,Jackson.<Integer>marshaller());
    }))
    )
    );
    }

    |



    I get the following compilation error :


    |
        method
    
akka.http.javadsl.server.directives.RouteDirectives.<T>completeWithFuture(scala.concurrent.Future<T>,akka.http.javadsl.marshalling.Marshaller<T,akka.http.javadsl.model.HttpResponse>)isnotapplicable
    (cannot infer type-variable(s)T
    (argument
    mismatch;java.util.concurrent.CompletionStage<java.lang.Integer>cannot
    be converted to scala.concurrent.Future<T>))
        method
    
akka.http.javadsl.server.directives.RouteDirectives.<T>completeWithFuture(java.util.concurrent.CompletionStage<T>,akka.http.javadsl.marshalling.Marshaller<T,akka.http.javadsl.model.HttpResponse>)isnotapplicable
    (cannot infer type-variable(s)T
    (argument
    
mismatch;akka.http.javadsl.marshalling.Marshaller<java.lang.Integer,akka.http.javadsl.model.RequestEntity>cannot
    be converted to
    
akka.http.javadsl.marshalling.Marshaller<T,akka.http.javadsl.model.HttpResponse>))
    |



    Thanks

--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ: http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka User List" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected] <mailto:[email protected]>. To post to this group, send email to [email protected] <mailto:[email protected]>.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

--
Signature
<http://www.openbet.com/>         Michal Borowiecki
Senior Software Engineer L4
        T:      +44 208 742 1600

        
        +44 203 249 8448

        
        
        E:      [email protected]
        W:      www.openbet.com <http://www.openbet.com/>

        
        OpenBet Ltd

        Chiswick Park Building 9

        566 Chiswick High Rd

        London

        W4 5XT

        UK

        
<https://www.openbet.com/email_promo>

This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the [email protected] <mailto:[email protected]> and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by OpenBet for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. OpenBet Ltd. Registered Office: Chiswick Park Building 9, 566 Chiswick High Road, London, W4 5XT, United Kingdom. A company registered in England and Wales. Registered no. 3134634. VAT no. GB927523612

--
     Read the docs: http://akka.io/docs/
     Check the FAQ: http://doc.akka.io/docs/akka/current/additional/faq.html
     Search the archives: https://groups.google.com/group/akka-user
--- You received this message because you are subscribed to the Google Groups "Akka User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to