gu / mqclient
GU MQ Client
Installs: 5 601
Dependents: 0
Suggesters: 0
Security: 0
Type:symfony-messenger-bridge
pkg:composer/gu/mqclient
Requires
- php: >=7.4
- dev-master
- 0.0.9
- 0.0.8
- 0.0.7
- 0.0.6
- 0.0.5
- 0.0.4
- 0.0.3
- 0.0.2
- 0.0.1
- dev-bugfix/WK-6866-cs-fel-stoppar-pr-tester-i-profi
- dev-WK-5981-envelope-stamp-fixes
- dev-feature/WK-5981-add-support-for-inquire
- dev-develop
- dev-bugfix/WK-5948-notices-in-mqclient
- dev-fix/fix_arrays_in_podman_images
- dev-feature/Initial-development
This package is auto-updated.
Last update: 2025-12-31 00:28:11 UTC
README
Application setup
An application can require mqclient via composer. The client requires information about the MQ server it should communicate with, the code examples assume the configuration is passed in an array like: `` $config = [
'host' => '',
'port' => '',
'qmanager' => '',
'channel' => '',
'queue' => '',
'user' => '',
'pass' => '',
'key_repo' => '',
]; ``
Connecting to a queue manager
``
$mqcno_stamp = new MqcnoStamp($config['host'], $config['port'], $config['channel']);
$mqcno_stamp->enableSSL($config['key_repo']);
$mqcno_stamp->setAuth($config['user'], $config['pass']);
$conn = $mqcno_stamp->toConnection($config['qmanager']);
``
Opening a queue for reading or writing
``
$mqod = new MqodEnvelope(new MqodStamp($config['queue']));
$conn->open($mqod);
`` The envelope $mqod will contain a reference to an open object (normally a queue).
Sending messages
``
$mqpmo = $mqod->toPutEnvelope(true);
$mqpmo->setMessage('Message 1');
$conn->put($mqpmo);
$mqpmo->setMessage('Message 2');
$conn->put($mqpmo);
$conn->commit($mqpmo);
``
Reading messages
``
$mqgmo = $mqod->toGetEnvelope(true);
$conn->get($mqgmo);
$msg = $mqgmo->getMessage();
$conn->commit($mqgmo);
``
Disconnecting
``
$conn->disconnect($mqpmo);
``
Handling errors
The connection object throws an MqException when there are errors, for example, when there are configuration errors or when the server can not be reached. Some MQ calls return a reason code, and it might be useful to check it after each call. ``
$conn->lastReason();
$conn->lastReasonString();
`
For example, $conn->get($mqgmo) calls can return reason 2033 when there are no more messages in the queue. The string for this reason is No message available.`