Search code examples
javamulemule-el

Can I access(and change) a property of smtp-connector programmatically?


I am running mule 3.3.1 CE.

I have an use case for which I need to be able to dynamically set the mime type on a smtp endpoint. But it appears I am unable to do so as it is currently bugged: https://www.mulesoft.org/jira/browse/MULE-6005

Also, if I use MEL to try and set the mime type like this:

mimeType="#[message.payload['email-mime']]"

All I get is bunch of stacktraces, and the application won't even deploy.

ERROR 2014-02-17 16:28:58,153 [Mule.app.deployer.monitor.1.thread.1] org.mule.module.launcher.application.DefaultMuleApplication: null org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessException details (1) are: PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'mimeType' threw exception; nested exception is java.lang.IllegalArgumentException: Unable to find a sub type. at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:1167) at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:924)

Is there a way to access the connector itself during runtime, and perhaps be able to change it so I would be able to change the mime type as needed? Or an alternative solution?


Solution

  • Define a separate smtp:connector like in the Jira description and try to set the content type in a Groovy script somewhere inside the flow like this:

    muleContext.getRegistry().lookupObject('smtpConnector').setContentType('text/html')