|
| 1 | +// tag::master-1A[] |
| 2 | +:walkthrough: Integrating event-driven and API-driven applications (AMQ) |
| 3 | +:fuse-version: 7.2 |
| 4 | +:messaging-service: EnMasse |
| 5 | + |
| 6 | +// The ID is used as an anchor for linking to the module. Avoid changing it after the module has been published to ensure existing links are not broken. |
| 7 | +[id='integrating-eventdriven-and-apidriven-applications'] |
| 8 | +// If the assembly is reused in other assemblies in a guide, include {context} in the ID: [id='a-collection-of-modules-{context}']. |
| 9 | + |
| 10 | +// Book Title |
| 11 | += {walkthrough} |
| 12 | + |
| 13 | +//If the assembly covers a task, start the title with a verb in the gerund form, such as Creating or Configuring. |
| 14 | +:context: integrating-eventdriven-and-apidriven-applications |
| 15 | +// The `context` attribute enables module reuse. Every module's ID includes {context}, which ensures that the module has a unique ID even if it is reused multiple times in a guide. |
| 16 | + |
| 17 | +//include::master-1-intro.adoc[ ] |
| 18 | + |
| 19 | +// word count range that fits best is 15-22, with 20 really being the sweet spot. Character count for that space would be 100-125 |
| 20 | +Build a simple integration that connects a message queue with an API. |
| 21 | + |
| 22 | +In a multi-application system, you often find: |
| 23 | + |
| 24 | +* communication between the applications can be difficult due to differing technologies |
| 25 | +* custom solutions can be difficult to create and maintain |
| 26 | +* custom solutions require custom monitoring |
| 27 | +* understanding the relationship between the applications requires deep technical insight to the overall architecture |
| 28 | + |
| 29 | +A more structured approach involves: |
| 30 | + |
| 31 | +* a simple integration that developers can understand intuitively |
| 32 | +* simple provisioning and configuration |
| 33 | +* built-in monitoring |
| 34 | + |
| 35 | +This walkthrough describes how to create such an integration, using OpenShift, {messaging-service} and API connectors in Fuse. |
| 36 | + |
| 37 | +++++ |
| 38 | +<img src="/images/wt1.png" class="img-responsive" alt="integration"> |
| 39 | +++++ |
| 40 | + |
| 41 | +// end::master-1[] |
| 42 | + |
| 43 | +// tag:task-creating-addresses.adoc[] |
| 44 | + |
| 45 | +[time=6] |
| 46 | + |
| 47 | +[id='creating-addresses_{context}'] |
| 48 | + |
| 49 | + |
| 50 | +// TODO: figure out enmasse url |
| 51 | +:enmasse-url: https://console-enmasse.apps.city.openshiftworkshop.com/console/my-example-space |
| 52 | +// https://console-enmasse-my-example-space.apps.city.openshiftworkshop.com/#/dashboard |
| 53 | + |
| 54 | +== Creating Addresses |
| 55 | +:context: creating-connections |
| 56 | + |
| 57 | +// tag::creating-api-connector[] |
| 58 | + |
| 59 | +[.integr8ly-docs-header] |
| 60 | +=== Creating an address in EnMasse space |
| 61 | + |
| 62 | +To route messages to the Spring Boot app, you create an address in EnMasse. |
| 63 | + |
| 64 | +. Log into link:{enmasse-url}[EnMasse, window="_blank"] by selecting the *OpenShift* button on the log in screen and accepting the permissions request. |
| 65 | +. Select *Addresses* from the left hand menu. |
| 66 | + |
| 67 | +. Create a *requests* address: |
| 68 | +.. Select the *Create* button to start the *Create new address* wizard. |
| 69 | +.. Enter the following as the address name: |
| 70 | ++ |
| 71 | +[subs="attributes+"] |
| 72 | +---- |
| 73 | +work-queue-requests |
| 74 | +---- |
| 75 | +.. Select *queue* as the type and click *Next*. |
| 76 | +.. Select *Small Queue* as the address plan and click *Next*. |
| 77 | +.. Select *Create* to complete the wizard. |
| 78 | + |
| 79 | +After the address is created a green check mark is displayed. |
| 80 | + |
| 81 | +[type=verification] |
| 82 | +Check the *Addresses* screen of the link:{messaging-url}[EnMasse, window="_blank"] console to make sure the newly created address exists. |
| 83 | + |
| 84 | +[type=verificationFail] |
| 85 | +Verify that you followed each step in the procedure above. If you are still having issues, contact your administrator. |
| 86 | + |
| 87 | +// end::task-creating-addresses[] |
| 88 | + |
| 89 | + |
| 90 | +[time=5] |
| 91 | +[id='integrating-eventdriven-and-apidriven-applications'] |
| 92 | +[id='creating-connections'] |
| 93 | +== Creating connections |
| 94 | +:context: creating-connections |
| 95 | + |
| 96 | +// tag::creating-api-connector[] |
| 97 | + |
| 98 | +[id='creating-api-connector_{context}'] |
| 99 | +[.integr8ly-docs-header] |
| 100 | +=== Creating an API Connector |
| 101 | + |
| 102 | +. Log in to the link:{fuse-url}[Red Hat Fuse Online, window="_blank"] console. |
| 103 | + |
| 104 | +. Select *Customizations* from the left hand menu. |
| 105 | + |
| 106 | +. Select the *Create API Connector* button to start the *API Client Connector* wizard. |
| 107 | + |
| 108 | +. When prompted to *Upload OpenAPI Specification*, select *Use a URL*: |
| 109 | +.. Enter the following in the URL field: |
| 110 | ++ |
| 111 | +[subs="attributes+"] |
| 112 | +---- |
| 113 | +http://{spring-boot-url}/v2/api-docs |
| 114 | +---- |
| 115 | + |
| 116 | +.. Click *Next*. |
| 117 | + |
| 118 | +. When prompted with *Review Actions*, select *Next*. |
| 119 | + |
| 120 | +. When prompted with *Specify Security*, select *Next*. |
| 121 | + |
| 122 | +. When prompted with *Review/Edit Connector Details*: |
| 123 | +.. Enter the following in the *Connector Name* field: |
| 124 | ++ |
| 125 | +[subs="attributes+"] |
| 126 | +---- |
| 127 | +Walkthrough {walkthrough-id} CRUD Connector |
| 128 | +---- |
| 129 | + |
| 130 | +.. Click *Create API Connector*. |
| 131 | + |
| 132 | +[type=verification] |
| 133 | +Check the *Customizations* screen of the link:{fuse-url}[Red Hat Fuse Online, window="_blank"] console to make sure the new connector exists. |
| 134 | + |
| 135 | +[type=verificationFail] |
| 136 | +Verify that you followed each step in the procedure above. If you are still having issues, contact your administrator. |
| 137 | + |
| 138 | +// end::creating-api-connector[] |
| 139 | + |
| 140 | +// tag::creating-amqp-connection-in-fuse[] |
| 141 | + |
| 142 | +// Module included in the following assemblies: |
| 143 | +// |
| 144 | +// <List assemblies here, each on a new line> |
| 145 | + |
| 146 | +:enmasse: Red Hat AMQ Online |
| 147 | + |
| 148 | + |
| 149 | +// tag::creating-http-connection[] |
| 150 | + |
| 151 | +[id='creating-http-connection-in-fuse_{context}'] |
| 152 | +[.integr8ly-docs-header] |
| 153 | +=== Creating HTTP connection to CRUD App |
| 154 | + |
| 155 | +To send messages to the Spring Boot app, you create a connection in Red Hat Fuse Online. |
| 156 | + |
| 157 | + |
| 158 | +. Log in to the link:{fuse-url}[Red Hat Fuse Online, window="_blank"] console. |
| 159 | + |
| 160 | +. Select *Connections* from the left hand menu. |
| 161 | + |
| 162 | +. Select the *Create Connection* button to start the *Create Connection* wizard. |
| 163 | + |
| 164 | +. When prompted with *Select Connector*, select *Walkthrough {walkthrough-id} CRUD Connector*. |
| 165 | + |
| 166 | +. When prompted with *Walkthrough {walkthrough-id} CRUD Configuration*, click *Next*. |
| 167 | + |
| 168 | +. When prompted with *Add Connection Details*: |
| 169 | +.. Enter the following in the *Connection Name* field: |
| 170 | ++ |
| 171 | +[subs="attributes+"] |
| 172 | +---- |
| 173 | +Walkthrough {walkthrough-id} CRUD App |
| 174 | +---- |
| 175 | +.. Click *Create*. |
| 176 | + |
| 177 | + |
| 178 | +[type=verification] |
| 179 | +Check the *Connections* screen of the link:{fuse-url}[Red Hat Fuse Online, window="_blank"] console to make sure the new connection exists. |
| 180 | + |
| 181 | +[type=verificationFail] |
| 182 | +Verify that you followed each step in the procedure above. If you are still having issues, contact your administrator. |
| 183 | + |
| 184 | + |
| 185 | +// end::creating-http-connection[] |
| 186 | + |
| 187 | +[id='creating-amqp-connection-in-fuse_{context}'] |
| 188 | +[.integr8ly-docs-header] |
| 189 | +=== Creating AMQP connection in Red Hat Fuse Online |
| 190 | + |
| 191 | +To receive messages from EnMasse, you create a connection in Red Hat Fuse Online. |
| 192 | + |
| 193 | + |
| 194 | +:fuse-url: https://eval.apps.city.openshiftworkshop.com/ |
| 195 | +:openshift-url: https://master.city.openshiftworkshop.com/console/project/eval/overview |
| 196 | + |
| 197 | +. Log in to the link:{fuse-url}[Red Hat Fuse Online, window="_blank"] console. |
| 198 | + |
| 199 | +. Select *Connections* from the left hand menu. |
| 200 | + |
| 201 | +. Select the *Create Connection* button to start the *Create Connection* wizard. |
| 202 | + |
| 203 | +. Select *AMQP* to configure an *AMQP Message Broker* connection. |
| 204 | + |
| 205 | +. Enter the connection URI relating to {enmasse}: |
| 206 | ++ |
| 207 | +[subs="attributes+"] |
| 208 | +---- |
| 209 | +amqp://{enmasse-broker-url}:5672?amqp.saslMechanisms=PLAIN |
| 210 | +---- |
| 211 | + |
| 212 | +. Enter the username relating to {enmasse}: |
| 213 | ++ |
| 214 | +[subs="attributes+"] |
| 215 | +---- |
| 216 | +{enmasse-credentials-username} |
| 217 | +---- |
| 218 | + |
| 219 | +. Enter the password relating to {enmasse}: |
| 220 | ++ |
| 221 | +[subs="attributes+"] |
| 222 | +---- |
| 223 | +{enmasse-credentials-password} |
| 224 | +---- |
| 225 | + |
| 226 | +. Set the value of *Check Certificates* to `Disable`. |
| 227 | + |
| 228 | +. Select the *Validate* button to check that the values are valid. |
| 229 | + |
| 230 | +. Click *Next* and enter a name for the connection, for example: |
| 231 | ++ |
| 232 | +[subs="attributes+"] |
| 233 | +---- |
| 234 | +Walkthrough {walkthrough-id} Messaging App |
| 235 | +---- |
| 236 | + |
| 237 | +. Click *Create*. |
| 238 | + |
| 239 | + |
| 240 | +[type=verification] |
| 241 | +Check the *Connections* screen of the link:{fuse-url}[Red Hat Fuse Online, window="_blank"] console to make sure the new connection exists. |
| 242 | + |
| 243 | + |
| 244 | +[type=verificationFail] |
| 245 | +Verify that you followed each step in the procedure above. If you are still having issues, contact your administrator. |
| 246 | + |
| 247 | + |
| 248 | +// end::creating-amqp-connection-in-fuse[] |
| 249 | + |
| 250 | + |
| 251 | + |
| 252 | +[time=5] |
| 253 | +[id='creating-an-integration'] |
| 254 | +== Creating an integration |
| 255 | +:context: creating-an-integration |
| 256 | + |
| 257 | +// end::task-creating-fuse-integration[] |
| 258 | + |
| 259 | +[id='creating-fuse-integration_{context}'] |
| 260 | +[.integr8ly-docs-header] |
| 261 | +=== Creating an integration |
| 262 | + |
| 263 | +To use the Fuse connections, you create an integration in Red Hat Fuse Online. |
| 264 | + |
| 265 | +. Select *Integrations* from the left hand menu. |
| 266 | + |
| 267 | +. Select the *Create Integration* button to start the *Create Integration* wizard. |
| 268 | + |
| 269 | +. Choose *Walkthrough {walkthrough-id} Messaging App* as the *Start Connection*. |
| 270 | + |
| 271 | +. When prompted to *Choose an Action*, select *Subscribe for messages*. |
| 272 | + |
| 273 | +. When prompted for a *Destination Name*, enter: |
| 274 | ++ |
| 275 | +[subs="attributes+"] |
| 276 | +---- |
| 277 | +work-queue/requests |
| 278 | +---- |
| 279 | + |
| 280 | +. Choose *Queue* as the *Destination Type* and click *Next*. |
| 281 | + |
| 282 | +. When prompted to *Specify Output Data Type*: |
| 283 | +.. Select *JSON Schema* as the type. |
| 284 | +.. Enter the following in the *Definition* field: |
| 285 | ++ |
| 286 | +[subs="attributes+"] |
| 287 | +---- |
| 288 | +{ |
| 289 | + "$schema": "http://json-schema.org/draft-04/schema#", |
| 290 | + "type": "object", |
| 291 | + "properties": { |
| 292 | + "type": { |
| 293 | + "type": "string" |
| 294 | + } |
| 295 | + } |
| 296 | +} |
| 297 | +---- |
| 298 | +.. Click *Done*. |
| 299 | + |
| 300 | +. Choose *Walkthrough {walkthrough-id} CRUD App* as the *Finish Connection*. |
| 301 | + |
| 302 | +. When prompted to *Choose an Action*, select *Create a fruit*. |
| 303 | + |
| 304 | +. When prompted to *Add to Integration*, select *Add a Step*. |
| 305 | + |
| 306 | +. Select *Data Mapper* to map source and target fields in the corresponding JSON schemas: |
| 307 | +.. Click and drag *type* from the *Source* column to *body/name* in the *Target* column. |
| 308 | +.. Click *Done* to navigate back to the Integration screen. |
| 309 | + |
| 310 | +. Click *Publish*. |
| 311 | +. When prompted, enter a name, for example: |
| 312 | ++ |
| 313 | +[subs="attributes+"] |
| 314 | +---- |
| 315 | +Walkthrough {walkthrough-id} |
| 316 | +---- |
| 317 | + |
| 318 | +[type=verification] |
| 319 | +Check the *Integrations* screen of the link:{fuse-url}[Red Hat Fuse Online, window="_blank"] console to make sure the new connection exists. |
| 320 | + |
| 321 | +[type=verificationFail] |
| 322 | +Verify that you followed each step in the procedure above. If you are still having issues, contact your administrator. |
| 323 | +// end::task-creating-fuse-integration[] |
| 324 | + |
| 325 | + |
| 326 | + |
| 327 | +[time=5] |
| 328 | +[id='using-the-application-integration'] |
| 329 | +== Using the application integration |
| 330 | +:context: using-the-application-integration |
| 331 | + |
| 332 | +// tag::task-using-integration[] |
| 333 | +[id='using-integration_{context}'] |
| 334 | +[.integr8ly-docs-header] |
| 335 | +=== Using the application integration |
| 336 | + |
| 337 | +After setting up the integration between the Node.js and Spring Boot applications, we can use the integration to create a new fruit for the grocery inventory application. |
| 338 | + |
| 339 | +:node-url: http://frontend-node-app.apps.city.openshiftworkshop.com/ |
| 340 | +:spring-url: http://spring-boot-rest-http-crud-spring-app.apps.city.openshiftworkshop.com/ |
| 341 | +:fuse-url: https://eval.apps.city.openshiftworkshop.com/ |
| 342 | + |
| 343 | +. Navigate to the link:http://{node-js-url}[Node.js app, window="_blank"]. |
| 344 | + |
| 345 | +. Enter a value for *Fruit*, for example: |
| 346 | ++ |
| 347 | +---- |
| 348 | +Pineapple |
| 349 | +---- |
| 350 | + |
| 351 | +. Click *Send Request*. |
| 352 | + |
| 353 | +. Navigate to the link:http://{spring-boot-url}[Spring Boot app, window="_blank"]. |
| 354 | + |
| 355 | +. Check that the entry from the Node.js app is displayed. |
| 356 | + |
| 357 | + |
| 358 | +[type=verification] |
| 359 | +**** |
| 360 | +View the activity log: |
| 361 | +
|
| 362 | +. Log in to the link:{fuse-url}[Red Hat Fuse Online, window="_blank"] console. |
| 363 | +. Select *Integrations* from the left hand menu. |
| 364 | +. Select your integration. |
| 365 | +. Select the *Activity* tab. |
| 366 | +. Expand the log entry to display the steps performed. |
| 367 | +**** |
| 368 | + |
| 369 | +[type=verificationFail] |
| 370 | +Verify that you followed each step in the procedure above. If you are still having issues, contact your administrator. |
| 371 | + |
| 372 | + |
| 373 | +// end::task-using-integration[] |
0 commit comments