You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by Arin <ar...@gmail.com> on 2009/05/27 18:03:17 UTC

How to set from id and subject of an email in camel-context.com

Instead of sending from email id and subject by sendBodyAndHeaders argument,
I want to set it in the camel-context.xml. Can anyone suggest me how I can
proceed with that...
-- 
View this message in context: http://www.nabble.com/How-to-set-from-id-and-subject-of-an-email-in-camel-context.com-tp23745547p23745547.html
Sent from the Camel Development mailing list archive at Nabble.com.


Re: How to set from id and subject of an email in camel-context.com

Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, May 27, 2009 at 6:03 PM, Arin <ar...@gmail.com> wrote:
>
> Instead of sending from email id and subject by sendBodyAndHeaders argument,
> I want to set it in the camel-context.xml. Can anyone suggest me how I can
> proceed with that...

These values can be set as a header and there is a <setHeader> XML tag

Something like this:
<setHeader name="subject"><constant>Hello World</constant></setHeader>

And if you need to set multiple values just add another setHeader below.


> --
> View this message in context: http://www.nabble.com/How-to-set-from-id-and-subject-of-an-email-in-camel-context.com-tp23745547p23745547.html
> Sent from the Camel Development mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: How to set from id and subject of an email in camel-context.com

Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, May 28, 2009 at 2:34 PM, Arin <ar...@gmail.com> wrote:
>
> Can anyone suggest me how I can get the constant text from properties file:
>
> <camel:setHeader
> headerName="from"><camel:constant>admin@irise.com</camel:constant></camel:setHeader>
>
> I want to set the mail address from properties file and not want to hard
> code here. Please suggest me.
Hi

You cannot do this easily out of the box with a simple XML tag.

Spring property placeholder is limited in Spring 2.x.
http://camel.apache.org/how-do-i-use-spring-property-placeholder-with-camel-xml.html

I have created a ticket to track a new feature in Camel that allows
you to more easily use properties file
and access it from the Spring XML DSL
https://issues.apache.org/activemq/browse/CAMEL-1656


You can use Spring to define a bean it as the java.util.Properties
holding the values.
There should be some spring docu how to do this in Spring XML as a spring bean.

Then you can define a POJO class and have a setter for the properties
and add a method to return the value

public class MyFoo {
  private Properties ...
  void setProperties(Properties .. )

  public String getEmail() {
    return properties.get("email");
  }
}


<bean id="foo" class="com.mycompany.MyFoo">
  <property name="properties" ref="spring bean id with properties"/>
</bean>

And then you can use the simple language to invoke this bean and set the header

<simple>${bean:foo?method=getEmail}</simple>


But you can also just use a Processor where you have access to the
org.apache.camel.Exchange where you from Java code can set the header.


You can maybe also use some of the scripting languages to invoke
spring bean and access the properties
http://camel.apache.org/languages.html





>
>
>
> --
> View this message in context: http://www.nabble.com/How-to-set-from-id-and-subject-of-an-email-in-camel-context.com-tp23745547p23760832.html
> Sent from the Camel Development mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: How to set from id and subject of an email in camel-context.com

Posted by Arin <ar...@gmail.com>.
Can anyone suggest me how I can get the constant text from properties file:

<camel:setHeader
headerName="from"><camel:constant>admin@irise.com</camel:constant></camel:setHeader>

I want to set the mail address from properties file and not want to hard
code here. Please suggest me.



-- 
View this message in context: http://www.nabble.com/How-to-set-from-id-and-subject-of-an-email-in-camel-context.com-tp23745547p23760832.html
Sent from the Camel Development mailing list archive at Nabble.com.


Re: How to set from id and subject of an email in camel-context.com

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

You can check the XML reference page to find the Camel version and the
XSD and thus which XML tags
you can use:
http://camel.apache.org/xml-reference.html

The attribute for the name is: headerName
So it should be

        <camel:setHeader headerName="subject"><constant>Hello
World</constant></camel:setHeader>



On Wed, May 27, 2009 at 6:18 PM, Arin <ar...@gmail.com> wrote:
>
> Please see below configuration, I am getting error  Invalid content was found
> starting with element 'camel:setHeader'. Can anyone correct me as where I
> should <camel:setHeader>
>
> <camel:camelContext id="camel">
>        <camel:template id="camelTemplate"/>
>        <camel:endpoint id="invitationQueue" uri="${queue.invitation}"/>
>        <camel:endpoint id="resetPasswordQueue"
> uri="${queue.resetPassword}"/>
>        <camel:endpoint id="mailServer" uri="${mail.host}"/>
>
>        <camel:setHeader name="subject"><constant>Hello
> World</constant></camel:setHeader>
>
>        <camel:endpoint id="invitationVelocity"
> uri="velocity:com/irise/dc/invitation/data/invitation.vm"/>
>
>        <camel:route>
>            <!-- Route to send invitation -->
>            <camel:from ref="invitationQueue"/>
>            <camel:to ref="invitationVelocity"/>
>            <camel:to ref="mailServer"/>
>        </camel:route>
>
>
>
>    </camel:camelContext>
>
>    <alias alias="producerTemplate" name="camelTemplate"/>
> --
> View this message in context: http://www.nabble.com/How-to-set-from-id-and-subject-of-an-email-in-camel-context.com-tp23745547p23745843.html
> Sent from the Camel Development mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: How to set from id and subject of an email in camel-context.com

Posted by Arin <ar...@gmail.com>.
Please see below configuration, I am getting error  Invalid content was found
starting with element 'camel:setHeader'. Can anyone correct me as where I
should <camel:setHeader>

<camel:camelContext id="camel">
        <camel:template id="camelTemplate"/>
        <camel:endpoint id="invitationQueue" uri="${queue.invitation}"/>
        <camel:endpoint id="resetPasswordQueue"
uri="${queue.resetPassword}"/>
        <camel:endpoint id="mailServer" uri="${mail.host}"/>

        <camel:setHeader name="subject"><constant>Hello
World</constant></camel:setHeader>

        <camel:endpoint id="invitationVelocity"
uri="velocity:com/irise/dc/invitation/data/invitation.vm"/>
        
        <camel:route>
            <!-- Route to send invitation -->
            <camel:from ref="invitationQueue"/>
            <camel:to ref="invitationVelocity"/>
            <camel:to ref="mailServer"/>
        </camel:route>

        

    </camel:camelContext>

    <alias alias="producerTemplate" name="camelTemplate"/>
-- 
View this message in context: http://www.nabble.com/How-to-set-from-id-and-subject-of-an-email-in-camel-context.com-tp23745547p23745843.html
Sent from the Camel Development mailing list archive at Nabble.com.