You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Claus Ibsen (Created) (JIRA)" <ji...@apache.org> on 2011/12/19 14:19:30 UTC

[jira] [Created] (CAMEL-4797) DataFormat - unmarshal should allow to return Message or Exchange to make it more flexible

DataFormat - unmarshal should allow to return Message or Exchange to make it more flexible
------------------------------------------------------------------------------------------

                 Key: CAMEL-4797
                 URL: https://issues.apache.org/jira/browse/CAMEL-4797
             Project: Camel
          Issue Type: Improvement
          Components: camel-core
            Reporter: Claus Ibsen
             Fix For: 2.10


The API of the unmarshal on DataFormat is
{code}
    Object unmarshal(Exchange exchange, InputStream stream) throws Exception;
{code}

The Object returned is by default the message body. But we should allow end user to return also a
- org.apache.camel.Message
- org.apache.camel.Exchange

If its a Message then use the message returned.
If its a Exchange then copy the results from the exchange to the current exchange (normally it would be the same instance, so its a noop operation)

We supports this for the splitter, where people can return a List<Message> in the split expression etc.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (CAMEL-4797) DataFormat - unmarshal should allow to return Message or Exchange to make it more flexible

Posted by "Claus Ibsen (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CAMEL-4797?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13221832#comment-13221832 ] 

Claus Ibsen commented on CAMEL-4797:
------------------------------------

Yes you overlooked something. People implementing a data format want to be able to transform both body *and* headers. Currently they can only transform bodies. And they want this in a single data format. Not having people to use both a data format and then afterwards have to use some other means of setting headers.
                
> DataFormat - unmarshal should allow to return Message or Exchange to make it more flexible
> ------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-4797
>                 URL: https://issues.apache.org/jira/browse/CAMEL-4797
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-core
>            Reporter: Claus Ibsen
>             Fix For: 2.10.0
>
>
> The API of the unmarshal on DataFormat is
> {code}
>     Object unmarshal(Exchange exchange, InputStream stream) throws Exception;
> {code}
> The Object returned is by default the message body. But we should allow end user to return also a
> - org.apache.camel.Message
> - org.apache.camel.Exchange
> If its a Message then use the message returned.
> If its a Exchange then copy the results from the exchange to the current exchange (normally it would be the same instance, so its a noop operation)
> We supports this for the splitter, where people can return a List<Message> in the split expression etc.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Assigned] (CAMEL-4797) DataFormat - unmarshal should allow to return Message or Exchange to make it more flexible

Posted by "Babak Vahdat (Assigned) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CAMEL-4797?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Babak Vahdat reassigned CAMEL-4797:
-----------------------------------

    Assignee: Babak Vahdat
    
> DataFormat - unmarshal should allow to return Message or Exchange to make it more flexible
> ------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-4797
>                 URL: https://issues.apache.org/jira/browse/CAMEL-4797
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-core
>            Reporter: Claus Ibsen
>            Assignee: Babak Vahdat
>             Fix For: 2.10.0
>
>
> The API of the unmarshal on DataFormat is
> {code}
>     Object unmarshal(Exchange exchange, InputStream stream) throws Exception;
> {code}
> The Object returned is by default the message body. But we should allow end user to return also a
> - org.apache.camel.Message
> - org.apache.camel.Exchange
> If its a Message then use the message returned.
> If its a Exchange then copy the results from the exchange to the current exchange (normally it would be the same instance, so its a noop operation)
> We supports this for the splitter, where people can return a List<Message> in the split expression etc.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Resolved] (CAMEL-4797) DataFormat - unmarshal should allow to return Message or Exchange to make it more flexible

Posted by "Babak Vahdat (Resolved) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CAMEL-4797?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Babak Vahdat resolved CAMEL-4797.
---------------------------------

    Resolution: Fixed
    
