I thought that this would be a reasonably common use case but I couldn't find the information I needed on the Internet and I wasted quite few hours scratching my... ar.. head...
[Service Layer] Alfresco + HornetQ + Mule (+ Hyperic Agent)
Mule Service1
I use Mule 2.2.1 to read emails from a pop account. Simple and straight forward using the pop3 transport.
The emails are actually forwarded as attachments to a parent email (could be more than one email as an attachment to the email) so my service splits the emails using a splitMessage in a router. It then places the individual messages on a HornetQ (jms queue1)
Mule Service2
Mule then consumes from (jms queue1) and completes a transformation of any attachments. I read the email, and iterate the attachments, transform them to PDF (Open office and iText), add the pdfs as attachments to the email, and finally place the email on HornetQ (jms queue2)
Mule Service3
Mule consumes from (jms queue2), saves messages into an alfresco repository using web services, creates a serialised transfer object (mytransfer.class) containing the alfresco node reference to the folder holding the attachments, and which places the transfer object on HornetQ (jms queue3).
I could do all this as one service however it is split into separate transactions so that we get the benefit of load balancing. The service layer is actually more than one VM and the HornetQ is clustered over those instances so any instance (the one with free capacity) consumes from the queue. Neat huh!?
[Portal Layer] Liferay Portal + Mule + JBPM
Mule Service4
In our portal we embed Mule which listens to (jms queue3). It consumes the transfer object and uses that information to link to the alfresco folder and start a JBPM workflow process. (Load balanced between the pooled portal instances)
Now the point to this blog is... gotcha at Mule Service2 (adding new attachments to an existing multipart message).
When you add attachments to an existing email (mimeMessage) you must call saveChanges() on it so that the headers are updated to reflect the changed content.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment