You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by harpritt <ha...@hotmail.com> on 2008/10/20 22:40:01 UTC

JMS to File to email to JMS

Hi

Appologies if i make noob comments, alas that is what i am.

Ive been tasked with conecting our remote locations with only email access
to our local jms queues.

I have one main requirement, the messages must arrive locally in the order
that they were added to the remote JMS queue.

this is what i think i can do 

JMS queue -> File Directory ---> picked up by an external email app and sent
to my local pop account --> Local JMS queue.

Do you guys see any problems with this? will camel know how to re-order the
messages in the local queue?
I really dont think it can unless i write some custom code.

ill be using the XML configuration because its a lot easier to document and
maintain.

Ive done lots of looking but cant seem to find the answer, but i have a
feeling that i will have to write my own file endpoint

as allways all help is appreciated.

Many Thanks


-- 
View this message in context: http://www.nabble.com/JMS-to-File-to-email-to-JMS-tp20078296s22882p20078296.html
Sent from the Camel - Users mailing list archive at Nabble.com.


RE: JMS to File to email to JMS

Posted by harpritt <ha...@hotmail.com>.
Thats flipping fantastic!

Thank you. 

Im having to learn spring, activeMQ and camel in one hit and your example
has really shed some light on the whole task.

Yep, the external app packages up all the files in a directory then sends
them via a satelite to a local mail server, where they are unpacked and sent
as individual emails (1 per file) to a given mail address.

I still cant get my head around how powerful camel is...  

Cheers again

Harpritt


Claus Ibsen wrote:
> 
> Hi
> 
> Just to get the fact straight: You *must* use files, since there is an
> external app relying on this?
> 
> The key is to store the files in the correct order, so the external app
> can read the files in correct order as well. So the file name can express
> this order.
> 
> If for instance you can use just an incrementing number in the file then
> you are home free.
> 
> <from uri="jms:queue:A">
> <to uri="file://somedir?expression=myemail-${bean:idgenerator}.txt"/>
> 
> <bean id="idgenerator" class=org.mycompany.MyIdGenerator"/>
> 
> Public class MyIdGenerator {
>   Private static counter;
> 
>   Public int generateId() {
>      Return counter++;
>   }
> }
> 
> You can also use timestamp for the filename
> 
> <from uri="jms:queue:A">
> <to
> uri="file://somedir?expression=myemail-${date:now:yyyyMMddHHmmSSsss}.txt"/>
> 
> Where the date pattern is from java.text.SimpleDateFormat
> 
> 
> Check out the File component and File Language:
> http://activemq.apache.org/camel/file.html
> http://activemq.apache.org/camel/file-language.html
> 
> File Language is new in Camel 1.5
> 
> If you are using Camel 1.4 then you must set the file name with the
> special header key: FileComponent.HEADER_FILE_NAME
> (org.apache.camel.file.name)
> 
> <from uri="jms:queue:A">
> <setHeader headerName="org.apache.camel.file.name">
>     <beanRef id="idgenerator"/>
> </setHeader>
> <to uri="file://somedir"/>
> 
> If you don't explict set a filename with the header Camel will use an
> autogenerated name, that can be used for testing.
> PS: The spring setHeader syntax might need some tweak to get it correct
> with the bean expression.
> 
> 
> Med venlig hilsen
>  
> Claus Ibsen
> ......................................
> Silverbullet
> Skovsgårdsvænget 21
> 8362 Hørning
> Tlf. +45 2962 7576
> Web: www.silverbullet.dk
> 
> -----Original Message-----
> From: harpritt [mailto:harpritt@hotmail.com] 
> Sent: 20. oktober 2008 22:40
> To: camel-user@activemq.apache.org
> Subject: JMS to File to email to JMS
> 
> 
> Hi
> 
> Appologies if i make noob comments, alas that is what i am.
> 
> Ive been tasked with conecting our remote locations with only email access
> to our local jms queues.
> 
> I have one main requirement, the messages must arrive locally in the order
> that they were added to the remote JMS queue.
> 
> this is what i think i can do 
> 
> JMS queue -> File Directory ---> picked up by an external email app and
> sent
> to my local pop account --> Local JMS queue.
> 
> Do you guys see any problems with this? will camel know how to re-order
> the
> messages in the local queue?
> I really dont think it can unless i write some custom code.
> 
> ill be using the XML configuration because its a lot easier to document
> and
> maintain.
> 
> Ive done lots of looking but cant seem to find the answer, but i have a
> feeling that i will have to write my own file endpoint
> 
> as allways all help is appreciated.
> 
> Many Thanks
> 
> 
> -- 
> View this message in context:
> http://www.nabble.com/JMS-to-File-to-email-to-JMS-tp20078296s22882p20078296.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/JMS-to-File-to-email-to-JMS-tp20078296s22882p20086153.html
Sent from the Camel - Users mailing list archive at Nabble.com.


RE: JMS to File to email to JMS

Posted by harpritt <ha...@hotmail.com>.
Just an update

I found the PDF Manual... cant believe i missed it.

ive come accross an interesting section on Patterns, one relates to my
message resequencing problem that Claus Ibsen helped me with earlier. 

heres the link 
http://cwiki.apache.org/confluence/display/CAMEL/Resequencer

Looks cool!


Claus Ibsen wrote:
> 
> Hi
> 
> Just to get the fact straight: You *must* use files, since there is an
> external app relying on this?
> 
> The key is to store the files in the correct order, so the external app
> can read the files in correct order as well. So the file name can express
> this order.
> 
> If for instance you can use just an incrementing number in the file then
> you are home free.
> 
> <from uri="jms:queue:A">
> <to uri="file://somedir?expression=myemail-${bean:idgenerator}.txt"/>
> 
> <bean id="idgenerator" class=org.mycompany.MyIdGenerator"/>
> 
> Public class MyIdGenerator {
>   Private static counter;
> 
>   Public int generateId() {
>      Return counter++;
>   }
> }
> 
> You can also use timestamp for the filename
> 
> <from uri="jms:queue:A">
> <to
> uri="file://somedir?expression=myemail-${date:now:yyyyMMddHHmmSSsss}.txt"/>
> 
> Where the date pattern is from java.text.SimpleDateFormat
> 
> 
> Check out the File component and File Language:
> http://activemq.apache.org/camel/file.html
> http://activemq.apache.org/camel/file-language.html
> 
> File Language is new in Camel 1.5
> 
> If you are using Camel 1.4 then you must set the file name with the
> special header key: FileComponent.HEADER_FILE_NAME
> (org.apache.camel.file.name)
> 
> <from uri="jms:queue:A">
> <setHeader headerName="org.apache.camel.file.name">
>     <beanRef id="idgenerator"/>
> </setHeader>
> <to uri="file://somedir"/>
> 
> If you don't explict set a filename with the header Camel will use an
> autogenerated name, that can be used for testing.
> PS: The spring setHeader syntax might need some tweak to get it correct
> with the bean expression.
> 
> 
> Med venlig hilsen
>  
> Claus Ibsen
> ......................................
> Silverbullet
> Skovsgårdsvænget 21
> 8362 Hørning
> Tlf. +45 2962 7576
> Web: www.silverbullet.dk
> 
> -----Original Message-----
> From: harpritt [mailto:harpritt@hotmail.com] 
> Sent: 20. oktober 2008 22:40
> To: camel-user@activemq.apache.org
> Subject: JMS to File to email to JMS
> 
> 
> Hi
> 
> Appologies if i make noob comments, alas that is what i am.
> 
> Ive been tasked with conecting our remote locations with only email access
> to our local jms queues.
> 
> I have one main requirement, the messages must arrive locally in the order
> that they were added to the remote JMS queue.
> 
> this is what i think i can do 
> 
> JMS queue -> File Directory ---> picked up by an external email app and
> sent
> to my local pop account --> Local JMS queue.
> 
> Do you guys see any problems with this? will camel know how to re-order
> the
> messages in the local queue?
> I really dont think it can unless i write some custom code.
> 
> ill be using the XML configuration because its a lot easier to document
> and
> maintain.
> 
> Ive done lots of looking but cant seem to find the answer, but i have a
> feeling that i will have to write my own file endpoint
> 
> as allways all help is appreciated.
> 
> Many Thanks
> 
> 
> -- 
> View this message in context:
> http://www.nabble.com/JMS-to-File-to-email-to-JMS-tp20078296s22882p20078296.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/JMS-to-File-to-email-to-JMS-tp20078296s22882p20088700.html
Sent from the Camel - Users mailing list archive at Nabble.com.


RE: JMS to File to email to JMS

Posted by Claus Ibsen <ci...@silverbullet.dk>.
Hi

Just to get the fact straight: You *must* use files, since there is an external app relying on this?

The key is to store the files in the correct order, so the external app can read the files in correct order as well. So the file name can express this order.

If for instance you can use just an incrementing number in the file then you are home free.

<from uri="jms:queue:A">
<to uri="file://somedir?expression=myemail-${bean:idgenerator}.txt"/>

<bean id="idgenerator" class=org.mycompany.MyIdGenerator"/>

Public class MyIdGenerator {
  Private static counter;

  Public int generateId() {
     Return counter++;
  }
}

You can also use timestamp for the filename

<from uri="jms:queue:A">
<to uri="file://somedir?expression=myemail-${date:now:yyyyMMddHHmmSSsss}.txt"/>

Where the date pattern is from java.text.SimpleDateFormat


Check out the File component and File Language:
http://activemq.apache.org/camel/file.html
http://activemq.apache.org/camel/file-language.html

File Language is new in Camel 1.5

If you are using Camel 1.4 then you must set the file name with the special header key: FileComponent.HEADER_FILE_NAME (org.apache.camel.file.name)

<from uri="jms:queue:A">
<setHeader headerName="org.apache.camel.file.name">
    <beanRef id="idgenerator"/>
</setHeader>
<to uri="file://somedir"/>

If you don't explict set a filename with the header Camel will use an autogenerated name, that can be used for testing.
PS: The spring setHeader syntax might need some tweak to get it correct with the bean expression.


Med venlig hilsen
 
Claus Ibsen
......................................
Silverbullet
Skovsgårdsvænget 21
8362 Hørning
Tlf. +45 2962 7576
Web: www.silverbullet.dk

-----Original Message-----
From: harpritt [mailto:harpritt@hotmail.com] 
Sent: 20. oktober 2008 22:40
To: camel-user@activemq.apache.org
Subject: JMS to File to email to JMS


Hi

Appologies if i make noob comments, alas that is what i am.

Ive been tasked with conecting our remote locations with only email access
to our local jms queues.

I have one main requirement, the messages must arrive locally in the order
that they were added to the remote JMS queue.

this is what i think i can do 

JMS queue -> File Directory ---> picked up by an external email app and sent
to my local pop account --> Local JMS queue.

Do you guys see any problems with this? will camel know how to re-order the
messages in the local queue?
I really dont think it can unless i write some custom code.

ill be using the XML configuration because its a lot easier to document and
maintain.

Ive done lots of looking but cant seem to find the answer, but i have a
feeling that i will have to write my own file endpoint

as allways all help is appreciated.

Many Thanks


-- 
View this message in context: http://www.nabble.com/JMS-to-File-to-email-to-JMS-tp20078296s22882p20078296.html
Sent from the Camel - Users mailing list archive at Nabble.com.