| 1 | # PCF Protocol Package |
| 2 | |
| 3 | This package provides a PCF (Programmable Command Format) protocol implementation for communicating with IBM MQ Queue Managers. |
| 4 | |
| 5 | ## Features |
| 6 | |
| 7 | - Full PCF protocol implementation with CGO bindings to IBM MQ C libraries |
| 8 | - Connection management with automatic reconnection and exponential backoff |
| 9 | - Static data caching (version, edition, platform) refreshed on reconnection |
| 10 | - Support for all major PCF commands (queues, channels, topics, etc.) |
| 11 | - Multi-message response handling for wildcard queries |
| 12 | - Human-readable error messages |
| 13 | |
| 14 | ## Usage |
| 15 | |
| 16 | ```go |
| 17 | import "github.com/netdata/netdata/go/plugins/plugin/ibm.d/protocols/pcf" |
| 18 | |
| 19 | // Create client |
| 20 | client := pcf.NewClient(pcf.Config{ |
| 21 | QueueManager: "QM1", |
| 22 | Channel: "SYSTEM.DEF.SVRCONN", |
| 23 | Host: "localhost", |
| 24 | Port: 1414, |
| 25 | User: "admin", |
| 26 | Password: "password", |
| 27 | }, state) |
| 28 | |
| 29 | // Connect |
| 30 | if err := client.Connect(); err != nil { |
| 31 | return err |
| 32 | } |
| 33 | defer client.Disconnect() |
| 34 | |
| 35 | // Get version (cached, refreshed on reconnection) |
| 36 | version, edition, err := client.GetVersion() |
| 37 | |
| 38 | // Get queue metrics |
| 39 | metrics, err := client.GetQueueMetrics("SYSTEM.DEFAULT.LOCAL.QUEUE") |
| 40 | |
| 41 | // Get queue list |
| 42 | queues, err := client.GetQueueList() |
| 43 | ``` |
| 44 | |
| 45 | ## Requirements |
| 46 | |
| 47 | - IBM MQ Client libraries installed |
| 48 | - CGO enabled |
| 49 | - Linux platform |
| 50 | |
| 51 | ## Protocol Details |
| 52 | |
| 53 | The PCF protocol uses IBM MQ's administrative interface to query queue manager statistics and configuration. Commands are sent to the `SYSTEM.ADMIN.COMMAND.QUEUE` and responses are received on a temporary dynamic queue. |
| 54 | |
| 55 | ### Connection Lifecycle |
| 56 | |
| 57 | 1. Connect to queue manager using MQCONNX |
| 58 | 2. Open command queue (SYSTEM.ADMIN.COMMAND.QUEUE) |
| 59 | 3. Create temporary reply queue |
| 60 | 4. Refresh static data (version, platform) |
| 61 | 5. Ready for PCF commands |
| 62 | |
| 63 | ### Error Handling |
| 64 | |
| 65 | The protocol automatically detects connection failures and marks itself as disconnected. The framework's backoff mechanism handles reconnection attempts. |
| 66 | |
| 67 | ### Caching |
| 68 | |
| 69 | Static data like version and platform information is cached and only refreshed on reconnection, reducing overhead for frequently accessed information. |