cancel
Showing results for 
Search instead for 
Did you mean: 

Adapter Module not working in Sender Communication Channel working in recie

Former Member
0 Kudos

Hi

I have written one adapter module. IF i give that Adapter Module in Sender Communication channel its not working. If i give that in Reciever Communication Channel its working. If i mention in both the channels then its working in sender communication channel also.But in only sender communication channel its not working in only reciever communication channel its working Can any one tell me why its happening

Thanks & Regards

Ravi Shankar B

Message was edited by:

RaviShankar B

Message was edited by:

RaviShankar B

Message was edited by:

RaviShankar B

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Bhavesh,

Wonderful! ..

I failed to spot that..:(

He did mention that

<i>"If i give that in Reciever Communication Channel its working."</i>

Ravi should be a much relieved person now.

Regards

krishna

bhavesh_kantilal
Active Contributor
0 Kudos

Exactly what I had mentioned in my earlier posts,

<i>Hi,

There must be some propblem in the logic of the code in the Module?

Did you check fior the direction of the message in the module and write the code in it?

Regards

Bhavesh</i>

lets hope ravi is really releived

Regards

Bhavesh

Former Member
0 Kudos

Yes, you had it "spot on"..

and for bhavesh, he should definitely be glad.

Former Member
0 Kudos
bhavesh_kantilal
Active Contributor
0 Kudos

Hi,

There must be some propblem in the logic of the code in the Module?

Did you check fior the direction of the message in the module and write the code in it?

Regards

Bhavesh

Former Member
0 Kudos

hi

if its problem with my code why its working if i give the adapter module in both the communication channels?If i give in only sender communication channel the module is not invoking. its not showing any auditlogs.Can any one please help me

OUTBOUND is for sender

INBOUND is for reciever right.?

the following code i have written

public ModuleData process(

ModuleContext moduleContext,

ModuleData inputModuleData)

throws ModuleException {

String SIGNATURE =

"process(ModuleContext moduleContext, ModuleData inputModuleData)";

Object obj = null;

Message msg = null;

String filename = null;

AuditMessageKey amk = null;

try {

obj = inputModuleData.getPrincipalData();

msg = (Message) obj;

System.out.println("&&&&&&&&&&&&&&&&&" + msg);

if (msg.getMessageDirection().equals(MessageDirection.OUTBOUND)){

amk = new AuditMessageKey(msg.getMessageId(),AuditDirection.OUTBOUND);

Audit.addAuditLogEntry(amk,AuditLogStatus.SUCCESS,">>>>>>>>>>>>>>> etHostName: Module called"+ i++);

}else{

File filename1 = new File("

10.7.1.43
XI
source","text.txt");

filename1.createNewFile();

amk = new AuditMessageKey(msg.getMessageId(),AuditDirection.INBOUND);

Audit.addAuditLogEntry(amk,AuditLogStatus.SUCCESS,">>>>>>>>>>>>>>> etHostName: Module called"+ i++);

}

System.out.println("**************" + amk + "***********");

} catch (Exception e) {

Audit.addAuditLogEntry(amk,AuditLogStatus.SUCCESS,">>>>>>>>>>>>>>> GetHostName: Error Module called");

e.printStackTrace(System.err);

ModuleException me = new ModuleException(e);

throw me;

}

// Read the channel ID, channel and the module configuration

try {

Hashtable mp = (Hashtable)inputModuleData.getSupplementalData("module.parameters");

if(mp != null){

filename = (String)mp.get("FileName");

Audit.addAuditLogEntry(amk,AuditLogStatus.SUCCESS,"Host >>> Element Name is set to {0}"+filename );

}else{

Audit.addAuditLogEntry(amk,AuditLogStatus.WARNING,"HostElementName parameter is not set. Default used: HostName.");

filename = "FileName";

}

} catch (Exception e) {

e.printStackTrace(System.err);

Audit.addAuditLogEntry(amk,AuditLogStatus.ERROR,"Cannot read the module context and configuration data");

ModuleException me = new ModuleException(e);

throw me;

}

try {

XMLPayload xmlpayload = msg.getDocument();

DocumentBuilderFactory factory;

factory = DocumentBuilderFactory.newInstance();

DocumentBuilder builder = factory.newDocumentBuilder();

Document document =

builder.parse((InputStream) xmlpayload.getInputStream());

Element rootNode = document.getDocumentElement();

if (rootNode != null) {

Element childElement = document.createElement("filename");

childElement.appendChild(document.createTextNode(filename));

rootNode.appendChild(childElement);

}

// Transforming the DOM object to Stream object.

TransformerFactory tfactory = TransformerFactory.newInstance();

Transformer transformer = tfactory.newTransformer();

Source src = new DOMSource(document);

ByteArrayOutputStream myBytes = new ByteArrayOutputStream();

Result dest = new StreamResult(myBytes);

transformer.transform(src, dest);

byte[] docContent = myBytes.toByteArray();

if (docContent != null) {

xmlpayload.setContent(docContent);

inputModuleData.setPrincipalData(msg);

}

} catch (Exception e) {

e.printStackTrace(System.err);

Audit.addAuditLogEntry(amk,AuditLogStatus.ERROR,"Cannot read the module context and configuration data");

ModuleException me = new ModuleException(e);

throw me;

}

return inputModuleData;

}

Best Regards

Ravi Shankar B

Message was edited by:

RaviShankar B

Message was edited by:

RaviShankar B

Former Member
0 Kudos

ravi,

I believe the problem can be resolved if we can look at your .xml files. rather than your code because the code has code only to write some data into the audit log after your module is invoked but in your case the module doesnt seem to work right?

Regards

krishna

bhavesh_kantilal
Active Contributor
0 Kudos

Finally...!!

<b>if (msg.getMessageDirection().equals(MessageDirection.OUTBOUND)){</b>

In this if clause here you are chcking if the direction of the message is Outbound, i.e , it is outbound fromt he integartion engine to the afdapter engine. That is why the module works with receievr Adapters and not Sender Adapters.

Please remove this If clause from your code and it will work with sender adapters also.

Eactly what i asked you to check earlier.

Regards

Bhavesh

Former Member
0 Kudos

Hay Ravi,

can you give some more details? what the adapter module does? where did you added it?