简体   繁体   English

Mule-Flow:检查必需的属性

[英]Mule-Flow: Checking Required Properties

I have a mule flow with an amqp inbound and outbound endpoint, here is a simplified example: 我有一个带有amqp入站和出站端点的m子流,这是一个简化的示例:

<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配置如下所示:

<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. 使用常规的Spring bean,我一直在实现IntializingBean并在InitializingBean#afterPropertiesSet()方法中检查所需的属性。

I would like to do something similar for properties that are referenced only by the mule flow, how is it possible? 我想对仅由m子流引用的属性执行类似的操作,这怎么可能? ie if ${q.username} is missing, do not deploy the application and throw an error message. 例如,如果缺少$ {q.username},请不要部署应用程序并抛出错误消息。 Does mule allow such a thing? m子允许这样的事情吗?

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. 加载您的属性,因为Spring会抛出异常,从而阻止应用程序加载。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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