You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by AlanFoster <al...@alanfoster.me> on 2012/09/07 22:43:45 UTC

Change Sql Component BLOB datatype to XML for Aggregator serialization

Hi All

I am currently using camel's sql-component in order to define a
aggregationRepositoryRef for the aggregator component.

The aggregator currently stores all of the information in the Aggregator
table as a BLOB. Is there a way to change this?

The documentation here
http://camel.apache.org/sql-component.html#SQLComponent-Codec%28Serialization%29
says "Since they can contain any type of payload, Exchanges are not
serializable by design. It is converted into a byte array to be stored in a
database BLOB field."

As I know my aggregator's payloads will always be XML I wonder if there is
anyway to store the information in the database as XML rather than an
unreadable BLOB?

Could anyone shed some light on whether or not this is possible please? :)

Thanks
Alan



--
View this message in context: http://camel.465427.n5.nabble.com/Change-Sql-Component-BLOB-datatype-to-XML-for-Aggregator-serialization-tp5718845.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Change Sql Component BLOB datatype to XML for Aggregator serialization

Posted by AlanFoster <al...@alanfoster.me>.
Thanks Christian for the links. This will be my 6th patch now however! :)

The link for the patch is here :
https://issues.apache.org/jira/browse/CAMEL-5643

And the relevant Camel Development post:
http://camel.465427.n5.nabble.com/Patch-CAMEL-5643-Allow-users-to-store-body-and-arbitrary-headers-as-text-within-a-datasource-td5719810.html

I'd appreciate any feedback you wish to give
Alan



--
View this message in context: http://camel.465427.n5.nabble.com/Change-Sql-Component-BLOB-datatype-to-XML-for-Aggregator-serialization-tp5718845p5719811.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Change Sql Component BLOB datatype to XML for Aggregator serialization

Posted by Christian Müller <ch...@gmail.com>.
Hello Alan!

Yes, this would be great! As you may know, we love contributions.
[1] and [2] will be helpful for you how to contribute to Apache Camel.

[1] http://camel.apache.org/contributing.html
[2] http://camel.apache.org/building.html

Looking forward for your first contribution,
Christian


On Sun, Sep 9, 2012 at 11:29 AM, AlanFoster <al...@alanfoster.me> wrote:

> @Claus I think adding such an option to the existing JDBC
> AggregationRepository would be a good idea too. Particularly as the current
> JDBC AggregationRepository code is not very friendly for
> extending/encapsulating - as everything useful is marked final or private.
>
> I shall work on an implementation similar to what you suggest for my own
> custom AggregationRepository solution, and then raise a jira ticket and
> offer a patch if it turns out to be useful
>
> Alan
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Change-Sql-Component-BLOB-datatype-to-XML-for-Aggregator-serialization-tp5718845p5718946.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



--

Re: Change Sql Component BLOB datatype to XML for Aggregator serialization

Posted by AlanFoster <al...@alanfoster.me>.
@Claus I think adding such an option to the existing JDBC
AggregationRepository would be a good idea too. Particularly as the current
JDBC AggregationRepository code is not very friendly for
extending/encapsulating - as everything useful is marked final or private.

I shall work on an implementation similar to what you suggest for my own
custom AggregationRepository solution, and then raise a jira ticket and
offer a patch if it turns out to be useful

Alan



--
View this message in context: http://camel.465427.n5.nabble.com/Change-Sql-Component-BLOB-datatype-to-XML-for-Aggregator-serialization-tp5718845p5718946.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Change Sql Component BLOB datatype to XML for Aggregator serialization

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

I think this is a good idea. When you store data in a RDBMS you may
want to use SQL types that is readable by humans, such as VARCHAR2 (or
what they are called today).

So maybe have some way to make this easier to say if header/body
should be binary or text based.

Yes you can create your own AggregationRepository or extend the
existing. But maybe if it was possible to add an option on the JDBC
AggregationRepository to control if its binary or text, that would be
nice.



On Sat, Sep 8, 2012 at 12:07 PM, AlanFoster <al...@alanfoster.me> wrote:
> Thanks for your Response Christian
>
> I wonder if there's a nice way to keep all of the functionality of the
> current Jdbc aggregator that the sql-component offers, but just change the
> way it marshalls the data? Through blueprint property setters
>
> I looked into the source code for this area, and I noticed the main point of
> marshalling/unmarshalling the exchange is done with the codec :
> private JdbcCamelCodec codec = new JdbcCamelCodec();
>
> This would be the only thing that needs to be changed right? But the class
> type is final so it can't be extended and the JdbcAggregationRepository
> class has no getters/setters for the codeec field so it can't be changed at
> all through blueprint configuration =[
>
> Can you recommend the expected way to change this sort of functionality
> without creating my own new aggregation repository from scratch please?
>
> Thanks again for the help
> Alan
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Change-Sql-Component-BLOB-datatype-to-XML-for-Aggregator-serialization-tp5718845p5718896.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: Change Sql Component BLOB datatype to XML for Aggregator serialization

Posted by AlanFoster <al...@alanfoster.me>.
Thanks for your Response Christian

I wonder if there's a nice way to keep all of the functionality of the
current Jdbc aggregator that the sql-component offers, but just change the
way it marshalls the data? Through blueprint property setters

I looked into the source code for this area, and I noticed the main point of
marshalling/unmarshalling the exchange is done with the codec :
private JdbcCamelCodec codec = new JdbcCamelCodec();

This would be the only thing that needs to be changed right? But the class
type is final so it can't be extended and the JdbcAggregationRepository
class has no getters/setters for the codeec field so it can't be changed at
all through blueprint configuration =[ 

Can you recommend the expected way to change this sort of functionality
without creating my own new aggregation repository from scratch please?

Thanks again for the help
Alan



--
View this message in context: http://camel.465427.n5.nabble.com/Change-Sql-Component-BLOB-datatype-to-XML-for-Aggregator-serialization-tp5718845p5718896.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Change Sql Component BLOB datatype to XML for Aggregator serialization

Posted by Christian Müller <ch...@gmail.com>.
The AggregationRepository do not only store the in message (your xml
payload). It also stores the exchange properties and message headers.
That's the reason why...
If this doesn't fit your needs, you can implement your own
AggregationRepository by implementing
org.apache.camel.spi.AggregationRepository.

Best,
Christian

On Fri, Sep 7, 2012 at 10:43 PM, AlanFoster <al...@alanfoster.me> wrote:

> Hi All
>
> I am currently using camel's sql-component in order to define a
> aggregationRepositoryRef for the aggregator component.
>
> The aggregator currently stores all of the information in the Aggregator
> table as a BLOB. Is there a way to change this?
>
> The documentation here
>
> http://camel.apache.org/sql-component.html#SQLComponent-Codec%28Serialization%29
> says "Since they can contain any type of payload, Exchanges are not
> serializable by design. It is converted into a byte array to be stored in a
> database BLOB field."
>
> As I know my aggregator's payloads will always be XML I wonder if there is
> anyway to store the information in the database as XML rather than an
> unreadable BLOB?
>
> Could anyone shed some light on whether or not this is possible please? :)
>
> Thanks
> Alan
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Change-Sql-Component-BLOB-datatype-to-XML-for-Aggregator-serialization-tp5718845.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



--