> DataFormat - unmarshal should allow to return Message or Exchange to make it more flexible
> ------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-4797
>                 URL: https://issues.apache.org/jira/browse/CAMEL-4797
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-core
>            Reporter: Claus Ibsen
>            Assignee: Babak Vahdat
>             Fix For: 2.10.0
>
>
> The API of the unmarshal on DataFormat is
> {code}
>     Object unmarshal(Exchange exchange, InputStream stream) throws Exception;
> {code}
> The Object returned is by default the message body. But we should allow end user to return also a
> - org.apache.camel.Message
> - org.apache.camel.Exchange
> If its a Message then use the message returned.
> If its a Exchange then copy the results from the exchange to the current exchange (normally it would be the same instance, so its a noop operation)
> We supports this for the splitter, where people can return a List<Message> in the split expression etc.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (CAMEL-4797) DataFormat - unmarshal should allow to return Message or Exchange to make it more flexible

Posted by "Babak Vahdat (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CAMEL-4797?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13221831#comment-13221831 ] 

Babak Vahdat commented on CAMEL-4797:
-------------------------------------

O.K now I've got the intention of this ticket but wouldn't we then provide *too* much of flexibility? IMHO each piece of the Lego has been provided for a specific role to be taken over in order to build up a nice Lego car and people should better not start swapping pieces with each other. So if they want to do CRUD on headers, attachments, etc. then they should better stick to the corresponding DSL elements provided specifically for that purpose *after* unmarshal.

Do I overlook something?
                
> DataFormat - unmarshal should allow to return Message or Exchange to make it more flexible
> ------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-4797
>                 URL: https://issues.apache.org/jira/browse/CAMEL-4797
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-core
>            Reporter: Claus Ibsen
>             Fix For: 2.10.0
>
>
> The API of the unmarshal on DataFormat is
> {code}
>     Object unmarshal(Exchange exchange, InputStream stream) throws Exception;
> {code}
> The Object returned is by default the message body. But we should allow end user to return also a
> - org.apache.camel.Message
> - org.apache.camel.Exchange
> If its a Message then use the message returned.
> If its a Exchange then copy the results from the exchange to the current exchange (normally it would be the same instance, so its a noop operation)
> We supports this for the splitter, where people can return a List<Message> in the split expression etc.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (CAMEL-4797) DataFormat - unmarshal should allow to return Message or Exchange to make it more flexible

Posted by "Claus Ibsen (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CAMEL-4797?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13221833#comment-13221833 ] 

Claus Ibsen commented on CAMEL-4797:
------------------------------------

Well currently they can kinda do this a bit as they get the exchange in the unmarshal method. So they can set the headers directory on the exchange, and then return the body to use. But this is a bit counter intuitive. It would be easier if they could either just adjust the exchange as they want, and return the exchange. Or return a Message object, where they can transform both the body and headers.


                
> DataFormat - unmarshal should allow to return Message or Exchange to make it more flexible
> ------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-4797
>                 URL: https://issues.apache.org/jira/browse/CAMEL-4797
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-core
>            Reporter: Claus Ibsen
>            Assignee: Babak Vahdat
>             Fix For: 2.10.0
>
>
> The API of the unmarshal on DataFormat is
> {code}
>     Object unmarshal(Exchange exchange, InputStream stream) throws Exception;
> {code}
> The Object returned is by default the message body. But we should allow end user to return also a
> - org.apache.camel.Message
> - org.apache.camel.Exchange
> If its a Message then use the message returned.
> If its a Exchange then copy the results from the exchange to the current exchange (normally it would be the same instance, so its a noop operation)
> We supports this for the splitter, where people can return a List<Message> in the split expression etc.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Issue Comment Edited] (CAMEL-4797) DataFormat - unmarshal should allow to return Message or Exchange to make it more flexible

Posted by "Babak Vahdat (Issue Comment Edited) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CAMEL-4797?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13221651#comment-13221651 ] 

Babak Vahdat edited comment on CAMEL-4797 at 3/3/12 5:40 PM:
-------------------------------------------------------------

As I'm not really sure if I understand it correctly, is the following what we intend by UnmarshalProcessor:

