[Info-vax] RDB, trigger, native procedure and ActiveMQ
Arne Vajhøj
arne at vajhoej.dk
Sun May 30 19:47:32 EDT 2021
Rdb features have been discussed here a few times and
some time ago I read a bit in the Rdb manual and found
the section on native procedure.
And since I like playing around with such stuff I
created a little demo.
Setup:
Rdb table -> insert trigger -> procedure written in C -> STOMP library
-> message queue on ActiveMQ
That means that when some application (residing on VMS or
elsewhere) insert data in that table, then another
application (residing on VMS or elsewhere) get
notified in near real time.
C snippet:
void stomp_send(struct dsc$descriptor *host,
int port,
struct dsc$descriptor *dest,
struct dsc$descriptor *data)
{
char host2[256];
char dest2[256];
char data2[256];
simple_stomp_t ctx;
desc2buf(host, host2);
desc2buf(dest, dest2);
desc2buf(data, data2);
simple_stomp_debug(0);
simple_stomp_init(&ctx, host2, port, print);
simple_stomp_write(&ctx, dest2, data2);
simple_stomp_close(&ctx);
}
Define procedure in Rdb:
CREATE PROCEDURE stomp_send(IN VARCHAR(255) BY DESCRIPTOR,
IN INTEGER BY VALUE,
IN VARCHAR(255) BY DESCRIPTOR,
IN VARCHAR(255) BY DESCRIPTOR);
EXTERNAL NAME stomp_send LOCATION 'disk2:[arne.dbmq]cproc.exe'
LANGUAGE GENERAL PARAMETER STYLE GENERAL
BIND ON SERVER SITE;
Insert trigger:
CREATE TRIGGER t1insert
AFTER INSERT ON t1
(CALL stomp_send('arnepc4', 61613, '/queue/t1insert', CAST(t1.f1 AS
VARCHAR(10)))) FOR EACH ROW;
Tested with 3 database clients:
* Cobol on VMS
* Java on PC
* C# on PC
and 1 message queue client:
* Python on VMS
It works.
More details and complete code available at:
https://www.vajhoej.dk/arne/articles/vmstd1.html
Arne
More information about the Info-vax
mailing list