cancel
Showing results for 
Search instead for 
Did you mean: 

Invocation of an EJB asynchronous method takes a lot of time

Former Member
0 Kudos

Would I like to know that it can provoke that a call to an asynchronous method EJB takes so much time (1-8 seconds)?

I developed the example [Calculator|http://help.sap.com/saphelp_nw04/helpdata/en/7d/cf0c8abcc34594ba9d3bbd5dd22155/content.htm] and the calls are very fast. (ten calls to the Add method were made in 79 Milliseconds).

But when I invoke an asynchronous method EJB that was developed using the Java Proxy Generation of the Integration Builder, its invocation takes long time, between 1 and 8 seconds (each call).

What can I check to know where the problem is?

Example Calculator EJB Invoke (Very Fast):

try {
	Context ctx = new InitialContext();
	CalculatorHome home =
	(CalculatorHome) ctx.lookup("sap.com/CalculatorEar/CalculatorBean");
	remote = home.create();

	float a = 1;
	float b = 5;

	float result; 
	long startTime;
	long stopTime;
	long elapsedTime;

	for (int i = 0; i < 10; i++) {

		startTime = System.currentTimeMillis();

		result = remote.add(a, b);

		stopTime = System.currentTimeMillis();

		elapsedTime = stopTime - startTime;

		System.out.println("Time: " +  elapsedTime);
	}

} catch (Exception e) {
	System.out.println("Exception:" + e.getLocalizedMessage());
}

Example Java Proxy Generation EJB (Very Slow):

try {
			
	Context ctx = new InitialContext();
	OaMI_PortTypeHome home = (OaMI_PortTypeHome) ctx.lookup("JNDI_oaMI");
	queryOutRemote =  home.create();

	//Set parameters for the proxy call (parameter of ejb method)
	...

	queryOutRemote.$messageSpecifier();

	float result; 
	long startTime;
	long stopTime;
	long elapsedTime;

	for (int i = 0; i < 10; i++) {

		startTime = System.currentTimeMillis();

		queryOutRemote.oaMIMethod(parameter);

		stopTime = System.currentTimeMillis();

		elapsedTime = stopTime - startTime;

		System.out.println("Time: " +  elapsedTime);
	}

} catch (Exception e) {
	System.out.println("Exception:" + e.getLocalizedMessage());
}

Thanks, and Regards,

Roger Solano

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Roger,

What does the OAMIMethod do exactly ? If this method causes long runtime, maybe you could add elapsed time logging/tracing to see which part(s) of it take(s) long time to perform ...

It won't help you a lot, but this could be a good starting point ...

Chris

Former Member
0 Kudos

Thanks Chris,

The EJB was generated by Java Proxy Generation from an outbound asynchronouse message interface using the Integration Builder.

The classes and methods ares generated automatically by Java Proxy Generation so the oaMIMethod

send one message from J2EE to SAP XI.

If the interface from which the proxy was generated is an asynchronous interface, should not the oaMIMethod method be executed also in asynchronous mode?

Should not the method once invoked for his execution return immediately?

thank you in advance,

Regards,

Roger

stefan_grube
Active Contributor
0 Kudos

An interesting approach to compare a method, which just adds two integer values, and a method, which creates an XML structures, stores it to a database and sends it via HTTP to an external system.

Stefan

Former Member
0 Kudos

How can I do the call to the oaMI method Asynchronously mode?

In .NET i can call the RFC methods asynchronously with SAP .NET Connector using the method Begin<RFC name> .

How can i do this in Java?

forgive me for the inconveniences, I'm new in JAVA and XI.

Regards,

Roger

Answers (0)