I switched from using queues with a RAW payload to queues with object payload (I hit the 32k limit of raw payloads). I defined an object as follows:
I have two processes (sevices). One enqueues only, the other dequeues, processes data (ENGINE_MESSAGE stores an XML document with data to process) and optionally reenqueues one or more objects to be processed, if needed.
The code used is (TdmIkonSystem is my datamodule):
When using the object payload instead of the RAW ones, a memory leak appears that will "eat" all available memory soon. It disappear when I use RAW payloads. I tried several combinations of EnqueueOptions, and trying to commit after enqueueing the message, but nothing helped.
I observed that the process that only enqueues works ok, and if the other process only dequeues it works too. When this process starts to dequeue and enqueue (using two separate TOracleQueue objects, and usually in two separate datamodule instances with separate connections), the memory leak appears. Am I doing something wrong with objects, or is it a DOA leak?
May I ask also why "Payload" is generated internally, and not passed to the Enqueue function? I would have preferred something alike
Code:
create or replace type IKON_SYSTEM.PM_ENGINE_MESSAGE as object (
PROCESS_ID NUMBER,
PROJECT_ID NUMBER,
ENGINE_MESSAGE CLOB
);
The code used is (TdmIkonSystem is my datamodule):
Code:
procedure TdmIkonSystem.Enqueue(const AMessage: string; AProcessID,
AProjectID: Int64; const ASender: string; APriority: Integer);
begin
try
{$IFDEF RAW_PAYLOAD}
Enqueuer.RawPayload := AMessage;
{$ELSE}
with Enqueuer.Payload do
begin
SetAttr('PROCESS_ID', AProcessID);
SetAttr('PROJECT_ID', AProjectID);
SetAttr('ENGINE_MESSAGE', AMessage);
end;
{$ENDIF}
Enqueuer.MessageProperties.Priority := APriority;
Enqueuer.MessageProperties.SenderId.Name := ASender;
Enqueuer.Enqueue;
Enqueuer.Session.Commit;
except
Enqueuer.Session.Rollback;
raise;
end;
end;
I observed that the process that only enqueues works ok, and if the other process only dequeues it works too. When this process starts to dequeue and enqueue (using two separate TOracleQueue objects, and usually in two separate datamodule instances with separate connections), the memory leak appears. Am I doing something wrong with objects, or is it a DOA leak?
May I ask also why "Payload" is generated internally, and not passed to the Enqueue function? I would have preferred something alike
Code:
Payload := Payload.Create(...)
try
Enqueue(Payload);
finally
Payload.Free;
end;