fabric8-tech-demo-notes

advertisement
Enterprise Service Bus Demo - 8/28/2014 - Mike Thomas
References:
Fabric8 Web Site:
http://fabric8.io/
ATS Project Wiki:
https://wiki.harvard.edu/confluence/display/ATSESB/Welcome
Demo Data Flows:
1.mike-amq-producer.xml
Input Folder
Message
Producer
Queue
Output
Folder
2.ojdbc7-bundle.jar, 3.mike-db-datasource.xml
Input Folder
Message
Producer
Queue
Output
Folder
Connection Pool
Oracle DB
4.mike-db-client.xml
Input Folder
Message
Producer
Queue
Message
Consumer
Log File
Output
Folder
Connection Pool
Oracle DB
Page 1
mike-amq-producer.xml
mike-db-client.xml
<?xml version="1.0" encoding="UTF-8"?>
<blueprint
xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0"
xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0
http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
<?xml version="1.0" encoding="UTF-8"?>
<blueprint
xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0
http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
<!-- ActiveMQ connection -->
<bean id="jmsConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="discovery:(fabric:default)"/>
<property name="userName" value="admin"/>
<property name="password" value="admin"/>
</bean>
<bean id="pooledConnectionFactory"
class="org.apache.activemq.pool.PooledConnectionFactory">
<property name="maxConnections" value="1"/>
<property name="maximumActiveSessionPerConnection" value="500"/>
<property name="connectionFactory" ref="jmsConnectionFactory"/>
</bean>
<bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
<property name="connectionFactory" ref="pooledConnectionFactory"/>
</bean>
<!-- DB connection -->
<reference id="myDataSource" interface="javax.sql.DataSource"
filter="(osgi.jndi.service.name=jdbc/oracleds)" availability="mandatory" />
<!-- ActiveMQ connection -->
<bean id="jmsConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="discovery:(fabric:default)"/>
<property name="userName" value="admin"/>
<property name="password" value="admin"/>
</bean>
<bean id="pooledConnectionFactory" class="org.apache.activemq.pool.PooledConnectionFactory">
<property name="maxConnections" value="1"/>
<property name="maximumActiveSessionPerConnection" value="500"/>
<property name="connectionFactory" ref="jmsConnectionFactory"/>
</bean>
<bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
<property name="connectionFactory" ref="pooledConnectionFactory"/>
</bean>
<camelContext xmlns="http://camel.apache.org/schema/blueprint">
<route id="mike-amq-producer">
<from uri="file:data-mike/input"/>
<camelContext xmlns="http://camel.apache.org/schema/blueprint">
<route id="mike-db-client">
<description>Mike's DB call.</description>
<to uri="file:data-mike/output"/>
<log message="+++ step 1: ${body}:"/>
<!-- Get the surname to query from ActiveMQ queue. -->
<from uri="activemq:queue:mike-test"/>
<log message="+++ step 3: ${body}:"/>
<setBody><xpath resultType="java.lang.String">/query/lastName</xpath></setBody>
<log message="+++ step 2: ${body}:"/>
<!-- Do the SQL query. -->
<to uri="sql:select count(*) as cnt from person where
last_name=#?dataSource=myDataSource"/>
<log message="step2:${body}:"/>
<to uri="activemq:queue:mike-test" />
</route>
</camelContext>
<!-- The result is a List of Maps (one Map for each record returned). Extract
the value we were querying for and convert it to a string. -->
<setBody><simple>${body[0][CNT]}</simple></setBody>
<setBody><simple>${bodyAs(String)}</simple></setBody>
<log message="+++ step 4: DB record count ${body}:"/>
</blueprint>
</route>
</camelContext>
</blueprint>
Page 2
Demo Steps



default login/password = admin/admin
Install
o Unzip to here
o Copy system.properties to FABRIC8_HOME/etc/ so I have DB login/password.
o Run my fabric8-karaf.cmd.
Create a fabric:
osgi:list
help all
fabric:create
container-info

[wait for ASCII text header to appear again ...]
[... and show them first bundle while we're waiting]
Install activeMQ and camel features:
profile-list
[to list available profiles]
container-add-profile root mq-amq feature-camel feature-cxf
container-info
[repeatedly until provision status = success]
profile-edit --features activemq-camel/0.0.0 fabric
profile-edit --features camel-sql/0.0.0 fabric


PICTURE 1 Deploy 1.mike-amq-producer.xml and demonstrate it with payload-jones.xml.
Use hawtio console to demo ActiveMQ:
Console URL: http://localhost:8181/hawtio/
admin/admin
o
o
o

Set perspective to Container in top left corner
Select ActiveMQ tab, press +Create button and create a queue.
Select queue in tree and press Send button to send a message. You will be prompted to
link to settings to set credentials: re-enter password: admin
PICTURE 2 Set up connection pool
o Ensure I installed system.properties in /etc. Restart if I forgot.
o Deploy JDBC driver bundle 2.ojdbc7-bundle.jar
profile-edit --bundles file:/C:/applications/fabric8-demo/deployables/2.ojdbc7bundle.jar fabric

o Deploy 3.mike-db-datasource.xml.
PICTURE 3 Deploy DB client / MQ consumer:
o deploy 4.mike-db-client client xml
o copy payload-smith.xml into input folder
o show output in log:display
o use osgi:stop and start to stop and start the mike-db-client.xml.
o run payload-generate.sh (right click, open with bash.exe) to create 100 files
Page 3
Download