This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push: new 148e7fc CAMEL-16861: Cleanup and update EIP docs 148e7fc is described below commit 148e7fc48ee05b3317bf7d1d44e5e4d6dfe29abe Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Wed Sep 29 12:16:20 2021 +0200 CAMEL-16861: Cleanup and update EIP docs --- .../main/docs/modules/eips/pages/marshal-eip.adoc | 62 ++++++++++++---------- .../docs/modules/eips/pages/unmarshal-eip.adoc | 56 ++++++++++--------- 2 files changed, 63 insertions(+), 55 deletions(-) diff --git a/core/camel-core-engine/src/main/docs/modules/eips/pages/marshal-eip.adoc b/core/camel-core-engine/src/main/docs/modules/eips/pages/marshal-eip.adoc index 7a26e4c..901378e 100644 --- a/core/camel-core-engine/src/main/docs/modules/eips/pages/marshal-eip.adoc +++ b/core/camel-core-engine/src/main/docs/modules/eips/pages/marshal-eip.adoc @@ -1,43 +1,47 @@ = Marshal EIP -Marshalling is the opposite of unmarshalling, where a bean is marshalled into some binary or textual format for transmission over some transport via a Camel xref:components::index.adoc[Components]. Marshalling is used in the same way as unmarshalling above; in the xref:latest@manual:ROOT:dsl.adoc[DSL] you can use a DataFormat instance, you can configure the DataFormat dynamically using the DSL or you can refer to a named instance of the format in the xref:latest@manual:ROOT:registry.adoc [...] +The xref:marshal-eip.adoc[Marshal] and xref:unmarshal-eip.adoc[Unmarshal] EIPs are used +for xref:message-translator.adoc[Message Transformation]. -== Options +Camel has support for message transformation using several techniques. +One such technique is xref:components:dataformats:index.adoc[Data Formats], +where marshal and unmarshal comes from. -// eip options: START -The Marshal EIP supports 1 options which are listed below: +So in other words the xref:marshal-eip.adoc[Marshal] and xref:unmarshal-eip.adoc[Unmarshal] EIPs +are used with xref:components:dataformats:index.adoc[Data Formats]. -[width="100%",cols="2,5,^1,2",options="header"] -|=== -| Name | Description | Default | Type -| *dataFormatType* | *Required* The data format to be used | | DataFormatDefinition -|=== -// eip options: END +- _Marshal_ - Transforms the message body (such as Java object) into a binary or textual format, ready to be wired over the network. +- _Unmarshal_ - Transforms data in some binary or textual format (such as received over the network) +into a Java object; or some other representation according to the data format being used. -== Samples +== Example -The following example unmarshals via serialization then marshals using a named JAXB data format to perform a kind of xref:message-translator.adoc[Message Translator]. +The following example reads XML files from the inbox/xml directory. +Each file is then transformed into Java Objects using xref:dataformats:jaxb-dataformat.adoc[JAXB]. +Then a xref:components::bean-component.adoc[Bean] is invoked that takes in the Java object. + +Then the reverse operation happens to transform the Java objects back into XML also via JAXB, +but using the `unmarshal` operation. And finally the message is routed to a xref:components::jms-component.adoc[JMS] queue. [source,java] ---- -from("file://foo/bar"). - unmarshal().serialization(). - marshal("jaxb"). - to("activemq:Some.Queue"); +from("file:inbox/xml") + .marshal().jaxb() + .to("bean:validateOrder") + .unmarshal().jaxb() + .to("jms:queue:order"); ---- -[[DataFormat-UsingSpringXML]] -=== Using Spring XML - -This example shows how to configure the data type just once and reuse it -on multiple routes - -You can also define reusable data formats as Spring beans +And in XML: [source,xml] --------------------------------------------------------- -<bean id="myJaxb" class="org.apache.camel.model.dataformat.JaxbDataFormat"> - <property name="prettyPrint" value="true"/> - <property name="contextPath" value="org.apache.camel.example"/> -</bean> --------------------------------------------------------- +---- +<route> + <from uri="file:inbox/xml"/> + <marshal><jaxb/></marshal> + <to uri="bean:validateOrder"/> + <unmarshal><jaxb/></unmarshal> + <to uri="jms:queue:order"/> +</route> +---- + diff --git a/core/camel-core-engine/src/main/docs/modules/eips/pages/unmarshal-eip.adoc b/core/camel-core-engine/src/main/docs/modules/eips/pages/unmarshal-eip.adoc index 7930ce3..f3d397e 100644 --- a/core/camel-core-engine/src/main/docs/modules/eips/pages/unmarshal-eip.adoc +++ b/core/camel-core-engine/src/main/docs/modules/eips/pages/unmarshal-eip.adoc @@ -1,43 +1,47 @@ = Unmarshal EIP -If you receive a message from one of the Camel xref:components::index.adoc[Components] such as xref:components::file-component.adoc[File], xref:components::http-component.adoc[HTTP] or xref:components::jms-component.adoc[JMS] you often want to unmarshal the payload into some bean so that you can process it using some xref:latest@manual:ROOT:bean-integration.adoc[Bean Integration] or perform xref:latest@manual:ROOT:predicate.adoc[Predicate] evaluation and so forth. +The xref:marshal-eip.adoc[Marshal] and xref:unmarshal-eip.adoc[Unmarshal] EIPs are used +for xref:message-translator.adoc[Message Transformation]. +Camel has support for message transformation using several techniques. +One such technique is xref:components:dataformats:index.adoc[Data Formats], +where marshal and unmarshal comes from. -== Options +So in other words the xref:marshal-eip.adoc[Marshal] and xref:unmarshal-eip.adoc[Unmarshal] EIPs +are used with xref:components:dataformats:index.adoc[Data Formats]. -// eip options: START -The Unmarshal EIP supports 1 options which are listed below: +- _Marshal_ - Transforms the message body (such as Java object) into a binary or textual format, ready to be wired over the network. +- _Unmarshal_ - Transforms data in some binary or textual format (such as received over the network) +into a Java object; or some other representation according to the data format being used. -[width="100%",cols="2,5,^1,2",options="header"] -|=== -| Name | Description | Default | Type -| *dataFormatType* | *Required* The data format to be used | | DataFormatDefinition -|=== -// eip options: END +== Example -== Samples +The following example reads XML files from the inbox/xml directory. +Each file is then transformed into Java Objects using xref:dataformats:jaxb-dataformat.adoc[JAXB]. +Then a xref:components::bean-component.adoc[Bean] is invoked that takes in the Java object. -For example +Then the reverse operation happens to transform the Java objects back into XML also via JAXB, +but using the `unmarshal` operation. And finally the message is routed to a xref:components::jms-component.adoc[JMS] queue. [source,java] ---- -DataFormat jaxb = new JaxbDataFormat("com.acme.model"); - -from("activemq:My.Queue"). - unmarshal(jaxb). - to("mqseries:Another.Queue"); +from("file:inbox/xml") + .marshal().jaxb() + .to("bean:validateOrder") + .unmarshal().jaxb() + .to("jms:queue:order"); ---- -The above uses a named DataFormat of _jaxb_ which is configured with a number of Java package names. You can if you prefer use a named reference to a data format which can then be defined in your xref:latest@manual:ROOT:registry.adoc[Registry] such as via your xref:components::spring-summary.adoc[Spring] XML file. - -You can also use the DSL itself to define the data format as you use it. -For example the following uses Java serialization to unmarshal a binary -file then send it as an ObjectMessage to xref:components::activemq-component.adoc[ActiveMQ] +And in XML: -[source,java] +[source,xml] ---- -from("file://foo/bar"). - unmarshal().serialization(). - to("activemq:Some.Queue"); +<route> + <from uri="file:inbox/xml"/> + <marshal><jaxb/></marshal> + <to uri="bean:validateOrder"/> + <unmarshal><jaxb/></unmarshal> + <to uri="jms:queue:order"/> +</route> ----