{code}
            Object result = dataFormat.unmarshal(exchange, stream);
            if (result instanceof Exchange) {
                Exchange anotherExchange = (Exchange) result;
                if (exchange == anotherExchange) {
                    // only check to see if the body of the out message has been properly set
                    Message message = exchange.getOut();
                    ObjectHelper.notNull(message.getBody(), "body", message);
                } else {
                    // copy the out message along with it's possibly set headers, attachments, etc.
                    exchange.setOut(anotherExchange.getOut().copy());
                }
            } else if (result instanceof Message) {
                Message message = (Message) result;
                ObjectHelper.notNull(message.getBody(), "body", message);
                exchange.setOut((Message) result);
            } else {
                out.setBody(result);
            }
{code}

Or am I completely with wrong thoughts by this ticket?
                
      was (Author: bvahdat):
    As I'm not really sure if I understand it correctly, is the following what we intend by UnmarshalProcessor:

{code}
            Object result = dataFormat.unmarshal(exchange, stream);
            if (result instanceof Exchange) {
                Exchange anotherExchange = (Exchange) result;
                if (exchange == anotherExchange) {
                    // only check to see if the body of the out message has been properly set
                    Message message = exchange.getOut();
                    ObjectHelper.notNull(message.getBody(), "body", message);
                } else {
                    // copy the out message along with it's possibly set headers, attachments, etc.
                    exchange.setOut(anotherExchange.getOut().copy());
                }
            } else if (result instanceof Message) {
                Message message = exchange.getOut();
                ObjectHelper.notNull(message.getBody(), "body", message);
                exchange.setOut((Message) result);
            } else {
                out.setBody(result);
            }
{code}

Or am I completely with wrong thoughts by this ticket?
                  
> DataFormat - unmarshal should allow to return Message or Exchange to make it more flexible
> ------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-4797
>                 URL: https://issues.apache.org/jira/browse/CAMEL-4797
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-core
>            Reporter: Claus Ibsen
>             Fix For: 2.10.0
>
>
> The API of the unmarshal on DataFormat is
> {code}
>     Object unmarshal(Exchange exchange, InputStream stream) throws Exception;
> {code}
> The Object returned is by default the message body. But we should allow end user to return also a
> - org.apache.camel.Message
> - org.apache.camel.Exchange
> If its a Message then use the message returned.
> If its a Exchange then copy the results from the exchange to the current exchange (normally it would be the same instance, so its a noop operation)
> We supports this for the splitter, where people can return a List<Message> in the split expression etc.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (CAMEL-4797) DataFormat - unmarshal should allow to return Message or Exchange to make it more flexible

Posted by "Claus Ibsen (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CAMEL-4797?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13172256#comment-13172256 ] 

Claus Ibsen commented on CAMEL-4797:
------------------------------------

People may want to return a Message or Exchange, if they want to unmarshal + add headers etc. Currently this is not possible.
                
> DataFormat - unmarshal should allow to return Message or Exchange to make it more flexible
> ------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-4797
>                 URL: https://issues.apache.org/jira/browse/CAMEL-4797
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-core
>            Reporter: Claus Ibsen
>             Fix For: 2.10
>
>
> The API of the unmarshal on DataFormat is
> {code}
>     Object unmarshal(Exchange exchange, InputStream stream) throws Exception;
> {code}
> The Object returned is by default the message body. But we should allow end user to return also a
> - org.apache.camel.Message
> - org.apache.camel.Exchange
> If its a Message then use the message returned.
> If its a Exchange then copy the results from the exchange to the current exchange (normally it would be the same instance, so its a noop operation)
> We supports this for the splitter, where people can return a List<Message> in the split expression etc.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (CAMEL-4797) DataFormat - unmarshal should allow to return Message or Exchange to make it more flexible

Posted by "Claus Ibsen (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CAMEL-4797?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13221819#comment-13221819 ] 

Claus Ibsen commented on CAMEL-4797:
------------------------------------

