on 07-05-2006 7:19 PM
Hi All
I have a scenario where I am picking up a set of files using the File Adapter Sender. The polling is set to 60 seconds and the processing paramerter are EOIO. I have a bean in place to convert the file so picked up into Base64.
What I see happen is that the Bean is returning the same converted string for more then a couple of messages ie.
File1 -> Bean Conversion -> File1 Converted Message
File2 -> Bean Conversion -> File1 Converted Message
File3 -> Bean Conversion -> File1 Converted Message
In the later two cases it should have returned
File2 Converted Message
File3 Converted Message
Why is this happening ? How can I trace this to see what is wrong. Isnt the Module context and Module Data supposed to change with each case.
Here is the code in my Bean
package mckpedBase64;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
import javax.ejb.CreateException;
import com.sap.aii.af.mp.module.*;
import com.sap.aii.af.ra.ms.api.*;
import com.sap.aii.utilxi.base64.api.Base64;
/**
@ejbHome <{mckpedBase64.ConvertoBase64Home}>
@ejbLocal <{mckpedBase64.ConvertoBase64Local}>
@ejbLocalHome <{mckpedBase64.ConvertoBase64LocalHome}>
@ejbRemote <{mckpedBase64.ConvertoBase64}>
@stateless
@transactionType Container
*/
public class ConvertoBase64Bean implements SessionBean, Module {
public void ejbRemove() {
}
public void ejbActivate() {
}
public void ejbPassivate() {
}
public void setSessionContext(SessionContext context) {
myContext = context;
}
private SessionContext myContext;
/**
Business Method.
*/
public ModuleData process(
ModuleContext modulecontext,
ModuleData inputModuleData) {
try{
Object obj = null;
Message msg = null;
XMLPayload xmlpayload = null;
String str_b64 = " ";
String xmldata = " ";
obj = inputModuleData.getPrincipalData();
msg = (Message) obj;
//Payload payload = msg.getDocument();
xmlpayload = msg.getDocument();
str_b64 = com.sap.aii.utilxi.base64.api.Base64.encode(xmlpayload.getContent());
xmldata =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n"
+ "<ns:"
+ "MC_SOAPFile_mt"
+ " xmlns:ns=\""
+ "http:/MCK_FILERFCSOAPRFC.COM"
+ "\">\n"
+ "<MCREQ>"
+ str_b64
+ "</MCREQ>\n"
+ "</ns:"
+ "MC_SOAPFile_mt"
+ ">";
xmlpayload.setContent(xmldata.getBytes());
inputModuleData.setPrincipalData(msg);
} catch (Exception e) {}
//System.out.print(e.getMessage());}
return inputModuleData;
}
/**
Create Method.
*/
public void ejbCreate() throws CreateException {
}
}
Regards
Aju Paul
Hi Aju,
>>Isnt the Module context and Module Data supposed to change with each case.
Yes, these objects will change with each incoming data.
Comment this line of code and try...
inputModuleData.setPrincipalData(msg);
>>How can I trace this to see what is wrong.
You can trace the messages inside the process method by writing them into a file using the following code...
File f = new File("d:
testing.txt");
FileOutputStream fos = new FileOutputStream(f);
PrintStream ps = new PrintStream(fos);
ps.println("Testing");
and finally close the file fos.close();
Regards,
Uma
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi All
After a lot of effort I found out that the issue is the statement
str_b64 = com.sap.aii.utilxi.base64.api.Base64.encode(xmlpayload.getContent());
code.
It looks like the static method is only returing the result of the first conversion. Even if it is called multiple times with different xmlpayloads !
Any thoughts ?
Aju
Hi Aju,
have you tried using the class sun.misc.BASE64Encoder for your base 64 encoding?
You can use it like this:
BASE64Encoder encoder = new BASE64Encoder();
String enc = encoder.encodeBuffer(byteArray);
I know it's not an offical java class, but it works... hopefully
Regards,
Matthias
Message was edited by: Matthias Fueller
Hi Aju,
Does that file get deleted after it gets picked up from the folder? Is your adapter in the test/delete mode?? Also check if the second file's payload can be seen in sxmb_moni..
Jusr try the delete mode and if you donot want the file to be rmoved altogether, archive the file which is already picked up.
Regards,
Sushumna
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sushumma
Yes, its on archive mode. I have also checked the messages in MONI. The message picked in the Bean is the right one. Only when I make the call for the Base64 call, does it start behaving weird.
Its looks like the static method is doing something or ts getting stuck somewhere between the Module Processor and the AE
Aju
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.