2015-12-11 14 views
0

我在應用程序的屬性文件中存儲了一個記錄類型id,現在我想定義一個會調用該屬性文件讀取寫入其中的id的會話變量,所以我可以在我的查詢中使用這個會話變量。從mulesoft的會話變量中調用屬性文件

任何人都可以幫助我在會話變量中聲明值,因爲{$}不允許這樣做。另外,讓我知道會話變量是否適合執行此任務或需要採取其他措施。

回答

0

我不知道是什麼原因造成的問題...
我能夠從性能讀取文件和執行在SQL查詢會話變量: -
例如讓我的屬性文件是test.properties,它具有以下值: -

id=44 

所以,現在我可以從屬性文件,你在代碼中看到,以獲取價值並存儲到會話變量作爲${id}: -

<set-session-variable variableName="abc" value="${id}" doc:name="Session Variable"/> 

...還我能夠使用會話變量在DB SQL查詢

<context:property-placeholder location="classpath:test.properties"/> 
    <http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8088" doc:name="HTTP Listener Configuration"/> 
    <flow name="testFlow"> 
     <http:listener config-ref="HTTP_Listener_Configuration" path="/" doc:name="HTTP"/> 
     <set-session-variable variableName="abc" value="${id}" doc:name="Session Variable"/> 
     <db:select config-ref="Generic_Database_Configuration" doc:name="Database"> 
      <db:parameterized-query><![CDATA[Select * from table1 where ID=#[sessionVars['abc']];]]></db:parameterized-query> 
     </db:select> 
     <object-to-string-transformer doc:name="Object to String"/> 

    </flow> 

,我能夠從數據庫中獲得的價值如下: - enter image description here

1

您可以訪問屬性並將其存儲在一個會話變量,像這樣:

#[${my.property}] 
0

my.properties ID = 1234

要讀取上述ID的會話變量: 1.在GlobalElements創建屬性佔位符: 在媒體資源相關聯的地方保持器組件: 位置:文件:/my.proeprties

  • 會話變量拖動到流動 在會話變量 名稱:身份識別碼 值:{ID}
  • .mflow:

    .... /my.proeprties「/>

    輸出: --id值是1234