Execute single message for inbound without executing all inbound ports.
class Krishh_InboundParallelMsgProcessPerMsgId extends AifInboundParallelMsgProcess
{
RecId gatewayQueueRecId;
DialogField dlgfRecId;
AifMessageId messageId;
}
protected Object dialog()
{
DialogRunbase dialogRunbase;
dialogRunbase = super();
dialogRunbase.caption(AifInboundParallelMsgProcess::description());
dialogRunbase.addText("Runbase framework doesnt allow Guid type fields");
dialogRunbase.addText("reference field shows the gatewayqueue record");
dlgfRecId = dialogRunbase.addField(extendedTypeStr(AifGatewayQueueRecId));
dlgfRecId.lookupButton(2);
return dialogRunbase;
}
public AifGatewayQueue findGatewayQueue(RecId _recId)
{
AifGatewayQueue aifGatewayQueue;
select aifGatewayQueue
where aifGatewayQueue.RecId == _recId;
return aifGatewayQueue;
}
public boolean getFromDialog()
{
boolean ret;
ret = super();
gateWayQueueRecId = dlgfRecId.value();
return ret;
}
public AifMessageId parmMessageId(AifMessageId _messageId = messageId)
{
messageId = _messageId;
return messageId;
}
public void run()
{
if (gatewayQueueRecId != 0 && messageId == emptyGuid())
{
messageId = this.findGatewayQueue(gateWayQueueRecId).MessageId;
}
try
{
ttsBegin;
if (messageId != emptyGuid())
{
this.runSingleMsgId(messageId);
AifQueueManager::createQueueManagerData();
}
else
{
throw error ("invalid message id please enter valid messageid");
}
ttsCommit;
}
catch
{
throw error("process has been aborted");
}
}
private void runSingleMsgId(AifMessageId _messageId)
{
AifGatewayQueue gatewayQueue;
AifInboundMsgProcess inboundMsgProcess;
AifResourceLockId resourceLockId;
;
setprefix(classstr(InboundParallelMsgProcessPerMsgId) + '-' + methodstr(Krishh_InboundParallelMsgProcessPerMsgId , run));
select firstOnly gatewayQueue
where gatewayQueue.MessageId == _messageId;
if (gatewayQueue)
{
resourceLockId = AifResourceLock::lockResource(guid2str(gatewayQueue.MessageId),
AifResourceType::Message,
AifResourceLockType::DocumentService);
// Process message only if lock is created.
if(resourceLockId)
{
AifResourceIdMap::createMsgResourceMap(guid2str(gatewayQueue.MessageId), gatewayQueue.MessageId);
// remember selected record
inboundMsgProcess = new AifInboundMsgProcess(gatewayQueue.data(), resourceLockId);
inboundMsgProcess.run();
}
}
}
public boolean validate(Object calledFrom = null)
{
boolean ret;
ret = super(calledFrom);
if (this.findGatewayQueue(gateWayQueueRecId).RecId == 0)
{
throw error("Queue not found");
}
return ret;
}
public static Krishh_InboundParallelMsgProcessPerMsgId construct()
{
return new Krishh_InboundParallelMsgProcessPerMsgId ();
}
public static void main(Args args)
{
Krishh_InboundParallelMsgProcessPerMsgId inboundParallelMsgProcessPerMsgId;
inboundParallelMsgProcessPerMsgId = Krishh_InboundParallelMsgProcessPerMsgId ::construct();
if (inboundParallelMsgProcessPerMsgId.prompt())
{
inboundParallelMsgProcessPerMsgId.run();
}
}
class Krishh_InboundParallelMsgProcessPerMsgId extends AifInboundParallelMsgProcess
{
RecId gatewayQueueRecId;
DialogField dlgfRecId;
AifMessageId messageId;
}
protected Object dialog()
{
DialogRunbase dialogRunbase;
dialogRunbase = super();
dialogRunbase.caption(AifInboundParallelMsgProcess::description());
dialogRunbase.addText("Runbase framework doesnt allow Guid type fields");
dialogRunbase.addText("reference field shows the gatewayqueue record");
dlgfRecId = dialogRunbase.addField(extendedTypeStr(AifGatewayQueueRecId));
dlgfRecId.lookupButton(2);
return dialogRunbase;
}
public AifGatewayQueue findGatewayQueue(RecId _recId)
{
AifGatewayQueue aifGatewayQueue;
select aifGatewayQueue
where aifGatewayQueue.RecId == _recId;
return aifGatewayQueue;
}
public boolean getFromDialog()
{
boolean ret;
ret = super();
gateWayQueueRecId = dlgfRecId.value();
return ret;
}
public AifMessageId parmMessageId(AifMessageId _messageId = messageId)
{
messageId = _messageId;
return messageId;
}
public void run()
{
if (gatewayQueueRecId != 0 && messageId == emptyGuid())
{
messageId = this.findGatewayQueue(gateWayQueueRecId).MessageId;
}
try
{
ttsBegin;
if (messageId != emptyGuid())
{
this.runSingleMsgId(messageId);
AifQueueManager::createQueueManagerData();
}
else
{
throw error ("invalid message id please enter valid messageid");
}
ttsCommit;
}
catch
{
throw error("process has been aborted");
}
}
private void runSingleMsgId(AifMessageId _messageId)
{
AifGatewayQueue gatewayQueue;
AifInboundMsgProcess inboundMsgProcess;
AifResourceLockId resourceLockId;
;
setprefix(classstr(InboundParallelMsgProcessPerMsgId) + '-' + methodstr(Krishh_InboundParallelMsgProcessPerMsgId , run));
select firstOnly gatewayQueue
where gatewayQueue.MessageId == _messageId;
if (gatewayQueue)
{
resourceLockId = AifResourceLock::lockResource(guid2str(gatewayQueue.MessageId),
AifResourceType::Message,
AifResourceLockType::DocumentService);
// Process message only if lock is created.
if(resourceLockId)
{
AifResourceIdMap::createMsgResourceMap(guid2str(gatewayQueue.MessageId), gatewayQueue.MessageId);
// remember selected record
inboundMsgProcess = new AifInboundMsgProcess(gatewayQueue.data(), resourceLockId);
inboundMsgProcess.run();
}
}
}
public boolean validate(Object calledFrom = null)
{
boolean ret;
ret = super(calledFrom);
if (this.findGatewayQueue(gateWayQueueRecId).RecId == 0)
{
throw error("Queue not found");
}
return ret;
}
public static Krishh_InboundParallelMsgProcessPerMsgId construct()
{
return new Krishh_InboundParallelMsgProcessPerMsgId ();
}
public static void main(Args args)
{
Krishh_InboundParallelMsgProcessPerMsgId inboundParallelMsgProcessPerMsgId;
inboundParallelMsgProcessPerMsgId = Krishh_InboundParallelMsgProcessPerMsgId ::construct();
if (inboundParallelMsgProcessPerMsgId.prompt())
{
inboundParallelMsgProcessPerMsgId.run();
}
}
No comments:
Post a Comment
Thanks for visiting my blog,
I will reply for your comment within 48 hours.
Thanks,
krishna.