Red Hat Managed Integration 1 Developing a Data Sync App
Total Page:16
File Type:pdf, Size:1020Kb
Red Hat Managed Integration 1 Developing a Data Sync App For Red Hat Managed Integration 1 Last Updated: 2020-01-21 Red Hat Managed Integration 1 Developing a Data Sync App For Red Hat Managed Integration 1 Legal Notice Copyright © 2020 Red Hat, Inc. The text of and illustrations in this document are licensed by Red Hat under a Creative Commons Attribution–Share Alike 3.0 Unported license ("CC-BY-SA"). An explanation of CC-BY-SA is available at http://creativecommons.org/licenses/by-sa/3.0/ . In accordance with CC-BY-SA, if you distribute this document or an adaptation of it, you must provide the URL for the original version. Red Hat, as the licensor of this document, waives the right to enforce, and agrees not to assert, Section 4d of CC-BY-SA to the fullest extent permitted by applicable law. Red Hat, Red Hat Enterprise Linux, the Shadowman logo, the Red Hat logo, JBoss, OpenShift, Fedora, the Infinity logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States and other countries. Linux ® is the registered trademark of Linus Torvalds in the United States and other countries. Java ® is a registered trademark of Oracle and/or its affiliates. XFS ® is a trademark of Silicon Graphics International Corp. or its subsidiaries in the United States and/or other countries. MySQL ® is a registered trademark of MySQL AB in the United States, the European Union and other countries. Node.js ® is an official trademark of Joyent. Red Hat is not formally related to or endorsed by the official Joyent Node.js open source or commercial project. The OpenStack ® Word Mark and OpenStack logo are either registered trademarks/service marks or trademarks/service marks of the OpenStack Foundation, in the United States and other countries and are used with the OpenStack Foundation's permission. We are not affiliated with, endorsed or sponsored by the OpenStack Foundation, or the OpenStack community. All other trademarks are the property of their respective owners. Abstract This document provides a comprehensive description and usage instructions for creating a Data Sync application, Red Hat Managed Integration 1. Table of Contents Table of Contents .P .R . E. .F . A. .C . E. .4 . .C . H. .A . P. .T .E . R. 1.. .I .N . T. .R .O . .D . U. .C . T. .I O. N. 5. 1.1. INTRODUCING DATA SYNC 5 1.2. DATA SYNC TECHNICAL OVERVIEW 5 1.3. DATA SYNC TERMINOLOGY 6 1.4. GETTING STARTED WITH HELLO WORLD DATA SYNC 7 .C . H. .A . P. .T .E . R. 2. Q. U. .E . R. .Y .I .N . G. A. D. .A . T. .A . .S . Y. .N . C. S. .E .R . V. .E . R. U. .S . I.N . G. A. D. .A . T. .A . .S . Y. .N . C. C. .L . I.E . N. .T . 1.0 . .C . H. .A . P. .T .E . R. 3. A. .D . .D . I.N . G. .A . .M . U. .T . A. .T . I.O . N. .T .O . A. D. .A . T. .A . .S .Y . N. .C . C . .L .I E. .N . T. 1.4 . .C . H. .A . P. .T .E . R. 4. .S .U . .P .P . O. R. .T .I .N . G. O. F. F. .L . I.N . E. F. U. N. .C . T. .I O. .N . .A .L . I.T . Y. I.N . .Y . O. U. .R . .M . O. B. .I L. .E . A. .P . P. 1.6 . 4.1. ABOUT OFFLINE FUNCTIONALITY 16 4.2. CREATING AN OFFLINE CLIENT 17 .C . H. .A . P. .T .E . R. 5. D. E. T. .E . C. .T . I.N . G. M. U. .T . A. .T . I.O . N. S. .W . .H . I. L. E. O. .F . F. .L .I .N . E. 1.8 . .C . H. .A . P. .T .E . R. 6. .P .E . R. .F . O. .R . M. I.N . G. .M . .U . T. A. .T . I.O . .N . S. W. H. .I L. .E . O. F. F. .L . I.N . E. 1.9 . 6.1. SUPPORTING APP RESTARTS WHILE OFFLINE 19 6.2. ENSURING SPECIFIED MUTATIONS ARE PERFORMED ONLINE ONLY 20 6.3. LISTENING FOR EVENTS 20 6.4. USING CACHE UPDATE HELPERS 21 6.4.1. Using cache update helpers for mutations 21 6.4.2. Using cache update helpers for subscriptions 22 6.4.3. Using cache update helpers for multiple subscriptions 22 .C . H. .A . P. .T .E . R. 7. D. E. T. .E . C. .T . I.N . G. N. E. T. .W . .O . .R .K . .S . T. .A . T. U. .S . .2 . 4. .C . H. .A . P. .T .E . R. 8. .S .U . P. .P . O. R. .T .I N. G. R. .E . A. .L .- .T . I.M . .E . .U . P. .D . A. .T .E . S. I.N . .Y . O. U. .R . .M . O. B. .I L. .E . A. .P . P. .2 . 5. 8.1. INTRODUCTION TO REAL-TIME UPDATES 25 8.2. IMPLEMENTING REAL-TIME UPDATES ON A DATA SYNC SERVER 25 8.2.1. Implementing a SubscriptionServer using voyager-subscription 26 8.2.2. Implementing a Publish Subscribe Mechanism 27 8.2.3. Defining subscriptions in the schema 27 8.2.4. Implementing resolvers 27 8.3. CONFIGURING A PUBLISH SUBSCRIBE MECHANISM 28 8.3.1. Using the Apollo PubSub mechanism 28 8.3.2. Using the MQTT PubSub mechanism 28 8.4. CONFIGURING AMQ ONLINE FOR MQTT MESSAGING 29 8.4.1. Creating an address space 29 8.4.2. Creating an Address 30 8.4.3. Creating an AMQ Online user 31 8.5. USING GRAPHQL MQTT PUBSUB WITH AMQ ONLINE 31 8.5.1. Using environment variables for configuration 34 8.5.2. Troubleshooting MQTT Connection Issues 34 8.5.2.1. Troubleshooting MQTT Events 34 8.5.2.2. Troubleshooting MQTT Configuration Issues 34 8.6. IMPLEMENTING REAL-TIME UPDATES ON ON THE CLIENT 35 8.6.1. Setting up a client to use subscriptions 35 8.6.2. Using Subscriptions 36 8.6.3. Handling network state changes 37 .C . H. .A . P. .T .E . R. 9. .S .U . P. .P . O. R. .T .I N. G. A. .U . T. .H . E. .N . T. .I C. .A . T. .I O. .N . A . .N . D. A. .U . T. .H . O. .R . I.Z . A. .T . I.O . N. .I N. Y. .O . U. .R . .M . .O . B. .I .L .E . .A . P. .P . .3 . 8. 1 Red Hat Managed Integration 1 Developing a Data Sync App 9.1. CONFIGURING YOUR SERVER FOR AUTHENTICATION AND AUTHORIZATION USING RED HAT SINGLE SIGN-ON 38 9.1.1. Protecting Data Sync Server using Red Hat Single Sign-On 38 9.1.2. Using the hasRole directive in a schema 39 9.2. AUTHENTICATION OVER WEBSOCKETS USING RED HAT SINGLE SIGN-ON 41 9.2.1. Red Hat Single Sign-On Authorization in Subscriptions 41 9.3. IMPLEMENTING AUTHENTICATION AND AUTHORIZATION ON YOUR CLIENT 43 .C . H. .A . P. .T .E . R. 1.0 . .. R. .E . S. .O . L. .V . I.N . G. C. .O . .N . F. .L . I.C . T. .S . I.N . Y. .O . U. .R . .D . A. .T . A. S. Y. .N . .C . .A . P. .P . .4 .4 . ..