Tuesday, June 27, 2017

WSO2- How to change c-app based artifacts for different environment?

You can follow below steps:

1. Create the message store as below (using ESB tooling)
<?xml version="1.0" encoding="UTF-8"?>
<messageStore
  class="org.apache.synapse.message.store.impl.rabbitmq.RabbitMQStore"
  name="TestMessageStore" xmlns="http://ws.apache.org/ns/synapse">
  <parameter name="store.rabbitmq.host.name">${hostName}</parameter>
  <parameter name="store.producer.guaranteed.delivery.enable">${guaranteed_delivery}</parameter>
  <parameter name="store.rabbitmq.host.port">${port}</parameter>
  <parameter name="store.rabbitmq.username">${userName}</parameter>
  <parameter name="store.rabbitmq.password">${password}</parameter>
</messageStore>

2. In pom.xml we need to add the properties as below
....
  <properties>
      <maven.test.skip>false</maven.test.skip>
      <CApp.type>...</CApp.type>
      <hostName>${hostName}</hostName>
      <guaranteed_delivery>${guaranteed_delivery}</guaranteed_delivery>
      <port>${port}</port>
      <userName>${userName}</userName>
      <password>${password}</password>
  </properties>
....
 
3. Build the configuration project, by passing the relevant values according to the environment. According to the above sample, we build the project by using below command
mvn clean install -DhostName=172.22.217.25 -Dguaranteed_delivery=true -Dport=5672 -DuserName=admin -Dpassword=admin

4. Build the Carbon application (CAR project) by using below command
mvn clean install

5. In the CAR file, we can see the message store as below
<messageStore class="org.apache.synapse.message.store.impl.rabbitmq.RabbitMQStore" name="TestMessageStore">
<parameter name="store.rabbitmq.host.name">172.22.217.25</parameter>
<parameter name="store.producer.guaranteed.delivery.enable">false</parameter>
<parameter name="store.rabbitmq.host.port">5672</parameter>
<parameter name="store.rabbitmq.username">admin</parameter>
<parameter name="store.rabbitmq.password">admin</parameter>
</messageStore>
 
You can configure the artifacts configuration according to the environment and this is the recommended way.

No comments:

Post a Comment