简体   繁体   中英

Mule-Flow: Checking Required Properties

I have a mule flow with an amqp inbound and outbound endpoint, here is a simplified example:

<flow name="foobar">

  <inbound-endpoint ref="amqp_inbound" />

  <transformer ref="some_xsl_transformer" />

  <outbound-endpoint ref="amqp_outbound"/>

</flow>

The amqp configuration is like so:

<amqp:endpoint name="amqp_inbound" queueName="${inbound.q.name}" connector-ref="amqpConnector" exchange-pattern="one-way" />

<amqp:connector
    name="amqpConnector"
    host="${q.host}"
    port="${q.port}"
    username="${q.username}"
    password="${q.password}"
    prefetchCount="${q.prefetchcount}"
    ackMode="MANUAL" />

What I would like to do is check the existence of the required properties when the application is deployed. If they are not present I would like to provide an error message with the missing required properties and gracefully shut down. With regular spring beans I have been implementing IntializingBean and checking required properties in the InitializingBean#afterPropertiesSet() method.

I would like to do something similar for properties that are referenced only by the mule flow, how is it possible? ie if ${q.username} is missing, do not deploy the application and throw an error message. Does mule allow such a thing?

In that case, use:

<context:property-placeholder
         location="classpath:config.properties"
         ignore-unresolvable="false" />

to load your properties, as Spring will throw an exception thus will prevent the application from loading.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM