[ 
https://issues.apache.org/jira/browse/CAMEL-6648?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13749831#comment-13749831
 ] 

Jan Matèrne commented on CAMEL-6648:
------------------------------------

Thanks for the feedback.
If you could wait a day or two I would try another iteration.

So your requests are

1. Reuse the ProducerTemplate
I could change the constructor to get the context (for creating the Exchange) 
as before and additionally the PT (instead of context.createPT).
So this should be enough.

2. Move the building-state to a new class. Delay the creation and sending.
Should also be not difficult.
There is a problem with dealing return-types and async sending/future objects:
    Future<Exchange> future = ...
    .resultAs(MyResponse.class)
    .asyncSend()
I think about subclassing Future so I could write a get() method
    FutureExchange extends Future<Exchange> {
        T get(Class<T> type) {
            super.get().getIn().getBody(type)
        }
    }
maybe I could overwrite the existing get() method ...

3. asyncStyle, dispatchInOut, dispatchInOnly, etc. methods conclude the 
building ...
Currently this is done by send() and asyncSend(). I used these names because 
the PT uses them.
IMO the naming of the PT should be used:
- they are known, because all already using the PT 
- these methods dont just specify the style, they do more: sending, recieving, 
result transformation
What about
- having methods asyncStyle(), syncStyle(), inOnly(), inOut() for just storing 
the async/sync invocation and the MEP and
- having a final submit() method doing the sending, recieving + result 
transformation?
                
> Create a Fluent ProducerTemplate
> --------------------------------
>
>                 Key: CAMEL-6648
>                 URL: https://issues.apache.org/jira/browse/CAMEL-6648
>             Project: Camel
>          Issue Type: New Feature
>          Components: camel-core
>            Reporter: Raul Kripalani
>            Assignee: Raul Kripalani
>         Attachments: ProducerTemplateBuilder.java, 
> ProducerTemplateBuilderTest.java
>
>
> Create a Fluent ProducerTemplate so that users can use it in the following 
> manner:
> \\
> \\
> {code}
> // initialize ProducerTemplate with a default endpoint
> FluentProducerTemplate template = new 
> FluentProducerTemplate("activemq:queue:foo"); 
> MyResponse response = 
>     template.newExchange().toDefaultEndpoint()
>             .withBody("this is slick")
>             .withHeader("MyHeader1", "HeaderValue")
>             .withHeader("MyHeader2", "HeaderValue2")
>             .resultAs(MyResponse.class)
>             .dispatchInOut();                 // or inOnly(), asyncInOut()
> {code}
>  

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to