cancel
Showing results for 
Search instead for 
Did you mean: 

Issue in Adapter Module

Former Member
0 Kudos

Hi Experts,

I have written an Adapter module to set the target file name (because it could not be done with usual DynamicConfig in mapping because of multimapping). I am facing a peculiar issue with it. For ex: I have 3 msgs. First msg started executing the module to set the target fillename and about to end the module execution. Meanwhile second msg enters the module execution and changes the file name. This is resulting in first msg to post a file with name set by second msg. I have put "Maintain order at runtime" in interface determination of ID to fix the issue. But this isssue is still persisting. Please let me know, how can a msg acquire a lock on the module and untill it finishes it execution, no other msg should start the module execution.

Thanks,

Rakesh

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

did u chk this:

gagandeep_batra
Active Contributor
0 Kudos

Hi,

try to implement the serialization in the Adapter module.it can help.

Thanks,

Gagandeep

MichalKrawczyk
Active Contributor
0 Kudos

Hi,

>>>try to implement the serialization in the Adapter module.it can help.

can you please describe how, if the adapter module sets the dynamic config for each of the processed messages one by one ?

Thank you,

Regards,

Michal Krawczyk

Former Member
0 Kudos

Hello,

I have a multi mapping because of which multiple msgs will be processed by a adapter in AE. Once first msg starts executing the module and sets the file name to "101_file.xml" (by referring to contents of the file like Docno=101) and is about to leave module, second msg enters and sets the file name to 102_file.xml (because for second msg Docno=102). And by the time first msg is about to write the file , file name has been changed. Hence file will be written with name 102_file.xml and will contain contents of Docno=101. I have set the "Maintain order at runtime" in interface determination of ID and I supposed that this will resolve the issue. But this issue has reocured. Please suggest how we can prevent subsequent msgs from executing the Adapter, when its predecessor msg is executing it.

Thanks,

Rakesh

gagandeep_batra
Active Contributor
0 Kudos

Hi,

i think we can implement the concept of serialization in java.

and if we try to implement same concept here that can help to block for calling the module for multiple times.

by this one message can call module at one time only.

Thanks

Gagandeep

Former Member
0 Kudos

Hi,

I have checked the msg data tab for the msg in AE. It shows Quality of Service = Exactly Once . I have set "Maintain order at runtime" in interface determination. This should change the QOS to EOIO (I suppose). But still its showing as Exactly Once . I think changing the QOS to EOIO will solve my purpose. How can I change the QOS to EOIO for a msg before it enters the AE (receiver Adapter) for execution.

Thanks,

Rakesh

MichalKrawczyk
Active Contributor
0 Kudos

Hi,

the adapter module is executed once per one message - another execution of the adapter does not change the dynamic condifg set in adapter module in the first call - I have no idea what you've implemented but adapter modules don't have access to dynamic config of any other message being processed

Regards,

Michal Krawczyk

Former Member
0 Kudos

Hi Michal,

I have written below code to name the \target file in module code. I have also set "Adapter specific msg attributes" in receiver file adapter and referred file name from dynamic config:

public ModuleData process(ModuleContext inputModuleContext, ModuleData inputModuleData)

throws ModuleException {

Object obj = null;

Message msg = null;

AuditAccess audit = null;

MessageKey keyOut = null;

obj = inputModuleData.getPrincipalData();

msg = (Message) obj;

keyOut = new MessageKey(msg.getMessageId(),msg.getMessageDirection());

try

{

audit = PublicAPIAccessFactory.getPublicAPIAccess().getAuditAccess();

audit.addAuditLogEntry(keyOut, AuditLogStatus.SUCCESS, "Module Started Execution..");

MessagePropertyKey mpk = new MessagePropertyKey("FileName","http://sap.com/xi/XI/System/File");

InputStream is = msg.getDocument().getInputStream();

DocumentBuilderFactory docBuilderFact = DocumentBuilderFactory.newInstance();

DocumentBuilder docBuilder = docBuilderFact.newDocumentBuilder();

Document doc = docBuilder.parse(is);

Node nl = (Node) doc.getDocumentElement();

Node n = nl.getFirstChild();

Attr a = (Attr) n.getAttributes().item(0);

String Num = a.getValue();

audit.addAuditLogEntry(keyOut, AuditLogStatus.SUCCESS, "Number is "+Num);

Attr a1,a2;

if (n.getNodeName().equalsIgnoreCase("Create"))

{

a1 = (Attr) n.getAttributes().item(1);

String sd = a1.getValue();

audit.addAuditLogEntry(keyOut, AuditLogStatus.SUCCESS, "Start Date is "+sd);

String fileName = sd + "-" + Num + ".xml";

msg.setMessageProperty(mpk,fileName);

}

else(n.getNodeName().equalsIgnoreCase("Update"))

{

a2 = (Attr) n.getAttributes().item(2);

String sd = a2.getValue();

audit.addAuditLogEntry(keyOut, AuditLogStatus.SUCCESS, "Start Date is "+sd);

String fileName = sd + "-" + Num + ".xml" ;

msg.setMessageProperty(mpk,fileName);

}

}

catch(Exception e)

{

audit.addAuditLogEntry(keyOut, AuditLogStatus.ERROR, "Execption Occured.." + e);

}

return inputModuleData;

}

When 3 msgs get created for Create interface, File name set by first msg is being changed by second and file for first msg is posted with name set by second (because second msg has changed the target file in module code by that time )

MichalKrawczyk
Active Contributor
0 Kudos

Hi,

if you set the dynamic config in the adapter module (which is a normal thing)

it will not be changed for this message by any other adapter module's execution... it's not possible

there is no need to set any lock for module execution

to be honest I don't know how would your scenario be even possible

Regards,

Michal Krawczyk