Yeah almost. I think we should not allow returning another Exchange instance, the *same* Exchange instance should always be used during routing. So if its not the same instance then throw an exception. Also when an exchange is returned, then you should not change anything at all.

                
> DataFormat - unmarshal should allow to return Message or Exchange to make it more flexible
> ------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-4797
>                 URL: https://issues.apache.org/jira/browse/CAMEL-4797
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-core
>            Reporter: Claus Ibsen
>             Fix For: 2.10.0
>
>
> The API of the unmarshal on DataFormat is
> {code}
>     Object unmarshal(Exchange exchange, InputStream stream) throws Exception;
> {code}
> The Object returned is by default the message body. But we should allow end user to return also a
> - org.apache.camel.Message
> - org.apache.camel.Exchange
> If its a Message then use the message returned.
> If its a Exchange then copy the results from the exchange to the current exchange (normally it would be the same instance, so its a noop operation)
> We supports this for the splitter, where people can return a List<Message> in the split expression etc.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (CAMEL-4797) DataFormat - unmarshal should allow to return Message or Exchange to make it more flexible

Posted by "Babak Vahdat (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CAMEL-4797?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13221834#comment-13221834 ] 

Babak Vahdat commented on CAMEL-4797:
-------------------------------------

O.K. if you're aware of people asking for/depending on this piece of Lego then just let's provide them this :-)
                
> DataFormat - unmarshal should allow to return Message or Exchange to make it more flexible
> ------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-4797
>                 URL: https://issues.apache.org/jira/browse/CAMEL-4797
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-core
>            Reporter: Claus Ibsen
>            Assignee: Babak Vahdat
>             Fix For: 2.10.0
>
>
> The API of the unmarshal on DataFormat is
> {code}
>     Object unmarshal(Exchange exchange, InputStream stream) throws Exception;
> {code}
> The Object returned is by default the message body. But we should allow end user to return also a
> - org.apache.camel.Message
> - org.apache.camel.Exchange
> If its a Message then use the message returned.
> If its a Exchange then copy the results from the exchange to the current exchange (normally it would be the same instance, so its a noop operation)
> We supports this for the splitter, where people can return a List<Message> in the split expression etc.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (CAMEL-4797) DataFormat - unmarshal should allow to return Message or Exchange to make it more flexible

Posted by "Babak Vahdat (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CAMEL-4797?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13221651#comment-13221651 ] 

Babak Vahdat commented on CAMEL-4797:
-------------------------------------

As I'm not really sure if I understand it correctly, is the following what we intend by UnmarshalProcessor:

{code}
            Object result = dataFormat.unmarshal(exchange, stream);
            if (result instanceof Exchange) {
                Exchange anotherExchange = (Exchange) result;
                if (exchange == anotherExchange) {
                    // only check to see if the body of the out message has been properly set
                    Message message = exchange.getOut();
                    ObjectHelper.notNull(message.getBody(), "body", message);
                } else {
                    // copy the out message along with it's possibly set headers, attachments, etc.
                    exchange.setOut(anotherExchange.getOut().copy());
                }
            } else if (result instanceof Message) {
                Message message = exchange.getOut();
                ObjectHelper.notNull(message.getBody(), "body", message);
                exchange.setOut((Message) result);
            } else {
                out.setBody(result);
            }
{code}

Or am I completely with wrong thoughts by this ticket?
                
> DataFormat - unmarshal should allow to return Message or Exchange to make it more flexible
> ------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-4797
>                 URL: https://issues.apache.org/jira/browse/CAMEL-4797
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-core
>            Reporter: Claus Ibsen
>             Fix For: 2.10.0
>
>
> The API of the unmarshal on DataFormat is
> {code}
>     Object unmarshal(Exchange exchange, InputStream stream) throws Exception;
> {code}
> The Object returned is by default the message body. But we should allow end user to return also a
> - org.apache.camel.Message
> - org.apache.camel.Exchange
> If its a Message then use the message returned.
> If its a Exchange then copy the results from the exchange to the current exchange (normally it would be the same instance, so its a noop operation)
> We supports this for the splitter, where people can return a List<Message> in the split expression etc.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira